diff options
-rw-r--r-- | rts/PrimOps.cmm | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/rts/PrimOps.cmm b/rts/PrimOps.cmm index a920fd333b..a13dae6774 100644 --- a/rts/PrimOps.cmm +++ b/rts/PrimOps.cmm @@ -2360,6 +2360,7 @@ stg_mkApUpd0zh ( P_ bco ) stg_unpackClosurezh ( P_ closure ) { W_ info, ptrs, nptrs, p, ptrs_arr, dat_arr; + MAYBE_GC_P(stg_unpackClosurezh, closure); info = %GET_STD_INFO(UNTAG(closure)); prim_read_barrier; @@ -2375,12 +2376,13 @@ stg_unpackClosurezh ( P_ closure ) (len) = foreign "C" heap_view_closureSize(clos "ptr"); W_ ptrs_arr_sz, ptrs_arr_cards, dat_arr_sz; - dat_arr_sz = SIZEOF_StgArrBytes + WDS(len); - - ALLOC_PRIM_P (dat_arr_sz, stg_unpackClosurezh, closure); - - dat_arr = Hp - dat_arr_sz + WDS(1); + dat_arr_sz = SIZEOF_StgArrBytes + WDS(len); + ("ptr" dat_arr) = ccall allocateMightFail(MyCapability() "ptr", BYTES_TO_WDS(dat_arr_sz)); + if (dat_arr == NULL) (likely: False) { + jump stg_raisezh(base_GHCziIOziException_heapOverflow_closure); + } + TICK_ALLOC_PRIM(SIZEOF_StgArrBytes, WDS(len), 0); SET_HDR(dat_arr, stg_ARR_WORDS_info, CCCS); StgArrBytes_bytes(dat_arr) = WDS(len); |