Fix a bug that can lead to noDuplicate# not working sometimes.
authorSimon Marlow <marlowsd@gmail.com>
Tue, 16 Feb 2010 12:34:11 +0000 (12:34 +0000)
committerSimon Marlow <marlowsd@gmail.com>
Tue, 16 Feb 2010 12:34:11 +0000 (12:34 +0000)
commitc44aaa1087388b0555a6026b11af2433e86136d0
tree2b55e7ab81900c41b2b7f1a270ca6eaeb5532da7
parent3fd25ca4ae2b41c283210112c6e710e8a44804ba
Fix a bug that can lead to noDuplicate# not working sometimes.

The symptom is that under some rare conditions when running in
parallel, an unsafePerformIO or unsafeInterleaveIO computation might
be duplicated, so e.g. lazy I/O might give the wrong answer (the
stream might appear to have duplicate parts or parts missing).

I have a program that demonstrates it -N3 or more, some lazy I/O, and
a lot of shared mutable state.  See the comment with stg_noDuplicatezh
in PrimOps.cmm that explains the problem and the fix.  This took me
about a day to find :-(
rts/PrimOps.cmm