Skip to content

SIGSEGV in libNativeScript.so on callback from java with console.log when displaying an object. #1366

@Yermo

Description

@Yermo

Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

  • CLI: 5.3.2
  • Cross-platform modules: 5.3.1 (core modules)
  • Android Runtime: 5.3.1
  • iOS Runtime (if applicable):
  • Plugin(s): working on developing a background geolocation plugin

Describe the bug

I am running into a crash in libNativeScript.so during garbage collection.

I do not know if this is a bug in the code I am working with or whether I've uncovered a bug in NativeScript. I am posting this here in the hopes of getting some pointers to determine in which category it falls.

I am porting over the background geolocation plugin from Cordova.

https://github.com/mauron85/cordova-plugin-background-geolocation

That plugin is based on this library, which I have forked but not modified: https://github.com/Yermo/background-geolocation-android

I'm using the Plugin Seed and have the android side of the plugin working. However, after between 1 and 13 hours or so it crashes during garbage collection. The crash is happening in libNativeScript.so with a NULL reference SEGV during what appears to be garbage collection. If it was a case of the underlying library freeing an object and then NativeScript attempting to free it during it's GC I would have expected to see "attempt to use cleared object refererence" instead of a NULL pointer de-reference.

From the tombstone file:

*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'Lenovo/TB-8504F/TB-8504F:8.1.0/OPM1.171019.019/8504F_S001011_181016_ROW:user/release-keys'
Revision: '0'
ABI: 'arm64'
pid: 12292, tid: 12292, name: location.ngdemo  >>> com.flyingbricksoftware.backgroundgeolocation.ngdemo <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
Cause: null pointer dereference
    x0   000000769e780058  x1   0000000000000000  x2   000000769e780068  x3   0000000000000001
    x4   4c271b83f1119a75  x5   0000000000000005  x6   0000000000107020  x7   00000000009261ce
    x8   0000000000000000  x9   0000000000009330  x10  0000000000000018  x11  0000000000000030
    x12  0000000000009340  x13  000000769441b0a1  x14  000000769441b0a1  x15  0000000000000001
    x16  000000769dcc0608  x17  000000769d222230  x18  0000000000000001  x19  0000007fc9bc3100
    x20  0000007fc9bc3190  x21  0000007fc9bc30f8  x22  000000769e6a3c00  x23  000000769e780068
    x24  000000769e780058  x25  000000769e780058  x26  0000000000000005  x27  0000000000000001
    x28  0000000000000000  x29  0000007fc9bc2f30  x30  000000769d222224
    sp   0000007fc9bc2e70  pc   000000769d222250  pstate 0000000080000000
    v0   00000000000000010000000000000001  v1   000000000000dc030000000000933dd1
    v2   00000000000000003f7573c559b0c412  v3   000000000000000040a5700000000000
    v4   00000000000000000000000000000ab8  v5   00000000000000000000000000000000
    v6   00000000cc004fb40000000000000000  v7   00000000540060900000000000000000
    v8   00000000000000000000000000000000  v9   00000000000000000000000000000000
    v10  00000000000000000000000000000000  v11  00000000000000000000000000000000
    v12  00000000000000000000000000000000  v13  00000000000000000000000000000000
    v14  00000000000000000000000000000000  v15  00000000000000000000000000000000
    v16  00000000000000000000000000000000  v17  00000000540060900000000000000000
    v18  00000000000000000000000000000000  v19  00000000540060900000000000000000
    v20  00000000000000000000000000000000  v21  00000000540060900000000000000000
    v22  00000000000000000000000000000000  v23  00000000540060900000000000000000
    v24  00000000000000000000000000000000  v25  00000000540060900000000000000000
    v26  00000000000000000000000000000000  v27  00000000540060900000000000000000
    v28  00000000000000000000000000000000  v29  00000000540060900000000000000000
    v30  00000000000000000000000000000000  v31  00000000540060900000000000000000
    fpsr 00000013  fpcr 00000000

