From 246dd9d59237c3d65144353f77616916e98c0f02 Mon Sep 17 00:00:00 2001 From: Edsko de Vries Date: Tue, 7 Nov 2023 10:38:16 +0100 Subject: [PATCH] Document bug and how to reproduce it --- STMBUG.md | 17 +++++++++++++++++ src/Network/GRPC/Util/Concurrency.hs | 3 +++ 2 files changed, 20 insertions(+) create mode 100644 STMBUG.md diff --git a/STMBUG.md b/STMBUG.md new file mode 100644 index 00000000..7ff8e52a --- /dev/null +++ b/STMBUG.md @@ -0,0 +1,17 @@ +This version of the branch demonstrates the STM bug. + +To reproduce, remove the workaround from `Network.GRPC.Util.Concurrency` by defining + +```haskell +atomically :: forall a. STM a -> IO a +atomically = STM.atomically +``` + +and then run with + +``` +while (cabal run test-grapesy -- -p earlyTermination3 2>log); do date; done +``` + +You should hit the "blocked indefinitely" very quickly (usually already on the +first run). diff --git a/src/Network/GRPC/Util/Concurrency.hs b/src/Network/GRPC/Util/Concurrency.hs index 55ab1505..981f3729 100644 --- a/src/Network/GRPC/Util/Concurrency.hs +++ b/src/Network/GRPC/Util/Concurrency.hs @@ -82,6 +82,8 @@ wrapThreadBody body = body -- TODO: Fix this properly. -- TODO: Is 1 guarded attempt enough..? Do we need more..? Unlimited..? atomically :: forall a. STM a -> IO a +atomically = STM.atomically +{- atomically stm = go 1 where go :: @@ -92,3 +94,4 @@ atomically stm = go 1 run :: IO a run = STM.atomically stm +-} \ No newline at end of file