diff options
author | Adam Sandberg Ericsson <adam@sandbergericsson.se> | 2022-06-18 10:01:22 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-07-07 23:24:34 -0400 |
commit | 42c917df5be8d75f79a283a8ed59fbaf099bc973 (patch) | |
tree | 9efeae5f39cd9c8ff49ec68ceb3b9f5f5a6ee2cf /rts/PrimOps.cmm | |
parent | fa59223b05e24d6e477e3ab0ab296e32b2b65a8b (diff) | |
download | haskell-42c917df5be8d75f79a283a8ed59fbaf099bc973.tar.gz |
rts: allow NULL to be used as an invalid StgStablePtr
Diffstat (limited to 'rts/PrimOps.cmm')
-rw-r--r-- | rts/PrimOps.cmm | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/rts/PrimOps.cmm b/rts/PrimOps.cmm index 84c5850f97..b865092ed1 100644 --- a/rts/PrimOps.cmm +++ b/rts/PrimOps.cmm @@ -2307,7 +2307,7 @@ stg_newIOPortzh () } /* ----------------------------------------------------------------------------- - Stable pointer primitives + Stable name primitives ------------------------------------------------------------------------- */ stg_makeStableNamezh ( P_ obj ) @@ -2347,6 +2347,10 @@ stg_makeStableNamezh ( P_ obj ) return (sn_obj); } +/* ----------------------------------------------------------------------------- + Stable pointer primitives + ------------------------------------------------------------------------- */ + stg_makeStablePtrzh ( P_ obj ) { W_ sp; @@ -2358,7 +2362,9 @@ stg_makeStablePtrzh ( P_ obj ) stg_deRefStablePtrzh ( P_ sp ) { W_ r; - r = spEntry_addr(W_[stable_ptr_table] + sp*SIZEOF_spEntry); + // see Note [NULL StgStablePtr] in StablePtr.c + // here we assume that sp is a valid StablePtr# + r = spEntry_addr(W_[stable_ptr_table] + (sp-1)*SIZEOF_spEntry); return (r); } |