backtrace:
    #00 pc 0000000000386250  /data/app/com.flyingbricksoftware.backgroundgeolocation.ngdemo-1Lh3czgPMLXfgVYeCePdOA==/lib/arm64/libNativeScript.so (v8::Object::HasOwnProperty(v8::Local<v8::Context>, v8::Local<v8::Name>)+32)
    #01 pc 0000000000386220  /data/app/com.flyingbricksoftware.backgroundgeolocation.ngdemo-1Lh3czgPMLXfgVYeCePdOA==/lib/arm64/libNativeScript.so (v8::Object::HasPrivate(v8::Local<v8::Context>, v8::Local<v8::Private>)+8)
    #02 pc 000000000022c66c  /data/app/com.flyingbricksoftware.backgroundgeolocation.ngdemo-1Lh3czgPMLXfgVYeCePdOA==/lib/arm64/libNativeScript.so
    #03 pc 0000000000201e90  /data/app/com.flyingbricksoftware.backgroundgeolocation.ngdemo-1Lh3czgPMLXfgVYeCePdOA==/lib/arm64/libNativeScript.so
    #04 pc 000000000021a4dc  /data/app/com.flyingbricksoftware.backgroundgeolocation.ngdemo-1Lh3czgPMLXfgVYeCePdOA==/lib/arm64/libNativeScript.so
    #05 pc 000000000049ab30  /data/app/com.flyingbricksoftware.backgroundgeolocation.ngdemo-1Lh3czgPMLXfgVYeCePdOA==/lib/arm64/libNativeScript.so
    #06 pc 000000000049b3b0  /data/app/com.flyingbricksoftware.backgroundgeolocation.ngdemo-1Lh3czgPMLXfgVYeCePdOA==/lib/arm64/libNativeScript.so
    #07 pc 00000000004a5548  /data/app/com.flyingbricksoftware.backgroundgeolocation.ngdemo-1Lh3czgPMLXfgVYeCePdOA==/lib/arm64/libNativeScript.so
    #08 pc 00000000004a3964  /data/app/com.flyingbricksoftware.backgroundgeolocation.ngdemo-1Lh3czgPMLXfgVYeCePdOA==/lib/arm64/libNativeScript.so (v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageColl
ectionReason, v8::GCCallbackFlags)+1328)
    #09 pc 00000000004ad744  /data/app/com.flyingbricksoftware.backgroundgeolocation.ngdemo-1Lh3czgPMLXfgVYeCePdOA==/lib/arm64/libNativeScript.so
    #10 pc 00000000004ad7c4  /data/app/com.flyingbricksoftware.backgroundgeolocation.ngdemo-1Lh3czgPMLXfgVYeCePdOA==/lib/arm64/libNativeScript.so
    #11 pc 0000000000472920  /data/app/com.flyingbricksoftware.backgroundgeolocation.ngdemo-1Lh3czgPMLXfgVYeCePdOA==/lib/arm64/libNativeScript.so (v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace)+48)
    #12 pc 00000000009f6c00  /data/app/com.flyingbricksoftware.backgroundgeolocation.ngdemo-1Lh3czgPMLXfgVYeCePdOA==/lib/arm64/libNativeScript.so
    #13 pc 0000000000b10a88  /data/app/com.flyingbricksoftware.backgroundgeolocation.ngdemo-1Lh3czgPMLXfgVYeCePdOA==/lib/arm64/libNativeScript.so

I have attempted to use ndk-stack and addr2line to get an idea about the cause of the crash but I'm guessing the version of libNativeScript.so shipped out doesn't contain debugging symbols?

Is there some way to determine what was happening on the javascript side immediately before this crash? (Which would help me figure out if it's in my code)

Is there a guide or some information somewhere on how one can best approach tracking down an issue like this?

I should mention I am not using markingMode:none. Adding that seems to make the app much less stable. Maybe that's a clue?

To Reproduce

Expected behavior

Sample project

I do not yet have a small test case that reproduces the problem. With some pointers I'm hoping to narrow it down so I can provide a test case.

Additional context

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions