@@ -61,65 +61,15 @@ typedef sigjmp_buf platform_jmp_buf;
61
61
#define CONCAT (a , b ) CONCAT2(a, b)
62
62
#define VERSIONED_SYMBOL (a ) CONCAT(a, VERSIONED_SUFFIX)
63
63
64
- // Define one function here, `wasmtime_setjmp_inverted`, which returns the
65
- // negation of whether the call succeeded. Define then the actual import below
66
- // of `wasmtime_setjmp_*` which returns the negation of this negation which
67
- // means it returns whether the function invocation succeeded or not.
68
- //
69
- // Why in the world would we do this? For now: MinGW. In
70
- // bytecodealliance/wasmtime#9675 that PR was originally failing CI only on
71
- // MinGW and seems to be fixed by this. In that PR the signature of `body` here
72
- // changed from a `void` return to a `bool` returned. That means that the body
73
- // of this function changed from the historical:
74
- //
75
- // body(payload, callee);
76
- // return 1;
77
- //
78
- // to what we actually want:
79
- //
80
- // return body(payload, callee);
81
- //
82
- // For some reason though this causes issues when unwinding via `longjmp` on
83
- // Windows. Tests would exit with the error message:
84
- //
85
- // code 0xc0000028: An invalid or unaligned stack was encountered during an
86
- // unwind operation. (os error 543)
87
- //
88
- // Debugging revealed that if this:
89
- //
90
- // return body(payload, callee);
91
- //
92
- // were written as:
93
- //
94
- // bool ret = body(payload, callee);
95
- // return ret;
96
- //
97
- // then the bug would be "fixed". This "fix" didn't work in release mode
98
- // however, leading to the current fix. For whatever reason it seems that
99
- // unwinding is broken if there's not code between the `body(...)` indirect
100
- // call and the function return. The `!` here below, inverting the return value,
101
- // is the source of that "code".
102
- //
103
- // Ideally this `*_inverted` shim would go away and get past CI. It's unclear
104
- // whether we're dealing with a miscompile in GCC, bad unwinding information
105
- // generated by Cranelift for JIT code, or what. For now "this seems to work"
106
- // but we'll also be in the process of forwarding this to some other Windows
107
- // folks to see better what's going on.
108
- static bool wasmtime_setjmp_inverted (void * * buf_storage ,
109
- bool (* body )(void * , void * ),
110
- void * payload , void * callee ) {
64
+ bool VERSIONED_SYMBOL (wasmtime_setjmp )(void * * buf_storage ,
65
+ bool (* body )(void * , void * ),
66
+ void * payload , void * callee ) {
111
67
platform_jmp_buf buf ;
112
68
if (platform_setjmp (buf ) != 0 ) {
113
- return true ;
69
+ return false ;
114
70
}
115
71
* buf_storage = & buf ;
116
- return !body (payload , callee );
117
- }
118
-
119
- bool VERSIONED_SYMBOL (wasmtime_setjmp )(void * * buf_storage ,
120
- bool (* body )(void * , void * ),
121
- void * payload , void * callee ) {
122
- return !wasmtime_setjmp_inverted (buf_storage , body , payload , callee );
72
+ return body (payload , callee );
123
73
}
124
74
125
75
void VERSIONED_SYMBOL (wasmtime_longjmp )(void * JmpBuf ) {
0 commit comments