Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require in metamethod causes a panic #262

Open
SnorlaxAssist opened this issue Oct 1, 2024 · 2 comments · May be fixed by #247
Open

Require in metamethod causes a panic #262

SnorlaxAssist opened this issue Oct 1, 2024 · 2 comments · May be fixed by #247
Labels
bug Something isn't working

Comments

@SnorlaxAssist
Copy link
Contributor

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.
@CompeyDev
Copy link
Contributor

What I noticed is that not wrapping the require within a function for the metamethod seems to behave normally. Interesting...

@filiptibell filiptibell added the bug Something isn't working label Oct 15, 2024
@filiptibell
Copy link
Collaborator

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

@FlowGnarly FlowGnarly linked a pull request Dec 2, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants