Post #2158443
2026-04-29 18:47 UTC
The culprit was a function that was using edi for its own purposes. It was correctly using push/pop edi to preserve the caller's value, but that was going wrong.
The stdcall ABI used on Windows means the callee pops arguments off the stack. This means when the culprit function calls one of my functions and I had the arguments wrong, the stack pointer gets off by an entry or two. I've written this bug so many times! This meant the restored edi was instead some other garbage on the stack.
Replies (1)
-
@evmar@inuh.net 2026-04-29 18:49
Normally screwing up the stack pointer in this way makes things go immediately wrong elsewhere because it fails to return to the right address. But in this case, the function was using ebp to save/restore the stack pointer, totally masking that I had messed up the stack pointer -- except in how it was failing to preserve this register, the cause of this bug. This is the same masking @aaronsgiles wrote about in https://corteximplant.com/@aaronsgiles/116044322660755992 .