Simon Jakobi pushed to branch wip/sjakobi/nonmoving-gc-test-fixes at Glasgow Haskell Compiler / GHC
Commits:
-
80465707
by Simon Jakobi at 2026-08-09T05:46:40+02:00
-
91790b45
by Simon Jakobi at 2026-08-09T05:46:40+02:00
6 changed files:
- libraries/base/tests/listThreads1.hs
- libraries/base/tests/listThreads1.stdout
- rts/js/thread.js
- + testsuite/tests/concurrent/should_run/T16761.hs
- + testsuite/tests/concurrent/should_run/T16761.stdout
- testsuite/tests/concurrent/should_run/all.T
Changes:
| ... | ... | @@ -2,5 +2,10 @@ module Main where |
| 2 | 2 | |
| 3 | 3 | import GHC.Conc.Sync
|
| 4 | 4 | |
| 5 | +-- Regression test for the JS backend's ListThreadsOp, which used to omit the
|
|
| 6 | +-- running thread. Whatever other threads the RTS has is irrelevant here.
|
|
| 5 | 7 | main :: IO ()
|
| 6 | -main = listThreads >>= print |
|
| 8 | +main = do
|
|
| 9 | + tid <- myThreadId
|
|
| 10 | + ts <- listThreads
|
|
| 11 | + print (tid `elem` ts) |
| 1 | -[ThreadId 1] |
|
| 1 | +True |
| ... | ... | @@ -110,6 +110,10 @@ function h$rts_getThreadId(t) { // returns a CULLong |
| 110 | 110 | RETURN_UBX_TUP2((t.tid / Math.pow(2,32))>>>0, (t.tid & 0xFFFFFFFF)>>>0);
|
| 111 | 111 | }
|
| 112 | 112 | |
| 113 | +function h$eq_thread(t1,t2) {
|
|
| 114 | + return t1 === t2 ? 1 : 0;
|
|
| 115 | +}
|
|
| 116 | + |
|
| 113 | 117 | function h$cmp_thread(t1,t2) {
|
| 114 | 118 | if(t1.tid < t2.tid) return -1;
|
| 115 | 119 | if(t1.tid > t2.tid) return 1;
|
| 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)
|