diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2020-06-23 10:01:44 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-06-27 11:55:59 -0400 |
commit | 1b3d13b68c95ef9bbeca4437028531d184abcbea (patch) | |
tree | eed6111120e26030f0ad8ca55144536dcdbe4b1e /rts | |
parent | a403eb917bd26caf96c29d67bfe91163b593b2c9 (diff) | |
download | haskell-1b3d13b68c95ef9bbeca4437028531d184abcbea.tar.gz |
Fix ghc-bignum exceptions
We must ensure that exceptions are not simplified. Previously we used:
case raiseDivZero of
_ -> 0## -- dummyValue
But it was wrong because the evaluation of `raiseDivZero` was removed and
the dummy value was directly returned. See new Note [ghc-bignum exceptions].
I've also removed the exception triggering primops which were fragile.
We don't need them to be primops, we can have them exported by ghc-prim.
I've also added a test for #18359 which triggered this patch.
Diffstat (limited to 'rts')
-rw-r--r-- | rts/Exception.cmm | 19 | ||||
-rw-r--r-- | rts/PrimOps.cmm | 19 |
2 files changed, 19 insertions, 19 deletions
diff --git a/rts/Exception.cmm b/rts/Exception.cmm index 587708e47e..3216edbcc4 100644 --- a/rts/Exception.cmm +++ b/rts/Exception.cmm @@ -14,6 +14,9 @@ #include "RaiseAsync.h" import CLOSURE ghczmprim_GHCziTypes_True_closure; +import CLOSURE base_GHCziExceptionziType_divZZeroException_closure; +import CLOSURE base_GHCziExceptionziType_underflowException_closure; +import CLOSURE base_GHCziExceptionziType_overflowException_closure; /* ----------------------------------------------------------------------------- Exception Primitives @@ -633,6 +636,22 @@ stg_raiseIOzh (P_ exception) jump stg_raisezh (exception); } + +stg_raiseDivZZerozh () +{ + jump stg_raisezh(base_GHCziExceptionziType_divZZeroException_closure); +} + +stg_raiseUnderflowzh () +{ + jump stg_raisezh(base_GHCziExceptionziType_underflowException_closure); +} + +stg_raiseOverflowzh () +{ + jump stg_raisezh(base_GHCziExceptionziType_overflowException_closure); +} + /* The FFI doesn't support variadic C functions so we can't directly expose * `barf` to Haskell code. Instead we define "stg_panic#" and it is exposed to * Haskell programs in GHC.Prim.Panic. diff --git a/rts/PrimOps.cmm b/rts/PrimOps.cmm index 1bd30b3af0..1fd746edf6 100644 --- a/rts/PrimOps.cmm +++ b/rts/PrimOps.cmm @@ -31,9 +31,6 @@ import pthread_mutex_unlock; #endif import CLOSURE base_ControlziExceptionziBase_nestedAtomically_closure; import CLOSURE base_GHCziIOziException_heapOverflow_closure; -import CLOSURE base_GHCziExceptionziType_divZZeroException_closure; -import CLOSURE base_GHCziExceptionziType_underflowException_closure; -import CLOSURE base_GHCziExceptionziType_overflowException_closure; import EnterCriticalSection; import LeaveCriticalSection; import CLOSURE ghczmprim_GHCziTypes_False_closure; @@ -2601,19 +2598,3 @@ stg_setThreadAllocationCounterzh ( I64 counter ) StgTSO_alloc_limit(CurrentTSO) = counter + TO_I64(offset); return (); } - - -stg_raiseDivZZerozh () -{ - jump stg_raisezh(base_GHCziExceptionziType_divZZeroException_closure); -} - -stg_raiseUnderflowzh () -{ - jump stg_raisezh(base_GHCziExceptionziType_underflowException_closure); -} - -stg_raiseOverflowzh () -{ - jump stg_raisezh(base_GHCziExceptionziType_overflowException_closure); -} |