Skip to content

Commit

Permalink
Merge a9509c5 into b3cba2b
Browse files Browse the repository at this point in the history
  • Loading branch information
kattrali committed Oct 19, 2018
2 parents b3cba2b + a9509c5 commit 11c36fe
Show file tree
Hide file tree
Showing 44 changed files with 186 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## TBD

### Bug fixes

* [NDK] Improve stack trace quality for signals raised on ARM32 devices
[#378](https://github.com/bugsnag/bugsnag-android/pull/378)

## 4.8.2 (2018-10-01)

### Bug fixes
Expand Down
6 changes: 6 additions & 0 deletions features/fixtures/mazerunner/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ set_target_properties(lib_bugsnag PROPERTIES IMPORTED_LOCATION
${BUGSNAG_LIB_DIR}/jni/${ANDROID_ABI}/libbugsnag-ndk.so)
target_include_directories(entrypoint PRIVATE ${BUGSNAG_INCLUDE_DIR})
target_link_libraries(entrypoint lib_bugsnag)

add_library(lib_monochrome SHARED IMPORTED)
set_target_properties(lib_monochrome PROPERTIES IMPORTED_LOCATION
${CMAKE_SOURCE_DIR}/libs/${ANDROID_ABI}/libmonochrome.so)
target_link_libraries(entrypoint lib_monochrome)

5 changes: 5 additions & 0 deletions features/fixtures/mazerunner/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ android {
path 'CMakeLists.txt'
}
}
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}
}

