简体   繁体   English

x86_64-w64-mingw32中的setjmp / longjmp

[英]setjmp/longjmp in x86_64-w64-mingw32

A while ago setjmp/longjmp in mingw-w64 was known to be broken ( http://www.agardner.me/golang/windows/cgo/64-bit/setjmp/longjmp/2016/02/29/go-windows-setjmp-x86.html ). 不久前,已知mingw-w64中的setjmp / longjmp被打破了( http://www.agardner.me/golang/windows/cgo/64-bit/setjmp/longjmp/2016/02/29/go-windows- setjmp-x86.html )。

We have a legacy code that we used to run on 32 bit Linux and 32 bit Windows, which (still) works fine. 我们有一个遗留代码,我们曾经在32位Linux和32位Windows上运行,这些代码(仍然)运行良好。 64-bit Linux version also works fine, but 64 bit Windows version breaks down after first longjmp back to setjmp location. 64位Linux版本也可以正常工作,但是在第一个longjmp返回setjmp位置后,64位Windows版本会崩溃。

I get segfault somewhere in msvcrt!_setjmpex,msvcrt!RtlUnwindEx. 我在msvcrt!_setjmpex,msvcrt!RtlUnwindEx中出现段错误。

I have looked into code and initially I can't notice any violations of rules defined for setjmp/longjmp by C (99/11) standards in our code. 我已经研究了代码,最初我注意到在我们的代码中C(99/11)标准没有违反为setjmp / longjmp定义的规则。 The workaround described above ("use gcc builtins") also does not work for me. 上述解决方法(“使用gcc内置函数”)对我也不起作用。

I have trouble creating minimal reproducible example. 我在创建最小的可复制示例时遇到了麻烦。 Example works. 示例作品。 Full code not. 完整的代码没有。 Of course I can start removing functionality from full source code, but that is not a simple task. 当然,我可以开始从完整的源代码中删除功能,但这不是一个简单的任务。

So, the question here is basically, is setjmp/longjmp in mingw-w64 known to (still) be broken? 因此,这里的问题基本上是,(仍然)已知的mingw-w64中的setjmp / longjmp是否被破坏了?

Yes, it looks setjmp/longjmp still breaks down for some code compiled with x86_64-w64-mingw32 compiler. 是的,对于使用x86_64-w64-mingw32编译器编译的某些代码,setjmp / longjmp仍然无法正常工作。 It works for simpler testcase, I tried to reproduce an issue with. 它适用于更简单的测试用例,我尝试重现一个问题。 So if you bump into this longjmp/setjmp issue try to use __builtin_setjmp and __builtin_longjmp instead (as explained here ). 所以,如果你碰到这样的longjmp / setjmp的问题,尝试使用__builtin_setjmp,而是__builtin_longjmp(如解释在这里 )。

My mistake was redefining longjmp/setjmp macros, so I could choose which version to use by simple define, but missing to do this everywhere. 我的错误是重新定义了longjmp / setjmp宏,因此我可以通过简单的define选择要使用的版本,但是却到处都找不到。 This caused compiled program to use both builtin and library versions, which are not compatible. 这导致编译的程序同时使用不兼容的内置版本和库版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM