[Git][ghc/ghc][wip/T25377] rts: Add assertions surrounding tracking of StgAsyncIOResult

Ben Gamari (@bgamari) gitlab at gitlab.haskell.org
Wed Oct 16 15:26:19 UTC 2024



Ben Gamari pushed to branch wip/T25377 at Glasgow Haskell Compiler / GHC


Commits:
182b2a99 by Ben Gamari at 2024-10-16T11:26:00-04:00
rts: Add assertions surrounding tracking of StgAsyncIOResult

We were previously pretty cavalier in handling StgAsyncIOResults which
has proven in #25377 to be problematic. We now initialize the
AsyncResult field of the `stg_block_async_void` frame to NULL when
pushing, assert that it is NULL in `awaitRequest` and that it is not
NULL in `stg_block_async_void`.

- - - - -


2 changed files:

- rts/HeapStackCheck.cmm
- rts/win32/AsyncMIO.c


Changes:

=====================================
rts/HeapStackCheck.cmm
=====================================
@@ -730,6 +730,7 @@ stg_block_async
 INFO_TABLE_RET ( stg_block_async_void, RET_SMALL, W_ info_ptr, W_ ares )
     return ()
 {
+    ASSERT(ares != 0);
     ccall free(ares "ptr");
     return ();
 }
@@ -738,6 +739,7 @@ stg_block_async_void
 {
     Sp_adj(-2);
     Sp(0) = stg_block_async_void_info;
+    Sp(1) = 0;  // this is the StgAsyncIOResult, which will be filled in by awaitRequests.
     BLOCK_GENERIC;
 }
 


=====================================
rts/win32/AsyncMIO.c
=====================================
@@ -326,6 +326,8 @@ start:
                         // stg_block_async_info stack frame, because
                         // the block_info field will be overwritten by
                         // pushOnRunQueue().
+                        ASSERT(tso->stackobj->sp[0] == (StgWord) &stg_block_async_void_info);
+                        ASSERT(tso->stackobj->sp[1] == 0);
                         tso->stackobj->sp[1] = (W_)tso->block_info.async_result;
                         pushOnRunQueue(&MainCapability, tso);
                         break;



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/182b2a99c1f79c98c928e63eec536b6c9ab15cae

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/182b2a99c1f79c98c928e63eec536b6c9ab15cae
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/20241016/598c80df/attachment-0001.html>


More information about the ghc-commits mailing list