Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: exit(0) causes ANR due to destroyed mutex #1820

Merged
merged 2 commits into from
Oct 15, 2024

Conversation

mukaschultze
Copy link
Contributor

Description

When initializing the runtime in direct boot mode the exit(0) IO cleanup causes a SIGABRT with the following message:

libc    : FORTIFY: pthread_mutex_destroy called on a destroyed mutex (0x759399de1718)

This SIGABRT is caught by the SIG_handler which in turn throws a tsn::NativeScriptException. I'm not exactly sure what catches this NativeScriptException, but whatever it is either deadlocks or keeps re-throwing it until the device runs out of memory.

void SIG_handler(int sigNumber) {
stringstream msg;
msg << "JNI Exception occurred (";
switch (sigNumber) {
case SIGABRT:
msg << "SIGABRT";
break;
case SIGSEGV:
msg << "SIGSEGV";
break;
default:
// Shouldn't happen, but for completeness
msg << "Signal #" << sigNumber;
break;
}
msg << ").\n=======\nCheck the 'adb logcat' for additional information about the error.\n=======\n";
throw NativeScriptException(msg.str());
}

This bug shows up as an ANR (App not responding) in Crashlytics and Google Play console (as reported in NativeScript/NativeScript#10527).

The same issue was reported on flutter/flutter#103587, which leads me to believe this is not specific to Nativescript's runtime.

My proposed solution is to use _Exit(0) instead, which doesn't trigger any cleanup process and simply ends the process.

Full error below:

08-28 13:56:32.187  1506  1506 D TNS.Runtime: V8 version 10.3.22
08-28 13:56:32.191  1506  1506 E TNS.error: metadata folder couldn't be opened! (Error: 2) 
--------- beginning of crash
08-28 13:56:32.191  1506  1506 F libc    : FORTIFY: pthread_mutex_destroy called on a destroyed mutex (0x759399de1718)
08-28 13:56:32.191  1506  1506 F TNS.Native: JNI Exception occurred (SIGABRT).
08-28 13:56:32.191  1506  1506 F TNS.Native: =======
08-28 13:56:32.191  1506  1506 F TNS.Native: Check the 'adb logcat' for additional information about the error.
08-28 13:56:32.191  1506  1506 F TNS.Native: =======
08-28 13:56:32.191  1506  1506 E libc++abi: terminating with uncaught exception of type tns::NativeScriptException

Related Pull Requests

#1712
NativeScript/plugins#262
NativeScript/NativeScript#10527

Does your pull request have unit tests?

@edusperoni edusperoni merged commit 94ddb15 into NativeScript:main Oct 15, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants