diff options
author | Steve Vinoski <[email protected]> | 2015-04-30 15:46:52 -0400 |
---|---|---|
committer | Steve Vinoski <[email protected]> | 2015-05-26 11:13:16 -0400 |
commit | 2f38cce79ae1bf318cdc8884bd74d1407778d91d (patch) | |
tree | a9c576fb36558ffb6e1876ac7ca71b7097aa86e3 /erts/emulator/beam/erl_nif.c | |
parent | 50cdb87765cd46e0a809d97f62df28baf8a2c16a (diff) | |
download | otp-2f38cce79ae1bf318cdc8884bd74d1407778d91d.tar.gz otp-2f38cce79ae1bf318cdc8884bd74d1407778d91d.tar.bz2 otp-2f38cce79ae1bf318cdc8884bd74d1407778d91d.zip |
Fix for enif_schedule_nif and exceptions
Fix a place where part of the implementation of enif_schedule_nif was
not using the ErlNifEnv exception_thrown field when it should have
been.
Also make the result of enif_schedule_nif return false when passed to
enif_is_exception, and add an assertion for this to the nif_SUITE.c
tests.
Diffstat (limited to 'erts/emulator/beam/erl_nif.c')
-rw-r--r-- | erts/emulator/beam/erl_nif.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/erts/emulator/beam/erl_nif.c b/erts/emulator/beam/erl_nif.c index 426a00304e..7876785a76 100644 --- a/erts/emulator/beam/erl_nif.c +++ b/erts/emulator/beam/erl_nif.c @@ -445,7 +445,7 @@ int enif_is_list(ErlNifEnv* env, ERL_NIF_TERM term) int enif_is_exception(ErlNifEnv* env, ERL_NIF_TERM term) { - return term == THE_NON_VALUE; + return env->exception_thrown && term == THE_NON_VALUE; } int enif_is_number(ErlNifEnv* env, ERL_NIF_TERM term) @@ -1843,6 +1843,7 @@ execute_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) NifExport* ep; ERL_NIF_TERM result; + ASSERT(!env->exception_thrown); ep = (NifExport*) ERTS_PROC_GET_NIF_TRAP_EXPORT(proc); ASSERT(ep); ep->fp = NULL; @@ -1855,7 +1856,7 @@ execute_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) * which case we need to restore the original NIF MFA. */ if (ep->fp == NULL) - restore_nif_mfa(proc, ep, is_non_value(result) && proc->freason != TRAP); + restore_nif_mfa(proc, ep, env->exception_thrown); return result; } |