From f84acd6e090c052c8a70a611eafbf7959464937b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20H=C3=B6gberg?= Date: Tue, 6 Aug 2019 09:16:48 +0200 Subject: 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. --- lib/kernel/src/erts_debug.erl | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib') 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(), -- cgit v1.2.3