Skip to content
Open
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
36 changes: 33 additions & 3 deletions tests/test_integration_native.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@
# timeout the native daemon used before it respected the SDK shutdown timeout.
SANITIZER_ARGS = ["shutdown-timeout", "10000"] if is_asan or is_tsan else []

STATUS_STACK_OVERFLOW = 0xC00000FD
STATUS_STACK_BUFFER_OVERRUN = 0xC0000409
STATUS_HEAP_CORRUPTION = 0xC0000374
STATUS_FAIL_FAST_EXCEPTION = 0xC0000602


def test_native_capture_crash(cmake, httpserver):
"""Test basic crash capture with native backend"""
Expand Down Expand Up @@ -75,9 +80,13 @@ def test_native_capture_crash(cmake, httpserver):
@pytest.mark.parametrize(
"crash_arg,exception_code",
[
pytest.param("fastfail", 0xC0000602, id="fastfail"),
pytest.param("heap-corruption", 0xC0000374, id="heap-corruption"),
pytest.param("stack-buffer-overrun", 0xC0000409, id="stack-buffer-overrun"),
pytest.param("fastfail", STATUS_FAIL_FAST_EXCEPTION, id="fastfail"),
pytest.param("heap-corruption", STATUS_HEAP_CORRUPTION, id="heap-corruption"),
pytest.param(
"stack-buffer-overrun",
STATUS_STACK_BUFFER_OVERRUN,
id="stack-buffer-overrun",
),
],
)
def test_native_wer_crash(cmake, httpserver, crash_arg, exception_code):
Expand Down Expand Up @@ -117,6 +126,27 @@ def test_native_oom(cmake, httpserver):
assert waiting.result


def test_native_stack_overflow(cmake, httpserver):
"""Test stack overflow crash capture with native backend"""
tmp_path = cmake(["sentry_example"], {"SENTRY_BACKEND": "native"})

httpserver.expect_oneshot_request("/api/123456/envelope/").respond_with_data("OK")

with httpserver.wait(timeout=10) as waiting:
run_crash(
tmp_path,
"sentry_example",
["log", "stdout", "stack-overflow"] + SANITIZER_ARGS,
env=dict(os.environ, SENTRY_DSN=make_dsn(httpserver)),
)
assert waiting.result

assert len(httpserver.log) >= 1
envelope = Envelope.deserialize(httpserver.log[0][0].get_data())
exception_code = STATUS_STACK_OVERFLOW if sys.platform == "win32" else None
assert_native_crash(envelope, exception_code=exception_code)


def test_native_capture_minidump_generated(cmake, httpserver):
"""Test that minidump file is generated"""
tmp_path = cmake(["sentry_example"], {"SENTRY_BACKEND": "native"})
Expand Down
Loading