Bug ID: 41123
Summary: X86: Underflow error in stack probe emitting
Component: Backend: X86
CC: craig.top...@gmail.com, email@example.com,
In X86FrameLowering::emitPrologue, there's some logic that checks if NumBytes
(the number of bytes that need to be reserved on the stack for the local stack
frame) exceeds some "stack probe size" and, if so, emits a stack probe call.
The stack probe call expects to find the size of stack space to be probed in
EAX/RAX. If that register is already alive, it's first pushed to the stack, and
the effect on ESP/RSP from that extra push is negated from NumBytes.
This means that if NumBytes is 0, the value passed to the stack probe is
actually an underflowed value, which the stack probe may interpret as an
extremely large number, causing a stack overflow at runtime.
Normally, this isn't a problem - the default "stack probe size" is 4096 bytes,
meaning NumBytes must already be sufficiently large that this subtraction
cannot underflow. However, if the user (or, rather, the project the user is
trying to compile) overrides the stack probe size to 0 ("emit probes
unconditionally"), then the underflow may occur and produce an invalid stack
I haven't checked if this bug exists in any other code generators; but I found
this one in the wild whilst trying to run an LLVM-produced X86 program.
You are receiving this mail because:
You are on the CC list for the bug.
llvm-bugs mailing list