Fix erlang:raise/3 assert with built stacktrace#2252
Fix erlang:raise/3 assert with built stacktrace#2252bettio wants to merge 1 commit intoatomvm:release-0.7from
Conversation
07263bb to
7e62129
Compare
7e62129 to
86ff1db
Compare
| term_put_tuple_element(stack_info, 2, term_from_int(0)); | ||
| term_put_tuple_element(stack_info, 3, term_from_int(0)); | ||
| term_put_tuple_element(stack_info, 4, built_stacktrace); | ||
| term_put_tuple_element(stack_info, 5, exception_class); |
Check failure
Code scanning / CodeQL
Use of term variable after garbage collection Error
When erlang:raise/3 is called with a built stacktrace (list of
{M,F,A,Loc} tuples) and the re-raised exception passes through a
try/catch whose clauses do not match, the compiler-generated catch-all
(OP_RAISE) calls stacktrace_exception_class, which asserts on a
6-tuple. The built list was stored as-is, never wrapped.
Wrap the built stacktrace into a raw 6-tuple in stacktrace_create_raw_mfa
so OP_RAISE and stacktrace_build can process it. Route OP_RAW_RAISE
through HANDLE_ERROR() so it also hits the wrapping path.
Signed-off-by: Davide Bettio <davide@uninstall.it>
86ff1db to
949690a
Compare
|
https://ampcode.com/threads/T-019d4d69-3ac6-718e-8d7c-1ad32f287c7b PR Review: Fix erlang:raise/3 assert with built stacktraceCommit: SummaryWhen The fix:
Verdict: ✅ Approve with suggestionsThe core fix is correct and well-reasoned for the interpreter path. GC root handling is safe, Issues Found🔴 Critical: JIT
|
stacktrace_exception_classwhenerlang:raise/3is called with a built stacktrace and the re-raised exception hits a non-matching catch clause (triggering the compiler-generatedOP_RAISE)stacktrace_create_raw_mfaOP_RAW_RAISEthroughHANDLE_ERROR()so both the NIF path and theraw_raiseopcode path go through the wrapping logicstacktrace_buildfor pre-built stacktracesFixes #2185
These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).
SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later