Skip to content

Commit 5d96ddc

Browse files
committed
Temporary fix for #71. Remove when rust #48251 is fixed in stable.
1 parent d799513 commit 5d96ddc

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

Cargo.toml

+15-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,21 @@ default = ["builtin-lua"]
1818
# specialized version of lua into your binary, you can disable this feature to
1919
# do that, but care must be taken. `rlua` makes at least the following
2020
# assumptions about the linked lua library:
21-
# * LUA_INTEGER is long long
22-
# * LUA_NUMBER as double
23-
# * LUA_EXTRASPACE is sizeof(void*)
24-
# * LUAI_MAXSTACK is 1000000
21+
# * LUA_INTEGER is long long
22+
# * LUA_NUMBER as double
23+
# * LUA_EXTRASPACE is sizeof(void*)
24+
# * LUAI_MAXSTACK is 1000000
25+
# * LUAI_THROW / LUAI_TRY are defined so that they are compatible with jumping
26+
# over Rust stack frames. Rust is, as of the discussion around
27+
# https://github.com/rust-lang/rust/issues/48251, intended to be compatible in
28+
# at least a limited way with C libraries that use setjmp / longjmp error
29+
# handling, but there are some caveats. The linked bug prevents calling into
30+
# C APIs which use setjmp / longjmp handling *at all* on windows with at least
31+
# the 1.24.0 version of the rust compiler, and it remains to be seen but
32+
# potentially the 1.24.1 and 1.25 versions as well. Eventually the fix for
33+
# this will make it into stable rust, but until then there is a fix in the
34+
# bundled version of Lua to use __intrinsic_setjmp on windows instead of
35+
# setjmp to avoid unwinding and triggering rust issue #48251.
2536
builtin-lua = ["gcc"]
2637

2738
[dependencies]

lua/luaconf.h

+9-3
Original file line numberDiff line numberDiff line change
@@ -775,9 +775,15 @@
775775
** without modifying the main part of the file.
776776
*/
777777

778-
779-
780-
778+
/*
779+
** rlua modification - fix for #71, temporary until the fix for
780+
** https://github.com/rust-lang/rust/issues/48251 is in stable rust
781+
*/
782+
#if defined(LUA_USE_WINDOWS)
783+
#define LUAI_THROW(L,c) longjmp((c)->b, 1)
784+
#define LUAI_TRY(L,c,a) if (__intrinsic_setjmp((c)->b, NULL) == 0) { a }
785+
#define luai_jmpbuf jmp_buf
786+
#endif
781787

782788
#endif
783789

0 commit comments

Comments
 (0)