From a1595fa23ada22f4b692df4ea5fd69f081aed33f Mon Sep 17 00:00:00 2001 From: Daniel Balla Date: Mon, 17 Dec 2018 00:17:11 +0100 Subject: [PATCH] Fix possible failure in backtrace info (#2643) Make sure to ignore static snapshots when sending backtrace information to the debugger. The `JMEM_SET_NON_NULL_POINTER` macro requires the frame context's `bytecode_header_p` pointer to be a heap pointer, but due to the static snapshot it might not be, causing an assertion failure. JerryScript-DCO-1.0-Signed-off-by: Daniel Balla dballa@inf.u-szeged.hu --- jerry-core/debugger/debugger.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/jerry-core/debugger/debugger.c b/jerry-core/debugger/debugger.c index 649f36571..75b58962d 100644 --- a/jerry-core/debugger/debugger.c +++ b/jerry-core/debugger/debugger.c @@ -130,7 +130,10 @@ jerry_debugger_send_backtrace (const uint8_t *recv_buffer_p) /**< pointer to the uint32_t frame_count = 0; while (iter_frame_ctx_p != NULL) { - frame_count++; + if (!(iter_frame_ctx_p->bytecode_header_p->status_flags & (CBC_CODE_FLAGS_STATIC_FUNCTION))) + { + frame_count++; + } iter_frame_ctx_p = iter_frame_ctx_p->prev_context_p; } memcpy (backtrace_total_p->frame_count, &frame_count, sizeof (frame_count)); @@ -160,7 +163,8 @@ jerry_debugger_send_backtrace (const uint8_t *recv_buffer_p) /**< pointer to the while (frame_ctx_p != NULL && min_depth_offset++ < max_depth) { - if (frame_ctx_p->bytecode_header_p->status_flags & CBC_CODE_FLAGS_DEBUGGER_IGNORE) + if (frame_ctx_p->bytecode_header_p->status_flags + & (CBC_CODE_FLAGS_DEBUGGER_IGNORE | CBC_CODE_FLAGS_STATIC_FUNCTION)) { frame_ctx_p = frame_ctx_p->prev_context_p; continue;