Simon Jakobi pushed to branch wip/sjakobi/nonmoving-gc-test-fixes at Glasgow Haskell Compiler / GHC
Commits:
-
fb53a40c
by Simon Jakobi at 2026-08-05T21:53:54+02:00
3 changed files:
- + testsuite/tests/concurrent/should_run/T16761.hs
- + testsuite/tests/concurrent/should_run/T16761.stdout
- testsuite/tests/concurrent/should_run/all.T
Changes:
| 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) |
| 1 | +True
|
|
| 2 | +False
|
|
| 3 | +True
|
|
| 4 | +True
|
|
| 5 | +True
|
|
| 6 | +True |
| ... | ... | @@ -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)
|