Skip to content

Commit 5887d78

Browse files
committed
win64: JIT stack-trace repair
Relevant to PR 13702 Merge to 5.3.4
1 parent ff580c2 commit 5887d78

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

src/racket/src/jitstack.c

+23-17
Original file line numberDiff line numberDiff line change
@@ -250,30 +250,30 @@ Scheme_Object *scheme_native_stack_trace(void)
250250
may have the next return address */
251251
ctx.Rip = fp[-(3 + LOCAL_FRAME_SIZE + 1)];
252252
}
253-
name = NULL;
253+
name = find_symbol((uintptr_t)ctx.Rip);
254254
} else {
255255
/* normal JIT function convention */
256+
}
256257

257-
cache_sp = (void *)fp;
258+
cache_sp = (void *)fp;
258259

259-
if (SCHEME_EOFP(name)) {
260-
/* JIT_LOCAL2 has the name to use */
261-
name = *(Scheme_Object **)fp[JIT_LOCAL2 >> JIT_LOG_WORD_SIZE];
262-
}
260+
if (SCHEME_EOFP(name)) {
261+
/* JIT_LOCAL2 has the name to use */
262+
name = *(Scheme_Object **)fp[JIT_LOCAL2 >> JIT_LOG_WORD_SIZE];
263+
}
263264

264-
ctx.Rsp = ctx.Rbp + (2 * sizeof(void*));
265+
ctx.Rsp = ctx.Rbp + (2 * sizeof(void*));
265266
# ifdef NEED_LOCAL4
266-
ctx.R14 = fp[-JIT_LOCAL4_OFFSET];
267+
ctx.R14 = fp[-JIT_LOCAL4_OFFSET];
267268
# endif
268-
ctx.Rbp = fp[0];
269-
ctx.Rbx = fp[-1];
270-
ctx.Rsi = fp[-2];
271-
ctx.Rdi = fp[-3];
272-
ctx.Rip = fp[1];
273-
274-
if (SCHEME_NULLP(name))
275-
name = NULL;
276-
}
269+
ctx.Rbp = fp[0];
270+
ctx.Rbx = fp[-1];
271+
ctx.Rsi = fp[-2];
272+
ctx.Rdi = fp[-3];
273+
ctx.Rip = fp[1];
274+
275+
if (SCHEME_NULLP(name))
276+
name = NULL;
277277
} else {
278278
unsuccess++;
279279
rf = RtlLookupFunctionEntry(ctx.Rip, &base, NULL);
@@ -302,6 +302,12 @@ Scheme_Object *scheme_native_stack_trace(void)
302302
}
303303
cache_sp = NULL;
304304
}
305+
306+
if (!(STK_COMP((uintptr_t)ctx.Rsp, stack_end)
307+
&& STK_COMP(stack_start, (uintptr_t)ctx.Rsp))) {
308+
/* out of stack range */
309+
break;
310+
}
305311
}
306312

307313
if (last)

0 commit comments

Comments
 (0)