-
-
Notifications
You must be signed in to change notification settings - Fork 200
Description
Description
The implementation of sentry__enter_signal_handler in sentry_sync.c has potential issues related to atomicity and race conditions.
The function is implemented as:
void sentry__enter_signal_handler(void)
{
sentry__block_for_signal_handler();
g_signal_handling_thread = sentry__current_thread();
__sync_fetch_and_or(&g_in_signal_handler, 1);
}Issues:
-
Non-atomic entry:
The check-and-set for entering the signal handler is not atomic. Aftersentry__block_for_signal_handler()returns, another thread may also reach this line and set the flags, causing multiple threads to believe they are in the handler. -
Return value ignored:
The return value ofsentry__block_for_signal_handler()is not checked. If the current thread is already the signal-handling thread, the function should probably return early, but it continues, possibly overwritingg_signal_handling_threadand setting the flag again. -
Split flag and thread ID:
Settingg_signal_handling_threadandg_in_signal_handlerhappens in two separate steps, which can lead to inconsistent states in a multithreaded or signal-driven environment.
Metadata
Metadata
Assignees
Labels
Projects
Status