dependencies {
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
16 changes: 16 additions & 0 deletions features/fixtures/mazerunner/src/main/cpp/entrypoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,22 @@ Java_com_bugsnag_android_mazerunner_scenarios_CXXDivideByZeroScenario_crash(JNIE
printf("This one here: %ld\n", (long) crash_floating_point(counter));
}

// defined in libs/[ABI]/libmonochrome.so
int something_innocuous(int input);

JNIEXPORT int JNICALL
Java_com_bugsnag_android_mazerunner_scenarios_CXXExternalStackElementScenario_crash(JNIEnv *env,
jobject instance,
jint counter) {
printf("Captain, why are we out here chasing comets?\n%d\n", counter);
int value = counter * 4;
if (counter > 0) {
value = something_innocuous(counter);
}
printf("Something innocuous this way comes: %d\n", value);
return value;
}

JNIEXPORT void JNICALL
Java_com_bugsnag_android_mazerunner_scenarios_CXXAbortScenario_crash(JNIEnv *env,
jobject instance) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class CXXAbortScenario extends Scenario {

static {
System.loadLibrary("bugsnag-ndk");
System.loadLibrary("monochrome");
System.loadLibrary("entrypoint");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class CXXAutoContextScenario extends Scenario {

static {
System.loadLibrary("bugsnag-ndk");
System.loadLibrary("monochrome");
System.loadLibrary("entrypoint");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
public class CXXBreadcrumbScenario extends Scenario {
static {
System.loadLibrary("bugsnag-ndk");
System.loadLibrary("monochrome");
System.loadLibrary("entrypoint");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
public class CXXCustomMetadataNativeCrashScenario extends Scenario {
static {
System.loadLibrary("bugsnag-ndk");
System.loadLibrary("monochrome");
System.loadLibrary("entrypoint");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
public class CXXCustomMetadataNativeNotifyScenario extends Scenario {
static {
System.loadLibrary("bugsnag-ndk");
System.loadLibrary("monochrome");
System.loadLibrary("entrypoint");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
public class CXXDelayedCrashScenario extends Scenario {
static {
System.loadLibrary("bugsnag-ndk");
System.loadLibrary("monochrome");
System.loadLibrary("entrypoint");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
public class CXXDelayedNotifyScenario extends Scenario {
static {
System.loadLibrary("bugsnag-ndk");
System.loadLibrary("monochrome");
System.loadLibrary("entrypoint");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
public class CXXDivideByZeroScenario extends Scenario {
static {
System.loadLibrary("bugsnag-ndk");
System.loadLibrary("monochrome");
System.loadLibrary("entrypoint");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class CXXDoubleFreeScenario extends Scenario {

static {
System.loadLibrary("bugsnag-ndk");
System.loadLibrary("monochrome");
System.loadLibrary("entrypoint");
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.bugsnag.android.mazerunner.scenarios;

import android.content.Context;

import com.bugsnag.android.Configuration;

import android.support.annotation.NonNull;

public class CXXExternalStackElementScenario extends Scenario {
static {
System.loadLibrary("bugsnag-ndk");
System.loadLibrary("monochrome");
System.loadLibrary("entrypoint");
}

public native void crash(int counter);

public CXXExternalStackElementScenario(@NonNull Configuration config, @NonNull Context context) {
super(config, context);
config.setAutoCaptureSessions(false);
}

@Override
public void run() {
super.run();
String metadata = getEventMetaData();
if (metadata != null && metadata.equals("non-crashy")) {
return;
}
crash(34);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
public class CXXExtraordinaryLongStringScenario extends Scenario {
static {
System.loadLibrary("bugsnag-ndk");
System.loadLibrary("monochrome");
System.loadLibrary("entrypoint");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class CXXImproperTypecastScenario extends Scenario {

static {
System.loadLibrary("bugsnag-ndk");
System.loadLibrary("monochrome");
System.loadLibrary("entrypoint");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
public class CXXJavaBreadcrumbNativeBreadcrumbScenario extends Scenario {
static {
System.loadLibrary("bugsnag-ndk");
System.loadLibrary("monochrome");
System.loadLibrary("entrypoint");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
public class CXXJavaBreadcrumbNativeCrashScenario extends Scenario {
static {
System.loadLibrary("bugsnag-ndk");
System.loadLibrary("monochrome");
System.loadLibrary("entrypoint");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
public class CXXJavaBreadcrumbNativeNotifyScenario extends Scenario {
static {
System.loadLibrary("bugsnag-ndk");
System.loadLibrary("monochrome");
System.loadLibrary("entrypoint");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
public class CXXJavaUserInfoNativeCrashScenario extends Scenario {
static {
System.loadLibrary("bugsnag-ndk");
System.loadLibrary("monochrome");
System.loadLibrary("entrypoint");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
public class CXXNativeBreadcrumbJavaCrashScenario extends Scenario {
static {
System.loadLibrary("bugsnag-ndk");
System.loadLibrary("monochrome");
System.loadLibrary("entrypoint");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
public class CXXNativeBreadcrumbJavaNotifyScenario extends Scenario {
static {
System.loadLibrary("bugsnag-ndk");
System.loadLibrary("monochrome");
System.loadLibrary("entrypoint");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
public class CXXNativeBreadcrumbNativeCrashScenario extends Scenario {
static {
System.loadLibrary("bugsnag-ndk");
System.loadLibrary("monochrome");
System.loadLibrary("entrypoint");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
public class CXXNotifyScenario extends Scenario {
static {
System.loadLibrary("bugsnag-ndk");
System.loadLibrary("monochrome");
System.loadLibrary("entrypoint");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class CXXNullPointerScenario extends Scenario {

static {
System.loadLibrary("bugsnag-ndk");
System.loadLibrary("monochrome");
System.loadLibrary("entrypoint");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class CXXSessionInfoCrashScenario extends Scenario {

static {
System.loadLibrary("bugsnag-ndk");
System.loadLibrary("monochrome");
System.loadLibrary("entrypoint");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class CXXSigabrtScenario extends Scenario {

static {
System.loadLibrary("bugsnag-ndk");
System.loadLibrary("monochrome");
System.loadLibrary("entrypoint");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class CXXSigbusScenario extends Scenario {

static {
System.loadLibrary("bugsnag-ndk");
System.loadLibrary("monochrome");
System.loadLibrary("entrypoint");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class CXXSigfpeScenario extends Scenario {

static {
System.loadLibrary("bugsnag-ndk");
System.loadLibrary("monochrome");
System.loadLibrary("entrypoint");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class CXXSigillScenario extends Scenario {

static {
System.loadLibrary("bugsnag-ndk");
System.loadLibrary("monochrome");
System.loadLibrary("entrypoint");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class CXXSigsegvScenario extends Scenario {

static {
System.loadLibrary("bugsnag-ndk");
System.loadLibrary("monochrome");
System.loadLibrary("entrypoint");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class CXXSigtrapScenario extends Scenario {

static {
System.loadLibrary("bugsnag-ndk");
System.loadLibrary("monochrome");
System.loadLibrary("entrypoint");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class CXXStackoverflowScenario extends Scenario {

static {
System.loadLibrary("bugsnag-ndk");
System.loadLibrary("monochrome");
System.loadLibrary("entrypoint");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class CXXTrapScenario extends Scenario {

static {
System.loadLibrary("bugsnag-ndk");
System.loadLibrary("monochrome");
System.loadLibrary("entrypoint");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class CXXUpdateContextCrashScenario extends Scenario {

static {
System.loadLibrary("bugsnag-ndk");
System.loadLibrary("monochrome");
System.loadLibrary("entrypoint");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
public class CXXUserInfoScenario extends Scenario {
static {
System.loadLibrary("bugsnag-ndk");
System.loadLibrary("monochrome");
System.loadLibrary("entrypoint");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class CXXWriteReadOnlyMemoryScenario extends Scenario {

static {
System.loadLibrary("bugsnag-ndk");
System.loadLibrary("monochrome");
System.loadLibrary("entrypoint");
}

Expand Down
18 changes: 18 additions & 0 deletions features/native_crash_handling.feature
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,21 @@ Feature: Native crash reporting
And the event "severity" equals "error"
And the event "unhandled" is true

Scenario: Causing a crash in a separate library
When I run "CXXExternalStackElementScenario"
And I configure the app to run in the "non-crashy" state
And I relaunch the app
Then I should receive a request
And the request payload contains a completed native report
And the event "severity" equals "error"
And the event "unhandled" is true
And the exception "errorClass" equals one of:
| SIGILL |
| SIGTRAP |
And the exception "message" equals one of:
| Illegal instruction |
| Trace/breakpoint trap |
And the exception "type" equals "c"
And the first significant stack frame methods and files should match:
| something_innocuous | libmonochrome.so |
| Java_com_bugsnag_android_mazerunner_scenarios_CXXExternalStackElementScenario_crash | libentrypoint.so |
15 changes: 15 additions & 0 deletions features/steps/build_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,21 @@
value = read_key_path(find_request(0)[:body], "events.0.exceptions.0.#{keypath}")
assert_includes(possible_values.raw.flatten, value)
end
Then("the first significant stack frame methods and files should match:") do |expected_values|
stacktrace = read_key_path(find_request(0)[:body], "events.0.exceptions.0.stacktrace")
expected_frame_values = expected_values.raw
expected_index = 0
stacktrace.each_with_index do |item, index|
next if expected_index >= expected_frame_values.length
expected_frame = expected_frame_values[expected_index]
next if item["method"].start_with? "bsg_"
next if item["file"].start_with? "/system/"

assert_equal(expected_frame[0], item["method"])
assert(item["file"].end_with?(expected_frame[1]), "'#{item["file"]}' in frame #{index} does not end with '#{expected_frame[1]}'")
expected_index += 1
end
end

Then("the report in request {int} contains the required fields") do |index|
steps %Q{
Expand Down

0 comments on commit 11c36fe

Please sign in to comment.