Opened 3 years ago

Closed 2 years ago

Last modified 2 years ago

#4591 closed defect (fixed)

Crash after dispose

Reported by: asmirnov Assignee: asmirnov
Priority: P2 Milestone:
Module: Libadblockplus-Android Keywords:
Cc: Blocked By:
Blocking: #4399 Platform: Android
Ready: yes Confidential: no
Tester: Scheer Verified working: yes
Review URL(s):

https://codereview.adblockplus.org/29361556

Description

Environment

The app uses filterengine for ad-blocking. When the main activity is destroyed we dispose adblock engine and it disposes filterengine. However after few minutes after the app is closed we're getting NRE in native code (sigsegv 11).

How to reproduce

  1. open the app (webviewapp)
  2. go to google.com
  3. navigate random website
  4. close the app (press back)
  5. wait for few minutes
  6. see "app crashed" android message

Observed behaviour

Crash message

Expected behaviour

Nothing happens

Attachments (3)

native_exception.txt (5.2 KB) - added by asmirnov 3 years ago.
native crash stacktrace
full_log.txt (566.7 KB) - added by asmirnov 3 years ago.
full log
full_log2.txt (369.1 KB) - added by asmirnov 3 years ago.

Download all attachments as: .zip

Change History (11)

Changed 3 years ago by asmirnov

native crash stacktrace

Changed 3 years ago by asmirnov

full log

Changed 3 years ago by asmirnov

comment:1 Changed 3 years ago by asmirnov

this cause NRE (GetJavaVM() returns null)

11-01 10:27:55.264 24316-24366 V/AdblockJNI: JniFilterChangeCallback subscription.lastCheck
void JniFilterChangeCallback::Callback(const std::string& arg,
    const AdblockPlus::JsValuePtr jsValue)
{
  __android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "JniFilterChangeCallback %s", arg.c_str());
  JNIEnvAcquire env(GetJavaVM());
...

comment:2 Changed 3 years ago by asmirnov

everything seems to be allocated and released correctly (checked raw addresses), however callback is invoked after disposing:

