Simon Jakobi pushed to branch wip/sjakobi/nonmoving-gc-test-fixes at Glasgow Haskell Compiler / GHC

Commits:

3 changed files:

Changes:

  • testsuite/tests/concurrent/should_run/T16761.hs
    1
    +-- Test that Eq ThreadId is based on thread identity (eq_thread),
    
    2
    +-- not on the numeric thread id, which may wrap around (#16761).
    
    3
    +module Main (main) where
    
    4
    +
    
    5
    +import Control.Concurrent
    
    6
    +import System.Mem (performGC)
    
    7
    +
    
    8
    +main :: IO ()
    
    9
    +main = do
    
    10
    +  t0 <- myThreadId
    
    11
    +  print (t0 == t0)
    
    12
    +
    
    13
    +  mv <- newEmptyMVar
    
    14
    +  _ <- forkIO (myThreadId >>= putMVar mv)
    
    15
    +  tChild <- takeMVar mv
    
    16
    +  print (t0 == tChild)
    
    17
    +  print (tChild == tChild)
    
    18
    +
    
    19
    +  -- Equality must be stable even after the GC moves the TSOs.
    
    20
    +  performGC
    
    21
    +  print (t0 == t0)
    
    22
    +
    
    23
    +  -- Ord must agree with Eq.
    
    24
    +  print (compare t0 tChild /= EQ)
    
    25
    +  print (compare t0 t0 == EQ)

  • testsuite/tests/concurrent/should_run/T16761.stdout
    1
    +True
    
    2
    +False
    
    3
    +True
    
    4
    +True
    
    5
    +True
    
    6
    +True

  • testsuite/tests/concurrent/should_run/all.T
    ... ... @@ -310,6 +310,8 @@ test('hs_try_putmvar003',
    310 310
     # Check forkIO exception determinism under optimization
    
    311 311
     test('T13330', normal, compile_and_run, ['-O'])
    
    312 312
     
    
    313
    +test('T16761', normal, compile_and_run, [''])
    
    314
    +
    
    313 315
     test('T26341', normal, compile_and_run, [''])
    
    314 316
     
    
    315 317
     # Test EINTR for async I/O interrupted by an exception (#26341)