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

Only set ANR unwind function if the bugsnag-plugin-android-anr.so was loaded successfully #2039

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

* Corrected the behavior when `Bugsnag.startSession` is called when `config.autoTrackSessions=true`, the first automatic session will now be correctly discarded
[#2033](https://github.com/bugsnag/bugsnag-android/pull/2033)
* Avoid a possible crash in the ANR plugin when the native ANR library failed to load.
[#2039](https://github.com/bugsnag/bugsnag-android/pull/2039)

## 6.5.0 (2024-05-15)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,25 @@ internal class AnrPlugin : Plugin {
}

private fun performOneTimeSetup(client: Client) {
libraryLoader.loadLibrary("bugsnag-plugin-android-anr", client) {
val isLoaded = libraryLoader.loadLibrary("bugsnag-plugin-android-anr", client) {
val error = it.errors[0]
error.errorClass = "AnrLinkError"
error.errorMessage = LOAD_ERR_MSG
true
}
@Suppress("UNCHECKED_CAST")
val clz = loadClass("com.bugsnag.android.NdkPlugin") as Class<Plugin>?
if (clz != null) {
val ndkPlugin = client.getPlugin(clz)
if (ndkPlugin != null) {
val method = ndkPlugin.javaClass.getMethod("getSignalUnwindStackFunction")

@Suppress("UNCHECKED_CAST")
val function = method.invoke(ndkPlugin) as Long
setUnwindFunction(function)

if (isLoaded) {
@Suppress("UNCHECKED_CAST")
val clz = loadClass("com.bugsnag.android.NdkPlugin") as Class<Plugin>?
if (clz != null) {
val ndkPlugin = client.getPlugin(clz)
if (ndkPlugin != null) {
val method = ndkPlugin.javaClass.getMethod("getSignalUnwindStackFunction")

@Suppress("UNCHECKED_CAST")
val function = method.invoke(ndkPlugin) as Long
setUnwindFunction(function)
}
}
}
}
Expand Down
Loading