mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-30 16:28:30 +00:00
Eliminate cyclic locks in runtime
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.
This commit is contained in:
parent
26c051c297
commit
af7bd80430
141 changed files with 2094 additions and 1601 deletions
|
@ -22,7 +22,6 @@
|
|||
#include "libc/runtime/stack.h"
|
||||
#include "libc/thread/posixthread.internal.h"
|
||||
#include "libc/thread/tls.h"
|
||||
#include "libc/thread/tls2.internal.h"
|
||||
|
||||
/**
|
||||
* Computes safer buffer size for alloca().
|
||||
|
@ -32,7 +31,7 @@
|
|||
* @return number of bytes to use for your buffer, or negative if the
|
||||
* allocation would likely cause a stack overflow
|
||||
*/
|
||||
privileged long __get_safe_size(long want, long extraspace) {
|
||||
privileged optimizesize long __get_safe_size(long want, long extraspace) {
|
||||
if (!__tls_enabled)
|
||||
return want;
|
||||
struct PosixThread *pt;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue