diff options
author | John Högberg <[email protected]> | 2019-08-06 09:16:48 +0200 |
---|---|---|
committer | John Högberg <[email protected]> | 2019-08-06 10:01:54 +0200 |
commit | f84acd6e090c052c8a70a611eafbf7959464937b (patch) | |
tree | f3938ff28ea1d18b5117f17118dc3c773f6e0274 | |
parent | 64731f3bb753f2b534ada36a4713370aecc8b4b1 (diff) | |
download | otp-f84acd6e090c052c8a70a611eafbf7959464937b.tar.gz otp-f84acd6e090c052c8a70a611eafbf7959464937b.tar.bz2 otp-f84acd6e090c052c8a70a611eafbf7959464937b.zip |
erts_debug: Turn off unsafe optimizations in test case
The test case alters the return value of a function that the
compiler expects will never return, resulting in undefined
behavior.
Note that the debugger (which may change variables/return values)
is unaffected since the affected module is purged and "replaced"
with an interpreted variant.
-rw-r--r-- | erts/emulator/test/nofrag_SUITE.erl | 5 | ||||
-rw-r--r-- | lib/kernel/src/erts_debug.erl | 9 |
2 files changed, 14 insertions, 0 deletions
diff --git a/erts/emulator/test/nofrag_SUITE.erl b/erts/emulator/test/nofrag_SUITE.erl index 8b1519ae36..d4c74579e2 100644 --- a/erts/emulator/test/nofrag_SUITE.erl +++ b/erts/emulator/test/nofrag_SUITE.erl @@ -22,6 +22,11 @@ -include_lib("common_test/include/ct.hrl"). +%% This suite alters the return values of functions which breaks certain +%% assumptions made by the compiler, so we have to turn off module-level type +%% optimization to be safe. +-compile(no_module_opt). + -export([all/0, suite/0, error_handler/1,error_handler_apply/1, error_handler_fixed_apply/1,error_handler_fun/1, diff --git a/lib/kernel/src/erts_debug.erl b/lib/kernel/src/erts_debug.erl index 42261d371d..7b9067d079 100644 --- a/lib/kernel/src/erts_debug.erl +++ b/lib/kernel/src/erts_debug.erl @@ -40,6 +40,15 @@ lc_graph/0, lc_graph_to_dot/2, lc_graph_merge/2, alloc_blocks_size/1]). +%% Reroutes calls to the given MFA to error_handler:breakpoint/3 +%% +%% Note that this is potentially unsafe as compiled code may assume that the +%% targeted function returns a specific type, triggering undefined behavior if +%% this function were to return something else. +%% +%% For reference, the debugger avoids the issue by purging the affected module +%% and interpreting all functions in the module, ensuring that no assumptions +%% are made with regard to return or argument types. -spec breakpoint(MFA, Flag) -> non_neg_integer() when MFA :: {Module :: module(), Function :: atom(), |