Hermes: Get `ndk-stack` working to symbolicate stack traces

Created on 26 Sep 2019  路  4Comments  路  Source: facebook/hermes

Several bug reports have unsymbolicated stack traces, and it appears that ndk-stack is unable to correctly symbolicate them given the binary releases posted on GitHub and NPM.

This could be due to the published libraries missing debugging info, or simply user error in which case the process should be better documented.

This task requires no Hermes-specific knowledge so it would be a good starter task for anyone interested in helping ensure that bugs are more easily diagnosed and fixed in the future.

good first issue help wanted

Most helpful comment

@safaiyeh thanks for your interest in helping here!

First, Android documents ndk-stack https://developer.android.com/ndk/guides/ndk-stack#usage like this:

To use ndk-stack, you first need a directory containing unstripped versions of your app's shared libraries. If you use ndk-build, these unstripped shared libraries are found in $PROJECT_PATH/obj/local/, where is your device's ABI.

So to make this work, you'll need to find out where the Hermes build puts the unstripped shared libraries. Hermes uses CMake, not ndk-build, so you'll need to figure out where that puts the libraries you need.

Then, you'll need to automate this in the Hermes build. https://github.com/facebook/hermes/blob/master/android/hermes/build.gradle is the build script which builds the libraries, and https://github.com/facebook/hermes/blob/master/doc/ReactNativeIntegration.md documents the process. I think you will mainly want to add stuff to https://github.com/facebook/hermes/blob/master/android/build.gradle which packages up and copies the necessary files into a new tarball file which can be uploaded to GitHub alongside the stripped libraries used to build RN applications.

The test will be to cause a crash in Hermes (by adding bad code), then showing that ndk-stack can produce a symbolicated stack which shows where in the Hermes C++ source the failure occurred. This process should work for a developers who builds from a particular npm version, without compiling Hermes themselves.

All 4 comments

Hi @willholen I would love to investigate this. What is the best way for me to start to understand this?

@safaiyeh thanks for your interest in helping here!

First, Android documents ndk-stack https://developer.android.com/ndk/guides/ndk-stack#usage like this:

To use ndk-stack, you first need a directory containing unstripped versions of your app's shared libraries. If you use ndk-build, these unstripped shared libraries are found in $PROJECT_PATH/obj/local/, where is your device's ABI.

So to make this work, you'll need to find out where the Hermes build puts the unstripped shared libraries. Hermes uses CMake, not ndk-build, so you'll need to figure out where that puts the libraries you need.

Then, you'll need to automate this in the Hermes build. https://github.com/facebook/hermes/blob/master/android/hermes/build.gradle is the build script which builds the libraries, and https://github.com/facebook/hermes/blob/master/doc/ReactNativeIntegration.md documents the process. I think you will mainly want to add stuff to https://github.com/facebook/hermes/blob/master/android/build.gradle which packages up and copies the necessary files into a new tarball file which can be uploaded to GitHub alongside the stripped libraries used to build RN applications.

The test will be to cause a crash in Hermes (by adding bad code), then showing that ndk-stack can produce a symbolicated stack which shows where in the Hermes C++ source the failure occurred. This process should work for a developers who builds from a particular npm version, without compiling Hermes themselves.

Just to reinforce the connection with issue #26, I'll quote @dulinriley at https://github.com/facebook/hermes/issues/26#issuecomment-622552948:

Unfortunately we don't have a good way (yet) to symbolicate our crashes in native code without building Hermes from source.

We have an open issue for figuring out how to make that work: #119.
Once we have that issue fixed, and we can get a symbolicated stack trace for each crash,
we have a better chance of diagnosing these.

This would be awesome for debugging, and would lead me (and others) to enable Hermes for the first time! 馃檪

This is done in Hermes v0.5.1 and newer. Instructions are at https://github.com/facebook/hermes/blob/master/doc/ReactNativeIntegration.md#reporting-native-crashes

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Huxpro picture Huxpro  路  4Comments

tsengvn picture tsengvn  路  4Comments

mathiasbynens picture mathiasbynens  路  6Comments

swabbass picture swabbass  路  3Comments

WilliamParks picture WilliamParks  路  3Comments