aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/test
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2019-03-12 14:56:20 +0100
committerSverker Eriksson <[email protected]>2019-03-19 20:05:14 +0100
commit7a0a52a9a1adc8f87365936f4e76739b7850f1b3 (patch)
tree21920a7579645ab24efa0fd4aa7c24e7d0bf7b69 /erts/emulator/test
parent620ac3e68c5bc8b36143965fcf2892a07dc005c4 (diff)
downloadotp-7a0a52a9a1adc8f87365936f4e76739b7850f1b3.tar.gz
otp-7a0a52a9a1adc8f87365936f4e76739b7850f1b3.tar.bz2
otp-7a0a52a9a1adc8f87365936f4e76739b7850f1b3.zip
erts: Schedule resource destructors always
to run user NIF code in a more known execution context. Fixes problems like user calling enif_whereis_pid() in destructor which may need to release process main lock in order to lock reg_tab.
Diffstat (limited to 'erts/emulator/test')
-rw-r--r--erts/emulator/test/nif_SUITE.erl17
-rw-r--r--erts/emulator/test/nif_SUITE_data/nif_SUITE.c4
2 files changed, 17 insertions, 4 deletions
diff --git a/erts/emulator/test/nif_SUITE.erl b/erts/emulator/test/nif_SUITE.erl
index ca5f90621f..6ca0990a8a 100644
--- a/erts/emulator/test/nif_SUITE.erl
+++ b/erts/emulator/test/nif_SUITE.erl
@@ -28,6 +28,7 @@
-include_lib("stdlib/include/assert.hrl").
-export([all/0, suite/0, groups/0,
+ init_per_suite/1, end_per_suite/1,
init_per_group/2, end_per_group/2,
init_per_testcase/2, end_per_testcase/2,
basic/1, reload_error/1, upgrade/1, heap_frag/1,
@@ -105,6 +106,14 @@ all() ->
nif_whereis, nif_whereis_parallel, nif_whereis_threaded,
nif_ioq].
+init_per_suite(Config) ->
+ erts_debug:set_internal_state(available_internal_state, true),
+ Config.
+
+end_per_suite(_Config) ->
+ catch erts_debug:set_internal_state(available_internal_state, false),
+ ok.
+
groups() ->
[{G, [], api_repeaters()} || G <- api_groups()]
++
@@ -114,7 +123,6 @@ groups() ->
monitor_process_d,
demonitor_process]}].
-
api_groups() -> [api_latest, api_2_4, api_2_0].
api_repeaters() -> [upgrade, resource_takeover, t_on_load].
@@ -1711,6 +1719,7 @@ read_resource(Type, {Holder,Id}) ->
forget_resource({Holder,Id}) ->
Holder ! {self(), forget, Id},
{Holder, forget_ok, Id} = receive_any(),
+ erts_debug:set_internal_state(wait, aux_work),
ok.
@@ -3327,6 +3336,10 @@ make_unaligned_binary(Bin0) ->
<<0:3,Bin:Size/binary,31:5>> = id(<<0:3,Bin0/binary,31:5>>),
Bin.
+last_resource_dtor_call() ->
+ erts_debug:set_internal_state(wait, aux_work),
+ last_resource_dtor_call_nif().
+
id(I) -> I.
%% The NIFs:
@@ -3354,7 +3367,7 @@ make_resource(_) -> ?nif_stub.
get_resource(_,_) -> ?nif_stub.
release_resource(_) -> ?nif_stub.
release_resource_from_thread(_) -> ?nif_stub.
-last_resource_dtor_call() -> ?nif_stub.
+last_resource_dtor_call_nif() -> ?nif_stub.
make_new_resource(_,_) -> ?nif_stub.
check_is(_,_,_,_,_,_,_,_,_,_,_) -> ?nif_stub.
check_is_exception() -> ?nif_stub.
diff --git a/erts/emulator/test/nif_SUITE_data/nif_SUITE.c b/erts/emulator/test/nif_SUITE_data/nif_SUITE.c
index f2ce6dbe67..17ba3ce297 100644
--- a/erts/emulator/test/nif_SUITE_data/nif_SUITE.c
+++ b/erts/emulator/test/nif_SUITE_data/nif_SUITE.c
@@ -866,7 +866,7 @@ static ERL_NIF_TERM iolist_2_bin(ErlNifEnv* env, int argc, const ERL_NIF_TERM ar
return enif_make_binary(env,&obin);
}
-static ERL_NIF_TERM last_resource_dtor_call(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
+static ERL_NIF_TERM last_resource_dtor_call_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
ERL_NIF_TERM ret;
if (resource_dtor_last != NULL) {
@@ -3512,7 +3512,7 @@ static ErlNifFunc nif_funcs[] =
{"get_resource", 2, get_resource},
{"release_resource", 1, release_resource},
{"release_resource_from_thread", 1, release_resource_from_thread},
- {"last_resource_dtor_call", 0, last_resource_dtor_call},
+ {"last_resource_dtor_call_nif", 0, last_resource_dtor_call_nif},
{"make_new_resource", 2, make_new_resource},
{"check_is", 11, check_is},
{"check_is_exception", 0, check_is_exception},