3 ms·
>There is very little you can safely do in a signal handler You can actually do pretty much anything you want, it's just the C library that uses a lot of globa
by PhilipRoman 3y ago
>There is very little you can safely do in a signal handler
You can actually do pretty much anything you want, it's just the C library that uses a lot of global state and internal memory allocations, which messes things up. The core syscall API and any reentrant code you write yourself are not affected.
>The memory state that a program receiving a SIGSEGV in is often undefined/garbage
That may be true for arbitrary segfaults caused by bugs, but the JIT has 100% control over what instructions to emit, it is not restricted by ABIs or platform-specific issues, so there is no problem to use SEGV as a signaling mechanism.
- zozbot234 3y agoYou can "do pretty much anything you want" as long as you carefully avoid doing anything non thread-safe (even indirectly) in both the main app and the handler itself? How reassuring!
- dwattttt 3y agoThe HotSpot JVM is already multithreaded, they understand how to write thread-safe code (I'm not sure which JVM(s?) are reported to be impacted, HotSpot was the first I found a result for).