11-01 15:51:49.410 13190-13190 V/AdblockJNI: JniFilterChangeCallback JniCtor 0xb83ce740
11-01 15:51:50.630 13190-13190 V/AdblockJNI: FilterEngine Ctor 0xb8418ad0
11-01 15:51:50.630 13190-13190 V/AdblockJNI: set filter callback 0xb83ce740
11-01 15:51:50.630 13190-13190 V/AdblockJNI: JniFilterChangeCallback subscription.title in 0xb83ce740
11-01 15:51:50.630 13190-13190 V/AdblockJNI: JniFilterChangeCallback subscription.homepage in 0xb83ce740
11-01 15:51:50.630 13190-13190 V/AdblockJNI: JniFilterChangeCallback subscription.title in 0xb83ce740
11-01 15:51:50.630 13190-13190 V/AdblockJNI: JniFilterChangeCallback subscription.homepage in 0xb83ce740
11-01 15:51:50.630 13190-13190 V/AdblockJNI: JniFilterChangeCallback subscription.title in 0xb83ce740
11-01 15:51:50.630 13190-13190 V/AdblockJNI: JniFilterChangeCallback subscription.homepage in 0xb83ce740
11-01 15:51:50.630 13190-13190 V/AdblockJNI: JniFilterChangeCallback subscription.title in 0xb83ce740
11-01 15:51:50.630 13190-13190 V/AdblockJNI: JniFilterChangeCallback subscription.homepage in 0xb83ce740
11-01 15:51:50.630 13190-13190 V/AdblockJNI: JniFilterChangeCallback subscription.title in 0xb83ce740
11-01 15:51:50.630 13190-13190 V/AdblockJNI: JniFilterChangeCallback subscription.homepage in 0xb83ce740
11-01 15:51:50.630 13190-13190 V/AdblockJNI: JniFilterChangeCallback subscription.title in 0xb83ce740
11-01 15:51:50.630 13190-13190 V/AdblockJNI: JniFilterChangeCallback subscription.homepage in 0xb83ce740
11-01 15:51:50.630 13190-13190 V/AdblockJNI: JniFilterChangeCallback subscription.title in 0xb83ce740
11-01 15:51:50.630 13190-13190 V/AdblockJNI: JniFilterChangeCallback subscription.homepage in 0xb83ce740
11-01 15:51:50.630 13190-13190 V/AdblockJNI: JniFilterChangeCallback subscription.title in 0xb83ce740
11-01 15:51:50.630 13190-13190 V/AdblockJNI: JniFilterChangeCallback subscription.homepage in 0xb83ce740
11-01 15:51:50.630 13190-13190 V/AdblockJNI: JniFilterChangeCallback subscription.title in 0xb83ce740
11-01 15:51:50.630 13190-13190 V/AdblockJNI: JniFilterChangeCallback subscription.homepage in 0xb83ce740
11-01 15:51:50.630 13190-13190 V/AdblockJNI: JniFilterChangeCallback subscription.title in 0xb83ce740
11-01 15:51:50.630 13190-13190 V/AdblockJNI: JniFilterChangeCallback subscription.homepage in 0xb83ce740
11-01 15:51:50.630 13190-13190 V/AdblockJNI: JniFilterChangeCallback subscription.title in 0xb83ce740
11-01 15:51:50.630 13190-13190 V/AdblockJNI: JniFilterChangeCallback subscription.homepage in 0xb83ce740
11-01 15:51:50.630 13190-13190 V/AdblockJNI: JniFilterChangeCallback subscription.title in 0xb83ce740
11-01 15:51:50.630 13190-13190 V/AdblockJNI: JniFilterChangeCallback subscription.homepage in 0xb83ce740
11-01 15:51:50.630 13190-13190 V/AdblockJNI: JniFilterChangeCallback subscription.title in 0xb83ce740
11-01 15:51:50.630 13190-13190 V/AdblockJNI: JniFilterChangeCallback subscription.homepage in 0xb83ce740
11-01 15:51:50.630 13190-13190 V/AdblockJNI: JniFilterChangeCallback subscription.title in 0xb83ce740
11-01 15:51:50.630 13190-13190 V/AdblockJNI: JniFilterChangeCallback subscription.homepage in 0xb83ce740
11-01 15:51:52.230 13190-13276 V/AdblockJNI: JniFilterChangeCallback save in 0xb83ce740
11-01 15:52:17.060 13190-13190 V/AdblockJNI: FilterEngine Dtor 0xb8418ad0
11-01 15:52:17.060 13190-13190 V/AdblockJNI: JniFilterChangeCallback JniDtor 0xb83ce740
11-01 15:52:49.561 13190-13241 V/AdblockJNI: JniFilterChangeCallback subscription.lastCheck in 0xb83ce740

comment:3 Changed 3 years ago by asmirnov

after removing static callbacks in AdblockEngine:

11-02 07:52:53.720 1843-1843 V/AdblockJNI: JsEngine Ctor
11-02 07:52:55.400 1843-1843 V/AdblockJNI: FilterEngine Ctor 0xb8cf4b10 (using js engine 0xb8cc3550)
11-02 07:53:13.610 1843-1843 V/AdblockJNI: FilterEngine Dtor 0xb8cf4b10
11-02 07:53:13.610 1843-1843 V/AdblockJNI: JsEngine Dtor 0xb8cc3550 (count=6)

still having some references to Js engine.

comment:4 Changed 3 years ago by asmirnov

relates to #3594

comment:5 Changed 3 years ago by asmirnov

  • Review URL(s) modified (diff)
  • Status changed from new to reviewing

comment:6 Changed 3 years ago by scheer

  • Tester changed from Unknown to Scheer
  • Verified working set
  • After backing through to the home screen after a page has loaded in step 3, the app no longer crashes.

ABP for Lightning Browser (95)
Galaxy S7
Android 6.0.1

comment:7 Changed 2 years ago by asmirnov

  • Resolution set to fixed
  • Status changed from reviewing to closed

comment:8 Changed 2 years ago by asmirnov

The source code changes will be included in issue 4399 files

Note: See TracTickets for help on using tickets.