Missing tsan interceptor for _longjmp on Mac
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
There is an interceptor for `_setjmp` but not `_longjmp`. The causes `_longjmp` to fail to restore the `__tsan_func_entry`/`__tsan_func_exit` stack to its position at `_setjmp` and can eventually result in overflow and internal TSAN crashes.
Discovered when addressing https://github.com/dart-lang/sdk/issues/61536.
```c
#include
__attribute__((noinline))
void foo(jmp_buf* buf) {
_longjmp(*buf, 1);
}
int main() {
jmp_buf buf;
for (int i = 0; i < 10000000; i++) {
if (_setjmp(buf) == 0) {
foo(&buf);
}
}
}
```
This small example crashes with `_setjmp`/`_longjmp`, but works with `setjmp`/`longjmp`.
Contributor guide
Research direction
Start by locating the existing `_setjmp` interceptor and comparing it with the missing `_longjmp` path in the ThreadSanitizer runtime. Build and run the provided C reproducer on Mac, then verify that repeated `_setjmp`/`_longjmp` calls no longer cause stack overflow or an internal ThreadSanitizer crash.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, macos
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100