Skip to content

Commit 61f98ee

Browse files
committed
Merge remote-tracking branch 'upstream/master' into jpnurmi/fix/sa-nodefer-chain-at-start
2 parents ef5b4f1 + d46426b commit 61f98ee

7 files changed

Lines changed: 25 additions & 18 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
**Fixes**:
66

7+
- inproc: only the handling thread cleans up after the crash. ([#1579](https://github.com/getsentry/sentry-native/pull/1579))
78
- Fix `CHAIN_AT_START` handler strategy crashing on Android when the chained Mono handler resets the signal handler and re-raises. ([#1572](https://github.com/getsentry/sentry-native/pull/1572))
89

910
## 0.13.2

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,17 @@ setup-git: $(GIT_COMMON_DIR)/hooks/pre-commit
6060
git submodule update --init --recursive
6161
.PHONY: setup-git
6262

63-
setup-venv: .venv/bin/python
63+
setup-venv: .venv/.stamp
6464
.PHONY: setup-venv
6565

6666
$(GIT_COMMON_DIR)/hooks/pre-commit:
6767
@cd $(GIT_COMMON_DIR)/hooks && ln -sf $(PWD)/scripts/git-precommit-hook.sh pre-commit
6868

69-
.venv/bin/python: Makefile tests/requirements.txt
69+
.venv/.stamp: Makefile tests/requirements.txt
7070
@rm -rf .venv
7171
python3 -m venv .venv
7272
.venv/bin/pip install --upgrade --requirement tests/requirements.txt
73+
@touch $@
7374

7475
format: setup-venv
7576
@.venv/bin/clang-format -i \

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,8 @@ The SDK currently supports and is tested on the following OS/Compiler variations
6666
- x64 Linux with GCC 9
6767
- x64/arm64 Linux with clang 19
6868
- x86 Linux with GCC 9 (cross compiled from x64 host)
69-
- x86 Windows with MSVC 2019
70-
- x64 Windows with MSVC 2022
71-
- macOS 13, 14, 15 with respective most recent Apple compiler toolchain and LLVM clang 15 + 18
69+
- x86, x64 and arm64 Windows with MSVC 2022
70+
- macOS 13, 14, 15, 26 with respective most recent Apple compiler toolchain and LLVM clang 15 + 18
7271
- Android API35 built by NDK27 toolchain
7372
- Android API16 built by NDK19 toolchain
7473
- PlayStation via [sentry-playstation](https://github.com/getsentry/sentry-playstation). See [PlayStation documentation](https://docs.sentry.io/platforms/playstation/) to get access.

src/backends/sentry_backend_inproc.c

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,7 +1354,7 @@ has_handler_thread_crashed(void)
13541354
return false;
13551355
}
13561356

1357-
static void
1357+
static bool
13581358
dispatch_ucontext(const sentry_ucontext_t *uctx,
13591359
const struct signal_slot *sig_slot, int handler_depth)
13601360
{
@@ -1368,7 +1368,7 @@ dispatch_ucontext(const sentry_ucontext_t *uctx,
13681368
// Disable stdio-based logging - not safe in signal handler context.
13691369
sentry__logger_disable();
13701370
process_ucontext_deferred(uctx, sig_slot, skip_hooks);
1371-
return;
1371+
return true;
13721372
#else
13731373
if (has_handler_thread_crashed()) {
13741374
// Disable stdio-based logging since we're now in signal handler context
@@ -1380,7 +1380,7 @@ dispatch_ucontext(const sentry_ucontext_t *uctx,
13801380
// Always skip hooks here since the first attempt (from handler thread)
13811381
// already failed, likely due to a crashing hook.
13821382
process_ucontext_deferred(uctx, sig_slot, true);
1383-
return;
1383+
return true;
13841384
}
13851385

13861386
// Try to become the crash handler. Only one thread can transition
@@ -1401,15 +1401,15 @@ dispatch_ucontext(const sentry_ucontext_t *uctx,
14011401
sentry__cpu_relax();
14021402
}
14031403
// State is now DONE: just return and let the signal propagate
1404-
return;
1404+
return false;
14051405
}
14061406

14071407
// We are the first handler. Check if handler thread is available.
14081408
if (!sentry__atomic_fetch(&g_handler_thread_ready)) {
14091409
// Disable stdio-based logging - not safe in signal handler context.
14101410
sentry__logger_disable();
14111411
process_ucontext_deferred(uctx, sig_slot, skip_hooks);
1412-
return;
1412+
return true;
14131413
}
14141414

14151415
g_handler_state.uctx = *uctx;
@@ -1463,7 +1463,7 @@ dispatch_ucontext(const sentry_ucontext_t *uctx,
14631463
int depth = sentry__enter_signal_handler();
14641464
if (depth >= 3) {
14651465
// Multiple recursive crashes - bail out
1466-
return;
1466+
return true;
14671467
}
14681468
// Disable stdio-based logging - not safe in signal handler context.
14691469
sentry__logger_disable();
@@ -1472,7 +1472,7 @@ dispatch_ucontext(const sentry_ucontext_t *uctx,
14721472
// always 1, which would incorrectly re-run hooks on a recursive
14731473
// crash where the pipe also fails.
14741474
process_ucontext_deferred(uctx, sig_slot, skip_hooks);
1475-
return;
1475+
return true;
14761476
}
14771477
# elif defined(SENTRY_PLATFORM_WINDOWS)
14781478
if (g_handler_semaphore) {
@@ -1489,7 +1489,7 @@ dispatch_ucontext(const sentry_ucontext_t *uctx,
14891489
// Disable stdio-based logging - not safe in signal handler context.
14901490
sentry__logger_disable();
14911491
process_ucontext_deferred(uctx, sig_slot, skip_hooks);
1492-
return;
1492+
return true;
14931493
}
14941494
# endif
14951495

@@ -1519,6 +1519,7 @@ dispatch_ucontext(const sentry_ucontext_t *uctx,
15191519
(void)!sentry__enter_signal_handler();
15201520
# endif
15211521

1522+
return true;
15221523
#endif
15231524
}
15241525

@@ -1661,11 +1662,18 @@ process_ucontext(const sentry_ucontext_t *uctx)
16611662

16621663
// invoke the handler thread for signal unsafe actions
16631664
#ifdef SENTRY_PLATFORM_UNIX
1664-
dispatch_ucontext(uctx, sig_slot, handler_depth);
1665+
bool is_handling_thread = dispatch_ucontext(uctx, sig_slot, handler_depth);
16651666
#else
1666-
dispatch_ucontext(uctx, sig_slot, 1);
1667+
bool is_handling_thread = dispatch_ucontext(uctx, sig_slot, 1);
16671668
#endif
16681669

1670+
// Non-handling threads (that lost the CAS race) should just return.
1671+
// Signal handlers are already reset by the handling thread, so
1672+
// re-executing the crashing instruction will hit the default handler.
1673+
if (!is_handling_thread) {
1674+
return;
1675+
}
1676+
16691677
#ifdef SENTRY_PLATFORM_UNIX
16701678
cleanup:
16711679
// reset signal handlers and invoke the original ones. This will then tear

tests/conftest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from . import run
88
from .cmake import CMake
99

10-
1110
LABEL = "label"
1211
TIME_UNIT = "time_unit"
1312
REAL_TIME = "real_time"

tests/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
black==24.3.0
1+
black==26.3.1
22
pytest==8.1.1
33
pytest-httpserver==1.0.10
44
flaky==3.8.1

tests/test_integration_native.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
)
2323
from .conditions import has_native, is_kcov, is_asan
2424

25-
2625
pytestmark = pytest.mark.skipif(
2726
not has_native,
2827
reason="Tests need the native backend enabled",

0 commit comments

Comments
 (0)