qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 2/4] sysemu/os-win32: fix setjmp/longjmp on windows-arm64


From: Pierrick Bouvier
Subject: Re: [PATCH v2 2/4] sysemu/os-win32: fix setjmp/longjmp on windows-arm64
Date: Mon, 20 Feb 2023 10:53:38 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.2

On 2/16/23 21:02, Richard Henderson wrote:
On 2/16/23 03:49, Pierrick Bouvier wrote:
Windows implementation of setjmp/longjmp is done in
C:/WINDOWS/system32/ucrtbase.dll. Alas, on arm64, it seems to *always*
perform stack unwinding, which crashes from generated code.

By using alternative implementation built in mingw, we avoid doing stack
unwinding and this fixes crash when calling longjmp.

Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
   include/sysemu/os-win32.h | 21 +++++++++++++++++++--
   meson.build               | 22 ++++++++++++++++++++++
   2 files changed, 41 insertions(+), 2 deletions(-)

Ugly, but workable.

Acked-by: Richard Henderson <richard.henderson@linaro.org>

Ideally we'd interact properly with system unwinding.  It looks like we'd use
RtlAddFunctionTable, but the documentation is spread out and I've not found all 
of the bits.

We already do something similar for gdb -- see tcg/tcg.c, tcg_register_jit_int, 
and
tcg/aarch64/tcg-target.c.inc, debug_frame.


Thanks for the idea.
For the sake of completeness, using RtlInstallFunctionTableCallback could be a better strategy, as it allows to have a callback called only during stack unwinding [1].

Meanwhile, I'll ask to our contact in MSFT if it's possible to perform a setjmp/longjmp that does not trigger stack unwinding on aarch64.

[1] https://learn.microsoft.com/en-us/windows/win32/api/winnt/nf-winnt-rtlinstallfunctiontablecallback


r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]