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

Remove calls to JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions() #73

Closed
appden opened this issue Oct 20, 2015 · 7 comments

Comments

@appden
Copy link
Contributor

appden commented Oct 20, 2015

It gets called inside RealmRPC.mm and RealmReactTests.m to prevent crashes. The issue is that calls to JSObjectCallAsFunction (and others) that result in an exception will in turn make JavaScriptCore want to create a stack trace that includes native functions.

My current theory is that JavaScriptCore doesn't correctly handle C++ lambdas (and might be fixed in the RPC server by switching to regular functions when migrating to pure C++ – see #72), though it may instead be caused by something else pertaining to how we link together our framework.

@appden appden changed the title Remove need to call JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions function Remove calls to JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions() Oct 20, 2015
@bdash
Copy link
Contributor

bdash commented Oct 20, 2015

Do you have the crash report / stack trace of the crash you see without the call to JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions?

@appden
Copy link
Contributor Author

appden commented Oct 20, 2015

Sure. It crashes at dladdr. JavaScriptCore is passing a function pointer it got from calling backtrace.

screen shot 2015-10-20 at 11 52 52 am

@bdash
Copy link
Contributor

bdash commented Oct 20, 2015

Thanks. I'm not sure it's inherently related to C++ lambdas. On OS X 10.11.1, a test program that uses backtrace, dladdr, and abi::__cxa_demangle in a similar manner to JavaScriptCore's appendAPIBacktrace has no problem. You can see the code I tested with at https://gist.github.com/bdash/906bddc3d5ece607b4af.

@appden
Copy link
Contributor Author

appden commented Oct 20, 2015

@bdash you're right. It's actually crashing on the last element of the trace, which is the return address for main it looks like. I'm not quite sure why. If I artificially make the stack trace deeper (with a little recursive function), then it no longer crashes. 😄

@appden
Copy link
Contributor Author

appden commented Oct 20, 2015

Just an update: [NSThread callStackSymbols] also causes it to crash the same way (it does essentially the same thing). We are doing this inside a dispatch_sync(dispatch_get_main_queue(), ^{...}), which might part of the issue.

@appden
Copy link
Contributor Author

appden commented Oct 20, 2015

It's definitely fixed if I run everything inside my own thread, which will be fine for this purpose, but I'd still really like to understand what the issue is with main.

@alazier alazier added the P2 label Oct 20, 2015
@appden
Copy link
Contributor Author

appden commented Oct 28, 2015

Update: since upgrading to Xcode 7.1, this crash no longer seems to happen on the main thread in the iOS 9.1 simulator (thanks @bdash). However, I have seen this crash occur on other threads unrelated to JavaScriptCore, such as when RCTLog attempts to create a backtrace with backtrace_symbols.

I need to test this on a device running 9.0.x (not 9.1) to see if it's an issue there before deciding to remove calls to JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions().

@alazier alazier added P3 and removed P2 labels Nov 24, 2015
alazier pushed a commit that referenced this issue Sep 14, 2016
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants