diff options
author | Samuel Bronson <naesten@gmail.com> | 2012-01-14 01:04:23 -0500 |
---|---|---|
committer | Samuel Bronson <naesten@gmail.com> | 2012-01-14 01:05:30 -0500 |
commit | 9fc1a7967e2a4559b3c54456794d0a8ab12c25cc (patch) | |
tree | ed69112a18a17b50689b051b73de2854d21b8fe3 /crawl-ref/source/crash.cc | |
parent | d4cdc3176b9bbed712ec03b41d7f816a617bfe29 (diff) | |
download | crawl-ref-9fc1a7967e2a4559b3c54456794d0a8ab12c25cc.tar.gz crawl-ref-9fc1a7967e2a4559b3c54456794d0a8ab12c25cc.zip |
Point out that the mutex usage in _crash_signal_handler() could cause UB.
Diffstat (limited to 'crawl-ref/source/crash.cc')
-rw-r--r-- | crawl-ref/source/crash.cc | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/crawl-ref/source/crash.cc b/crawl-ref/source/crash.cc index 9fddfeffbe..33df239171 100644 --- a/crawl-ref/source/crash.cc +++ b/crawl-ref/source/crash.cc @@ -78,12 +78,17 @@ static mutex_t crash_mutex; static void _crash_signal_handler(int sig_num) { - // We rely on mutexes ignoring locks held by the same process, on some - // platforms this must be explicitely enabled (and we do so). + // We rely on mutexes ignoring locks held by the same thread. + // On some platforms, this must be explicitely enabled (which we do). // This mutex is never unlocked again -- the first thread to crash will // do a dump then terminate the process while everyone else waits here // forever. + + // XXX: This is a bit dangerous: if we catch a signal while any + // non-asynch-signal-safe function is executing, and then call + // pthread_mutex_lock() (which is also not asynch-signal-safe), + // the behaviour is undefined. mutex_lock(crash_mutex); if (crawl_state.game_crashed) |