Skip to content
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

- Add `sentry_scope_remove_fingerprint` to remove a fingerprint set on a scope, matching the global `sentry_remove_fingerprint`. ([#1932](https://github.com/getsentry/sentry-native/pull/1932))

**Fixes**:

- Crashpad: fix a crash when calling `sentry_init` before C++ dynamic initializers have run. ([#1930](https://github.com/getsentry/sentry-native/issues/1930), [mini_chromium#8](https://github.com/getsentry/mini_chromium/pull/8))

## 0.16.1

**Features**:
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,7 @@ endif()
if(SENTRY_BUILD_TESTS)
add_subdirectory(tests/unit)
add_subdirectory(tests/fixtures/crash_reporter)
add_subdirectory(tests/fixtures/early_init)
add_subdirectory(tests/fixtures/screenshot)
if(WIN32 AND NOT XBOX)
add_subdirectory(tests/fixtures/appx)
Expand Down
2 changes: 1 addition & 1 deletion external/crashpad
1 change: 1 addition & 0 deletions tests/cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def destroy(self):
"sentry_test_unit",
"libsentry.dylib" if sys.platform == "darwin" else "libsentry.so",
"sentry-crash",
"sentry_early_init",
]
cmd = [
os.environ.get("LLVM_COV", "llvm-cov"),
Expand Down
5 changes: 5 additions & 0 deletions tests/fixtures/early_init/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cmake_minimum_required(VERSION 3.10)
project(sentry_early_init LANGUAGES CXX)

add_executable(sentry_early_init early_init.cpp)
target_link_libraries(sentry_early_init PRIVATE sentry)
28 changes: 28 additions & 0 deletions tests/fixtures/early_init/early_init.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <sentry.h>

static int
do_early_init()
{
sentry_options_t *options = sentry_options_new();
sentry_options_set_debug(options, true);
return sentry_init(options);
}

struct EarlyInit {
int result = do_early_init();
};

#if defined(_MSC_VER)
// call sentry_init() as early as possible, before other static initializers
# pragma init_seg(lib)
#elif defined(__GNUC__) || defined(__clang__)
__attribute__((init_priority(101)))
#endif
Comment thread
jpnurmi marked this conversation as resolved.
static EarlyInit early_init;

int
main()
{
sentry_close();
return early_init.result;
}
18 changes: 18 additions & 0 deletions tests/test_integration_crashpad.py
Original file line number Diff line number Diff line change
Expand Up @@ -1134,3 +1134,21 @@ def test_crashpad_restart_on_crash(cmake, httpserver):
assert len(httpserver.log) == 2
for req in httpserver.log:
assert_crashpad_upload(req[0])


def test_crashpad_early_init(cmake):
tmp_path = cmake(
["sentry_early_init"],
{
"SENTRY_BACKEND": "crashpad",
"SENTRY_TRANSPORT": "none",
"BUILD_SHARED_LIBS": "OFF",
},
)

result = run(
tmp_path,
"sentry_early_init",
[],
)
assert result.returncode == 0
Comment thread
cursor[bot] marked this conversation as resolved.
26 changes: 26 additions & 0 deletions tests/test_integration_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -1431,3 +1431,29 @@ def test_restart_on_crash(cmake, httpserver, backend):
assert_breakpad_crash(envelope)
else:
assert False


@pytest.mark.parametrize(
"backend",
[
"inproc",
pytest.param(
"breakpad",
marks=pytest.mark.skipif(
not has_breakpad, reason="breakpad backend not available"
),
),
],
)
def test_early_init(cmake, backend):
tmp_path = cmake(
["sentry_early_init"],
{
"SENTRY_BACKEND": backend,
"SENTRY_TRANSPORT": "none",
"BUILD_SHARED_LIBS": "OFF",
},
)

result = run(tmp_path, "sentry_early_init", [])
assert result.returncode == 0
18 changes: 18 additions & 0 deletions tests/test_integration_native.py
Original file line number Diff line number Diff line change
Expand Up @@ -1193,3 +1193,21 @@ def test_native_replay_orphan_not_flushed(cmake, httpserver):
assert not is_replay_envelope(req.get_data())
assert (replays / f"replay-{REPLAY_ID}.mp4").exists()
assert (replays / f"replay-{REPLAY_ID}.json").exists()


def test_native_early_init(cmake):
tmp_path = cmake(
["sentry_early_init"],
{
"SENTRY_BACKEND": "native",
"SENTRY_TRANSPORT": "none",
"BUILD_SHARED_LIBS": "OFF",
},
)

result = run(
tmp_path,
"sentry_early_init",
[],
)
assert result.returncode == 0
Loading