summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/crash.cc
diff options
context:
space:
mode:
authorSamuel Bronson <naesten@gmail.com>2012-01-14 01:04:23 -0500
committerSamuel Bronson <naesten@gmail.com>2012-01-14 01:05:30 -0500
commit9fc1a7967e2a4559b3c54456794d0a8ab12c25cc (patch)
treeed69112a18a17b50689b051b73de2854d21b8fe3 /crawl-ref/source/crash.cc
parentd4cdc3176b9bbed712ec03b41d7f816a617bfe29 (diff)
downloadcrawl-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.cc9
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)