Please remove the change "crt: Provide _setjmpex() function for arm32 UCRT builds" and replace it by two changes which are in the attachment.
CI testing: https://github.com/maiddaisuki/mingw-w64/actions/runs/36504625980 On Monday 28 September 2026 13:15:46 Pali Rohár wrote: > 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
>From cac1d4b2ae82955b9494760692db4ed31c0de758 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <[email protected]> Date: Mon, 28 Sep 2026 12:56:04 +0200 Subject: [PATCH 1/2] crt: Add _setjmpex and __intrinsic_setjmpex symbol aliases for arm32 UCRT builds Function _setjmpex is available in arm32 msvcr110.dll, msvcr120.dll, msvcr120_app.dll and in msvcrt.dll DLL libs. It is also available in arm32 vcruntime140.dll DLL library via symbol __intrinsic_setjmpex which msvc toolchain uses for linking UCRT applications. For some unknown reasons this function is not available in arm32 api-ms-win-crt-private-l1-1-0.dll and ucrtbase.dll libraries which mingw-w64 uses for UCRT builds. But it is available in arm64 versions of those libraries. When application includes setjmpex.h header file, the _setjmpex symbol is emitted for setjmp() calls. So without the _setjmpex symbol in libucrt.a library, the final linking for UCRT builds on arm32 is failing. In arm32 msvcr110.dll, msvcr120.dll, msvcr120_app.dll and in msvcrt.dll DLL libs have _setjmpex symbol with the same functionality as _setjmp symbol. Both functions stores the second argument (frame pointer) into the jmp_buf structure. So for arm32 UCRT define _setjmpex and __intrinsic_setjmpex symbols as aliases to the __intrinsic_setjmp symbol. This prevents applications from linking to the vcruntime140.dll when they are including setjmpex.h file. --- mingw-w64-crt/def-include/crt-aliases.def.in | 2 ++ mingw-w64-crt/lib-common/api-ms-win-crt-private-l1-1-0.def.in | 2 ++ 2 files changed, 4 insertions(+) diff --git a/mingw-w64-crt/def-include/crt-aliases.def.in b/mingw-w64-crt/def-include/crt-aliases.def.in index 36101151b931..bd07657faf1b 100644 --- a/mingw-w64-crt/def-include/crt-aliases.def.in +++ b/mingw-w64-crt/def-include/crt-aliases.def.in @@ -337,7 +337,9 @@ strncasecmp == _strnicmp #ifdef UCRTBASE F_NON_ARM64(_setjmp == __intrinsic_setjmp) +F_ARM32(__intrinsic_setjmpex == __intrinsic_setjmp) F64(_setjmpex == __intrinsic_setjmpex) +F_ARM32(_setjmpex == __intrinsic_setjmp) #endif #ifndef NO_STRCMPI_ALIAS diff --git a/mingw-w64-crt/lib-common/api-ms-win-crt-private-l1-1-0.def.in b/mingw-w64-crt/lib-common/api-ms-win-crt-private-l1-1-0.def.in index a2bce9fcafb7..73340fdd46b8 100644 --- a/mingw-w64-crt/lib-common/api-ms-win-crt-private-l1-1-0.def.in +++ b/mingw-w64-crt/lib-common/api-ms-win-crt-private-l1-1-0.def.in @@ -48,7 +48,9 @@ F_I386(__intrinsic_abnormal_termination) F_NON_ARM64(__intrinsic_setjmp) F_NON_ARM64(_setjmp == __intrinsic_setjmp) F64(__intrinsic_setjmpex) +F_ARM32(__intrinsic_setjmpex == __intrinsic_setjmp) F64(_setjmpex == __intrinsic_setjmpex) +F_ARM32(_setjmpex == __intrinsic_setjmp) __processing_throw __report_gsfailure __std_exception_copy -- 2.20.1 >From d0614fa33cb57c6e03800cfaa80ff22b40473e55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <[email protected]> Date: Mon, 28 Sep 2026 13:23:01 +0200 Subject: [PATCH 2/2] crt: Fix mingw-w64 amd64 setjmp/__intrinsic_setjmp/_setjmp and arm32 __intrinsic_setjmp/_setjmp functions amd64 msvcrt.dll/msvcr80-120 setjmp and _setjmp functions, and amd64 UCRT __intrinsic_setjmp function are not clearing the second (%rdx) argument, they are storing it into the jmp_buf structure. Same applies for arm32 msvcrt.dll/msvcr110-120 _setjmp function and arm32 UCRT __intrinsic_setjmp function. Fix the mingw-w64 implementations of those functions to match the msvcrt and UCRT behavior. --- mingw-w64-crt/misc/setjmp.S | 2 -- 1 file changed, 2 deletions(-) diff --git a/mingw-w64-crt/misc/setjmp.S b/mingw-w64-crt/misc/setjmp.S index 7751dbbd39bc..094d948fb9df 100644 --- a/mingw-w64-crt/misc/setjmp.S +++ b/mingw-w64-crt/misc/setjmp.S @@ -123,7 +123,6 @@ __MINGW_LSYMBOL(setjmp_common): __MINGW_USYMBOL(setjmp): __MINGW_USYMBOL(__intrinsic_setjmp): __MINGW_USYMBOL(_setjmp): - xorq %rdx,%rdx __MINGW_USYMBOL(__intrinsic_setjmpex): __MINGW_USYMBOL(_setjmpex): movq %rdx,(%rcx) /* jmp_buf->Frame */ @@ -157,7 +156,6 @@ __MINGW_USYMBOL(_setjmpex): #elif defined(__arm__) __MINGW_USYMBOL(__intrinsic_setjmp): __MINGW_USYMBOL(_setjmp): - mov r1, #0 __MINGW_USYMBOL(__intrinsic_setjmpex): __MINGW_USYMBOL(_setjmpex): str r1, [r0] /* jmp_buf->Frame */ -- 2.20.1
_______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
