mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-24 14:59:03 +00:00
This change introduces a new deadlock detector for Cosmo's POSIX threads implementation. Error check mutexes will now track a DAG of nested locks and report EDEADLK when a deadlock is theoretically possible. These will occur rarely, but it's important for production hardening your code. You don't even need to change your mutexes to use the POSIX error check mode because `cosmocc -mdbg` will enable error checking on mutexes by default globally. When cycles are found, an error message showing your demangled symbols describing the strongly connected component are printed and then the SIGTRAP is raised, which means you'll also get a backtrace if you're using ShowCrashReports() too. This new error checker is so low-level and so pure that it's able to verify the relationships of every libc runtime lock, including those locks upon which the mutex implementation depends.
29 lines
929 B
C
29 lines
929 B
C
#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGSET_INTERNAL_H_
|
|
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGSET_INTERNAL_H_
|
|
#include "libc/calls/struct/sigset.h"
|
|
#include "libc/mem/alloca.h"
|
|
#include "libc/sysv/consts/sig.h"
|
|
COSMOPOLITAN_C_START_
|
|
|
|
#define BLOCK_SIGNALS \
|
|
do { \
|
|
sigset_t _SigMask; \
|
|
_SigMask = __sig_block()
|
|
|
|
#define ALLOW_SIGNALS \
|
|
__sig_unblock(_SigMask); \
|
|
} \
|
|
while (0)
|
|
|
|
sigset_t __sig_block(void);
|
|
void __sig_unblock(sigset_t);
|
|
int __sys_sigprocmask(int, const uint64_t *, uint64_t *, uint64_t);
|
|
int sys_sigprocmask(int, const sigset_t *, sigset_t *);
|
|
int sys_sigsuspend(const uint64_t *, uint64_t);
|
|
int sys_sigpending(uint64_t *, size_t);
|
|
|
|
const char *_DescribeSigset(char[128], int, const sigset_t *);
|
|
#define DescribeSigset(rc, ss) _DescribeSigset(alloca(128), rc, ss)
|
|
|
|
COSMOPOLITAN_C_END_
|
|
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGSET_INTERNAL_H_ */
|