[Git][ghc/ghc][master] rts/win32: Ensure reliability of IO manager shutdown

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Fri Aug 4 16:25:24 UTC 2023



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
01db1117 by Ben Gamari at 2023-08-04T12:25:02-04:00
rts/win32: Ensure reliability of IO manager shutdown

When the Win32 threaded IO manager shuts down, `ioManagerDie` sends an
`IO_MANAGER_DIE` event to the IO manager thread using the
`io_manager_event` event object. Finally, it will closes the event object,
and invalidate `io_manager_event`.

Previously, `readIOManagerEvent` would see that `io_manager_event` is
invalid and return `0`, suggesting that everything is right with the
world. This meant that if `ioManagerDie` invalidated the handle before
the event manager was blocked on the event we would end up in a
situation where the event manager would never realize it was asked to
shut down.

Fix this by ensuring that `readIOManagerEvent` instead returns
`IO_MANAGER_DIE` when we detect that the event object has been
invalidated by `ioManagerDie`.

Fixes #23691.

- - - - -


1 changed file:

- rts/win32/ThrIOManager.c


Changes:

=====================================
rts/win32/ThrIOManager.c
=====================================
@@ -79,7 +79,9 @@ readIOManagerEvent (void)
             }
         }
     } else {
-        res = 0;
+        // Making it here after getIOManagerEvent has been called means that we
+        // have hit ioManagerDie, which closed our event object.
+        res = IO_MANAGER_DIE;
     }
 
     OS_RELEASE_LOCK(&event_buf_mutex);



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/01db1117e18f140987f608a78f3e929242d6f00c

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/01db1117e18f140987f608a78f3e929242d6f00c
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230804/5057a32b/attachment.html>


More information about the ghc-commits mailing list