Fix deadlock bug when mkFastStringWith is duplicated

Authored by watashi on Nov 18 2018, 12:09 AM.



In D5211: Rewrite FastString table in concurrent hashtable, we use withMVar to guard writes to the same segment,
this is unsafe to be duplicated. It can lead to deadlock if it is only run
partially and putMVar is not called after takeMVar.

Test Plan

We used to see deadlock when building stackage without this fix, and it
no longer happens.

Diff Detail

rGHC Glasgow Haskell Compiler
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.
watashi created this revision.Nov 18 2018, 12:09 AM
simonmar accepted this revision.Nov 19 2018, 2:55 AM


I think this is a general problem with unsafeDupablePerformIO that we can't do bracket-type things inside it. I'm thinking about possible solutions.

This revision is now accepted and ready to land.Nov 19 2018, 2:55 AM
This revision was automatically updated to reflect the committed changes.