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

Android + Sentry Native - Section Crashed is not in Loaded Images #483

Closed
2 of 3 tasks
deathlyrage opened this issue Feb 20, 2021 · 15 comments
Closed
2 of 3 tasks

Android + Sentry Native - Section Crashed is not in Loaded Images #483

deathlyrage opened this issue Feb 20, 2021 · 15 comments

Comments

@deathlyrage
Copy link

deathlyrage commented Feb 20, 2021

Description

image

image

When does the problem happen

  • During build
  • During run-time
  • When capturing a hard crash

Environment

Using the pre-built package from sentry-java which uses sentry-native.

Steps To Reproduce

Not sure how to reproduce this one, but i'd say 50% of my crashes experience this issue, other crashes do have libUE4.so loaded.
It might have something to do with my libUE4.so symbol size, (its around 1.8 GB)

Log output

Here is a link to the event on Sentry SAAS if that helps:

https://sentry.io/share/issue/d6ecd48de5bf43db9990a56c42a6807b/

I upload full symbol files and source maps, I'm not sure why sentry can't identify the right loaded symbol and give additional context, eg like line numbers or source code information about the crash.

@Swatinem
Copy link
Member

One known limitation that we have is that we can’t find the loaded images correctly if they are being loaded directly from .apk files. You have to instruct android to properly extract them to disk. The docs give examples of how to achieve this:

https://docs.sentry.io/platforms/android/usage/advanced-usage/#integrating-the-ndk

In particular, the extractNativeLibs and enableUncompressedNativeLibs options need to be set appropriately.

CC @marandaneto

Using the pre-built package from sentry-java which uses sentry-native.

In that case please open an issue in the sentry-java repo next time.

@Swatinem
Copy link
Member

Another common source of missing loaded images is if you have loaded the library dynamically.
In that case, you might need to flush sentries internal cache that it has:

/**
* Clears the internal module cache.
*
* For performance reasons, sentry will cache the list of loaded libraries when
* capturing events. This cache can get out-of-date when loading or unloading
* libraries at runtime. It is therefore recommended to call
* `sentry_clear_modulecache` when doing so, to make sure that the next call to
* `sentry_capture_event` will have an up-to-date module list.
*/
SENTRY_EXPERIMENTAL_API void sentry_clear_modulecache(void);

Unfortunately that is something that needs to be done manually right now.

@marandaneto
Copy link
Contributor

related to getsentry/sentry-java#1280 so people won't need to set extractNativeLibs manually.

@deathlyrage
Copy link
Author

Another common source of missing loaded images is if you have loaded the library dynamically.
In that case, you might need to flush sentries internal cache that it has:

/**
* Clears the internal module cache.
*
* For performance reasons, sentry will cache the list of loaded libraries when
* capturing events. This cache can get out-of-date when loading or unloading
* libraries at runtime. It is therefore recommended to call
* `sentry_clear_modulecache` when doing so, to make sure that the next call to
* `sentry_capture_event` will have an up-to-date module list.
*/
SENTRY_EXPERIMENTAL_API void sentry_clear_modulecache(void);

Unfortunately that is something that needs to be done manually right now.

What's the best way to call this from java? I have tried calling it from native but it doesn't carry over. Should I ask on the getsentry/sentry-java issue tracker instead?

@marandaneto
Copy link
Contributor

@deathlyrage

but it doesn't carry over.

I don't follow this sentence, what do you mean?

you could call directly from native or you could create a JNI bridge, both would work in the same way

@deathlyrage
Copy link
Author

deathlyrage commented Mar 4, 2021

Yeah just attempting to call:

#if PLATFORM_ANDROID
	sentry_clear_modulecache();
#endif

Didn't properly clear the module cache for future reports. However my sentry_init() call is done in java, so i'm not sure how thats supposed to work. I'v got no idea how to call sentry_clear_modulecache(); in the java version of the SDK, but it looks burried between interface hell. If anyone has a code example of calling it would be lovely.

Java_io_sentry_android_ndk_NativeModuleListLoader_nativeClearModuleList(JNIEnv *env, jclass cls) {

I can see its called here but im not sure what the write syntax is to access this one?

@marandaneto
Copy link
Contributor

marandaneto commented Mar 4, 2021

you need to init. the SDK using the manual mode.
https://docs.sentry.io/platforms/android/usage/advanced-usage/#manual-initialization

SentryAndroid.init(this, options -> {
// cache this loader to be access outside of this lambda
val loader = options.getDebugImagesLoader()
}

call loader.clearModuleList() when you want

@deathlyrage
Copy link
Author

Managed to get it working thanks!

@Swatinem
Copy link
Member

Managed to get it working thanks!

@deathlyrage Was it just about calling sentry_clear_modulecache or what else did you do here?

I would like to understand this better, since this is one of the most frequent annoyances that Android customers are facing.

@deathlyrage
Copy link
Author

deathlyrage commented Mar 12, 2021

Managed to get it working thanks!

@deathlyrage Was it just about calling sentry_clear_modulecache or what else did you do here?

I would like to understand this better, since this is one of the most frequent annoyances that Android customers are facing.

This managed to solve the problem with sentry_clear_modulecache. Just attempting to move to Native + Android + Breakpad without java NDK version of it so i can get more crash information and minidumps.

#496

@deathlyrage
Copy link
Author

Nevermind looks like I spoke too soon, its still broken with sentry_clear_modulecache.

https://sentry.io/share/issue/be797880554f45f29251688e6a4f3e18/

@deathlyrage deathlyrage reopened this Mar 13, 2021
@deathlyrage
Copy link
Author

deathlyrage commented Mar 13, 2021

It looks like it exclusively happens on Android 11 devices? Older android versions correctly show the right loaded symbols.

@Swatinem
Copy link
Member

We do know that the module finder is not really reliable in some cases, though its a pain to make that work even as it is.

@Swatinem
Copy link
Member

@deathlyrage I have been looking at this again, and it seems that in the event you sent (https://sentry.io/share/issue/be797880554f45f29251688e6a4f3e18/), libUE4.so is loaded directly from the apk (just hove the filename in the stacktrace).

I recently landed #431 which should support this usecase.

@Swatinem
Copy link
Member

Closing this for now, as it should be fixed by the new modulefinder. Still working on releasing and uplifting the new version to the Android SDK though.

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

No branches or pull requests

3 participants