diff options
author | Richard Carlsson <[email protected]> | 2015-04-26 16:29:53 +0200 |
---|---|---|
committer | Björn-Egil Dahlberg <[email protected]> | 2015-06-10 15:56:56 +0200 |
commit | 3219822bb549a9d0d40ff29463f0bfe7d1eedd37 (patch) | |
tree | d19b0294cc422e689356a598dc858e601a6c5283 /erts/emulator/test/module_info_SUITE.erl | |
parent | d8f343b234174d49bc66d5bddbe79f24400868e6 (diff) | |
download | otp-3219822bb549a9d0d40ff29463f0bfe7d1eedd37.tar.gz otp-3219822bb549a9d0d40ff29463f0bfe7d1eedd37.tar.bz2 otp-3219822bb549a9d0d40ff29463f0bfe7d1eedd37.zip |
Fix segfault in module_info for deleted modules
Add a check to protect from segfault when erlang:get_module_info/1/2 is
called on a deleted module (i.e. with no current code). Also refactor
erts_module_info_0/1 to avoid repeated calls to erts_active_code_ix() and
remove some obsolete comments. Add test for module_info on deleted modules.
Diffstat (limited to 'erts/emulator/test/module_info_SUITE.erl')
-rw-r--r-- | erts/emulator/test/module_info_SUITE.erl | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/erts/emulator/test/module_info_SUITE.erl b/erts/emulator/test/module_info_SUITE.erl index 1125cf3072..362e210d20 100644 --- a/erts/emulator/test/module_info_SUITE.erl +++ b/erts/emulator/test/module_info_SUITE.erl @@ -24,7 +24,7 @@ -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, - exports/1,functions/1,native/1,info/1]). + exports/1,functions/1,deleted/1,native/1,info/1]). %%-compile(native). @@ -53,7 +53,7 @@ end_per_group(_GroupName, Config) -> modules() -> - [exports, functions, native, info]. + [exports, functions, deleted, native, info]. init_per_testcase(Func, Config) when is_atom(Func), is_list(Config) -> Dog = ?t:timetrap(?t:minutes(3)), @@ -93,6 +93,23 @@ functions(Config) when is_list(Config) -> ?line All = lists:sort(?MODULE:module_info(functions)), ok. +%% Test that deleted modules cause badarg +deleted(Config) when is_list(Config) -> + ?line Data = ?config(data_dir, Config), + ?line File = filename:join(Data, "module_info_test"), + ?line {ok,module_info_test,Code} = compile:file(File, [binary]), + ?line {module,module_info_test} = erlang:load_module(module_info_test, Code), + ?line 17 = module_info_test:f(), + ?line [_|_] = erlang:get_module_info(module_info_test, attributes), + ?line [_|_] = erlang:get_module_info(module_info_test), + ?line erlang:delete_module(module_info_test), + ?line {'EXIT',{undef, _}} = (catch module_info_test:f()), + ?line {'EXIT',{badarg, _}} = + (catch erlang:get_module_info(module_info_test, attributes)), + ?line {'EXIT',{badarg, _}} = + (catch erlang:get_module_info(module_info_test)), + ok. + %% Test that the list of exported functions from this module is correct. %% Verify that module_info(native) works. native(Config) when is_list(Config) -> |