Hello, after rechecking the setjmp/_setjmp for amd64, arm32 and arm64 implementation in msvcrt, msvcr* and UCRT again, I have realized that non-ex functions have basically same behavior as -ex implementations or non-ex are just redirections to the -ex implementations.
This is not so obvious to see in older msvcrt.dll because at the beginning of setjmp function is code which reads something from library and if it is non-null then it jumps to that read address (if it is null then code continues in the setjmp function). And that reading is done from read-only memory and there is stored address of the setjmpex function. So basically that conditional jump is unconditional and the setjmp is never executed (always jumps to setjmpex). So it means that for amd64, arm32 and arm64 it does not matter if the _setjmp or _setjmpex is called, both functions stores frame pointer from the second parameter into the jmp_buf structure and so longjmp from both of them is always doing SEH unwinding. For i386 it is only slightly complicated. setjmp and _setjmp3 always stores the unwinding info to the struct, but it is the longjmp macro which decides whether to do unwinding or not. There is longjmp symbol and _longjmpex symbol. And for msvcrt20+ (so including msvcrt.dll and UCRT), the longjmp is aliased to _longjmpex, and hence since msvcrt20, the unwinding is always done (that is why I added longjmp wrapper for crtdll.dll and msvcrt10.dll builds). This means that: - non-ex implementations in mingw-w64-crt/misc/setjmp.S are wrong, they should not clear second argument - my new change "crt: Provide _setjmpex() function for arm32 UCRT builds" which adds a new file ucrt_arm32__setjmpex.c is also wrong, its _setjmpex should be just a simple alias to _setjmp (for simplicity defined in .def file) I will provide replacement for that "crt: Provide _setjmpex() function for arm32 UCRT builds" change and will try to fix also the first issue in mingw-w64-crt/misc/setjmp.S. On Saturday 26 September 2026 21:29:18 Pali Rohár wrote: > Hello, in the attachment I'm sending setjmp/longjmp fixes. > > It fixes mingw-w64 _setjmp/_setjmp3/longjmp/_longjmpex implementations > for various CRT builds. And add new tests for verification. > > Kirill run CI testing on github: > https://github.com/maiddaisuki/mingw-w64/actions/runs/36254715839 _______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
