So I am trying to understand if I am missing anything about calling futex_wait inside a signal handler for a SIGSEGV access violation. Ostensibly, it is not on the list of async-signal-safe calls, however with the assumption that I do not cause a deadlock by the signal being called on the thread that would have called futex_wake, I do not see how there could be any issues/corruption or deadlocks.
Specifically, For my use case I am trying to pause all process memory accesses in a region via mprotect()/ signal-handler pattern. During the 'paused' period I am snapshotting the segments of process memory for distributed shared memory type system.
FYI, I am trying to avoid userfaultfd, due to not being supported by some container/VM runtimes.
My thought process is that this should be safe:
- A handler for SIGSEGV will be synchronous, and run in the thread that caused the segfault.
- I can also pretty strongly guarantee that the thread controlling the access permissions, and is expected to call futex wake, will not itself segfault.
Am I missing something about my understanding of the futex_wait/wake logic?