Skip to content

Commit b6bd86f

Browse files
mflattrmculpepper
authored andcommitted
win64: JIT stack-trace repair
Relevant to PR 13702 Merge to 5.3.4 (cherry picked from commit 5887d78)
1 parent 4f738c6 commit b6bd86f

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
@@ -244,30 +244,30 @@ Scheme_Object *scheme_native_stack_trace(void)
244244
may have the next return address */
245245
ctx.Rip = fp[-(3 + LOCAL_FRAME_SIZE + 1)];
246246
}
247-
name = NULL;
247+
name = find_symbol((uintptr_t)ctx.Rip);
248248
} else {
249249
/* normal JIT function convention */
250+
}
250251

251-
cache_sp = (void *)fp;
252+
cache_sp = (void *)fp;
252253

253-
if (SCHEME_EOFP(name)) {
254-
/* JIT_LOCAL2 has the name to use */
255-
name = *(Scheme_Object **)fp[JIT_LOCAL2 >> JIT_LOG_WORD_SIZE];
256-
}
254+
if (SCHEME_EOFP(name)) {
255+
/* JIT_LOCAL2 has the name to use */
256+
name = *(Scheme_Object **)fp[JIT_LOCAL2 >> JIT_LOG_WORD_SIZE];
257+
}
257258

258-
ctx.Rsp = ctx.Rbp + (2 * sizeof(void*));
259+
ctx.Rsp = ctx.Rbp + (2 * sizeof(void*));
259260
# ifdef NEED_LOCAL4
260-
ctx.R14 = fp[-JIT_LOCAL4_OFFSET];
261+
ctx.R14 = fp[-JIT_LOCAL4_OFFSET];
261262
# endif
262-
ctx.Rbp = fp[0];
263-
ctx.Rbx = fp[-1];
264-
ctx.Rsi = fp[-2];
265-
ctx.Rdi = fp[-3];
266-
ctx.Rip = fp[1];
267-
268-
if (SCHEME_NULLP(name))
269-
name = NULL;
270-
}
263+
ctx.Rbp = fp[0];
264+
ctx.Rbx = fp[-1];
265+
ctx.Rsi = fp[-2];
266+
ctx.Rdi = fp[-3];
267+
ctx.Rip = fp[1];
268+
269+
if (SCHEME_NULLP(name))
270+
name = NULL;
271271
} else {
272272
unsuccess++;
273273
rf = RtlLookupFunctionEntry(ctx.Rip, &base, NULL);
@@ -296,6 +296,12 @@ Scheme_Object *scheme_native_stack_trace(void)
296296
}
297297
cache_sp = NULL;
298298
}
299+
300+
if (!(STK_COMP((uintptr_t)ctx.Rsp, stack_end)
301+
&& STK_COMP(stack_start, (uintptr_t)ctx.Rsp))) {
302+
/* out of stack range */
303+
break;
304+
}
299305
}
300306

301307
if (last)

0 commit comments

Comments
 (0)