llvm-project
38d79280 - [lldb] Handle SIGINT via the MainLoop signal thread (on POSIX) (#195959)

Commit
3 days ago
[lldb] Handle SIGINT via the MainLoop signal thread (on POSIX) (#195959) The driver's async SIGINT handler called SBDebugger::DispatchInputInterrupt directly. That is not async-signal-safe and can lead to a crash. Register SIGINT with the existing signal-thread MainLoop instead so DispatchInputInterrupt runs in normal thread context. The Windows path is unchanged and keeps the legacy async handler. While DispatchInputInterrupt runs, the callback temporarily installs SIG_DFL so a second Ctrl-C still hard-terminates the process, preserving the escape hatch users rely on when the debugger is unresponsive. Moving SIGINT off the main thread means a Ctrl-C no longer interrupts blocking syscalls there (e.g. a Python REPL waiting on input or sleeping), so Python never observes the queued interrupt and KeyboardInterrupt is not raised. To restore that behavior, after dispatching the interrupt the callback re-raises SIGINT on the main thread via pthread_kill; the resulting EINTR lets Python pick up the pending interrupt. A skip flag suppresses the re-entry that this self-send produces. Because the callback only ever runs on the signal thread, the flag and the captured main-thread id live in the lambda's captures and need no synchronization. rdar://158218595
Author
Parents
Loading