Harden fixST
ClosedPublic

Authored by dfeuer on Jul 9 2018, 1:13 PM.

Details

Summary

Trac Trac #15349 reveals that lazy blackholing can cause trouble for
fixST much like it can for fixIO. Make fixST work just
like fixIO.

Diff Detail

Repository
rGHC Glasgow Haskell Compiler
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
dfeuer created this revision.Jul 9 2018, 1:13 PM

Can you add a test please?

dfeuer updated this revision to Diff 17262.Jul 10 2018, 1:27 PM
  • Fix lazy ST; add tests

Can you add a test please?

Done. Unfortunately, all my attempts to fix lazy ST using noDuplicate# failed the test when compiled with -O0. I wish I understood why, so I could feel more confident that we don't have more troubles lurking in that module. Lazy ST is really subtle. In the mean time, I implemented the lazy ST version using an MVar as well; that seems to work.

dfeuer planned changes to this revision.Jul 10 2018, 2:00 PM

Oh, bleh! I just realized my lazy version is still wrong. It's too strict sometimes, and I think it can also have trouble from the putMVar not actually happening. What a mess....

dfeuer updated this revision to Diff 17265.Jul 10 2018, 3:55 PM
  • Back out lazy ST changes
dfeuer updated this revision to Diff 17266.Jul 10 2018, 3:59 PM
  • Back out lazy ST changes
simonmar accepted this revision.Jul 16 2018, 4:23 AM

I don't think noDuplicate# has any well-defined semantics that we can rely on, so I'm not entirely surprised that you found it difficult to use it to fix Lazy ST.

I presume we're good here for strict ST at least?

This revision is now accepted and ready to land.Jul 16 2018, 4:23 AM
This revision was automatically updated to reflect the committed changes.