diff options
author | Simon Marlow <marlowsd@gmail.com> | 2008-11-13 15:57:30 +0000 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2008-11-13 15:57:30 +0000 |
commit | 6d31658583b97f84313cc7837a0eaeb4060022a7 (patch) | |
tree | 515b2c9dafccf54aa2ca871827f9c6f97a55b4d0 /rts/Schedule.h | |
parent | 424e0afadc8ed00f96330d869b774acde2865c37 (diff) | |
download | haskell-6d31658583b97f84313cc7837a0eaeb4060022a7.tar.gz |
Fix an extremely subtle deadlock bug on x86_64
The recent_activity flag was an unsigned int, but we sometimes do a
64-bit xchg() on it, which overwrites the next word in memory. This
happened to contain the sched_state flag, which is used to control the
orderly shutdown of the system. If the xchg() happened during
shutdown, the scheduler would get confused and deadlock. Don't you
just love C?
Diffstat (limited to 'rts/Schedule.h')
-rw-r--r-- | rts/Schedule.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/rts/Schedule.h b/rts/Schedule.h index d76f42b3af..c3334e6f69 100644 --- a/rts/Schedule.h +++ b/rts/Schedule.h @@ -97,7 +97,7 @@ void initThread(StgTSO *tso, nat stack_size); #define SCHED_INTERRUPTING 1 /* ^C detected, before threads are deleted */ #define SCHED_SHUTTING_DOWN 2 /* final shutdown */ -extern rtsBool RTS_VAR(sched_state); +extern volatile StgWord RTS_VAR(sched_state); /* * flag that tracks whether we have done any execution in this time slice. @@ -113,7 +113,7 @@ extern rtsBool RTS_VAR(sched_state); * INACTIVE to DONE_GC happens under sched_mutex. No lock required * to set it to ACTIVITY_YES. */ -extern nat recent_activity; +extern volatile StgWord recent_activity; /* Thread queues. * Locks required : sched_mutex |