Skip to content

Commit 0dec722

Browse files
committed
Fix a NoThunks failure in unsafeReleaseReadAccess
1 parent aa22af7 commit 0dec722

File tree

2 files changed

+4
-13
lines changed
  • src-control/Control/Concurrent/Class/MonadSTM
  • src-extras/Database/LSMTree/Extras

2 files changed

+4
-13
lines changed

src-control/Control/Concurrent/Class/MonadSTM/RWVar.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ unsafeAcquireWriteAccess rw@(RWVar !var) = do
117117

118118
{-# SPECIALISE unsafeReleaseWriteAccess :: RWVar IO a -> a -> STM IO () #-}
119119
unsafeReleaseWriteAccess :: MonadSTM m => RWVar m a -> a -> STM m ()
120-
unsafeReleaseWriteAccess (RWVar !var) x = do
120+
unsafeReleaseWriteAccess (RWVar !var) !x = do
121121
readTVar var >>= \case
122122
Reading _ _ -> error "releasing a writer without write access (Reading)"
123123
WaitingToWrite _ _ -> error "releasing a writer without write access (WaitingToWrite)"

src-extras/Database/LSMTree/Extras/NoThunks.hs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -548,28 +548,19 @@ instance (NoThunks a, Typeable s, Typeable a) => NoThunks (MutableHeap s a) wher
548548
-- Some constraints, like @NoThunks (MutVar s a)@ and @NoThunks (StrictTVar m
549549
-- a)@, can not be satisfied for arbitrary @m@\/@s@, and must be instantiated
550550
-- for a concrete @m@\/@s@, like @IO@\/@RealWorld@.
551-
class ( forall a. NoThunks a => NoThunks (StrictTVar m a)
551+
class ( forall a. (NoThunks a, Typeable a) => NoThunks (StrictTVar m a)
552552
, forall a. (NoThunks a, Typeable a) => NoThunks (StrictMVar m a)
553553
) => NoThunksIOLike' m s
554554

555555
instance NoThunksIOLike' IO RealWorld
556556

557557
type NoThunksIOLike m = NoThunksIOLike' m (PrimState m)
558558

559-
-- TODO: on ghc-9.4, a check on StrictTVar IO (RWState (TableContent IO h))
560-
-- fails, but we have not yet found out why so we simply disable NoThunks checks
561-
-- for StrictTVars on ghc-9.4
562-
instance NoThunks a => NoThunks (StrictTVar IO a) where
563-
showTypeOf (_ :: Proxy (StrictTVar IO a)) = "StrictTVar IO"
559+
instance (NoThunks a, Typeable a) => NoThunks (StrictTVar IO a) where
560+
showTypeOf (p :: Proxy (StrictTVar IO a)) = show $ typeRep p
564561
wNoThunks _ctx _var = do
565-
#if defined(MIN_VERSION_GLASGOW_HASKELL)
566-
#if MIN_VERSION_GLASGOW_HASKELL(9,4,0,0) && !MIN_VERSION_GLASGOW_HASKELL(9,6,0,0)
567-
pure Nothing
568-
#else
569562
x <- readTVarIO _var
570563
noThunks _ctx x
571-
#endif
572-
#endif
573564

574565
-- TODO: in some cases, strict-mvar functions leave thunks behind, in particular
575566
-- modifyMVarMasked and modifyMVarMasked_. So in some specific cases we evaluate

0 commit comments

Comments
 (0)