lune
lune copied to clipboard
Require in metamethod causes a panic
trafficstars
Luau Source
script.luau
local mt = setmetatable({}, {
__index = function()
return require("./test")
end})
print(mt.test)
test.luau
return {}
Output
attempt to yield across metamethod/C-call boundary
[Stack Begin]
Script '[C]' - function 'yield'
Script '__mlua_async_poll', Line 16
Script 'require', Line 2
Script './script', Line 3
Script './script', Line 6
[Stack End]
thread 'main' panicked at /home/runner/work/lune/lune/crates/mlua-luau-scheduler/src/scheduler.rs:447:14:
cannot mutably borrow app data container
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at crates/mlua-luau-scheduler/src/scheduler.rs:460:22:
cannot mutably borrow app data container
stack backtrace:
0: 0x555d771f1204 - <unknown>
1: 0x555d76be934b - <unknown>
2: 0x555d771c433e - <unknown>
3: 0x555d771f2f39 - <unknown>
4: 0x555d771f288b - <unknown>
5: 0x555d771f3a93 - <unknown>
6: 0x555d771f327a - <unknown>
7: 0x555d771f3209 - <unknown>
8: 0x555d771f31f6 - <unknown>
9: 0x555d76b4e4a2 - <unknown>
10: 0x555d76fe6203 - <unknown>
11: 0x555d76c42c06 - <unknown>
12: 0x555d76c453c0 - <unknown>
13: 0x555d76c56453 - <unknown>
14: 0x555d76c74845 - <unknown>
15: 0x555d76c7e93a - <unknown>
16: 0x555d76c7ac91 - <unknown>
17: 0x555d76c7e5ed - <unknown>
18: 0x7ffacde3314e - __libc_start_call_main
19: 0x7ffacde33209 - __libc_start_main@@GLIBC_2.34
20: 0x555d76b6c155 - <unknown>
21: 0x0 - <unknown>
thread 'main' panicked at library/core/src/panicking.rs:227:5:
panic in a destructor during cleanup
thread caused non-unwinding panic. aborting.
What I noticed is that not wrapping the require within a function for the metamethod seems to behave normally. Interesting...
Labeling this as a bug since a panic is definitely not intended. require will not work inside a metamethod however since it is a yielding function (the file you call require on may have yields in its main body) and non-yielding require is not planned
Most likely fixed in https://github.com/lune-org/lune/commit/2e5b3bb5eb5356d15b341b46d1a3e2ecaa19ad1c , feel free to reopen after Lune 0.9.3 is out if you can still get it to happen