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

calling error function on a luau vm causes the ran thread to throw error even when pcalled #6

Open
jLn0n opened this issue Sep 7, 2024 · 2 comments

Comments

@jLn0n
Copy link

jLn0n commented Sep 7, 2024

expected behavior:

  • the ran source will just run fine with output result being false [string "skibidi"]:2: mafakas

actual behavior:
image
luau vm gets halted since _emscripten_throw_longjmp is called internally and the implementation of that said function just errors "Infinity"

temporary workaround:

  • use Fiu as luau VM (I don't want to do that)

using 0.640 of luauception

@jLn0n
Copy link
Author

jLn0n commented Sep 8, 2024

also tried on these versions:

  • 0.631 - failed
  • 0.630 - failed
  • 0.628 - failed

did not try the rest of the versions since VM doesn't work there

@jLn0n jLn0n changed the title calling error function on a luau sandbox causes the ran thread to halt calling error function on a luau vm causes the ran thread to throw error Sep 8, 2024
@jLn0n jLn0n changed the title calling error function on a luau vm causes the ran thread to throw error calling error function on a luau vm causes the ran thread to throw error even when pcalled Sep 8, 2024
@davidkra230
Copy link

davidkra230 commented Dec 30, 2024

This appears to be error handling related or a lack thereof.

Perhaps looking into this would guide you in the right direction.

Though Wasynth doesn't like it when adding the -fwasm-exceptions -sSUPPORT_LONGJMP=wasm flags (It doesn't know how to translate the Throw instruction),
And manually emulating it in Luau like how emscripten does it with JavaScript could be too time-consuming to implement (You can give it a shot by using the -fexceptions -sSUPPORT_LONGJMP=emscripten flags).

To needlessly repeat myself, the original problem could be solved in two ways:

  1. By Wasynth implementing the Throw instruction, and the -fwasm-exceptions -sSUPPORT_LONGJMP=wasm flags being added to compilation and linking.
  2. By using the -fexceptions -sSUPPORT_LONGJMP=emscripten flags and looking at how the .js and .wasm normally communicate and re-implement that in Luau like how _setitimer_js or _localtime_js was implemented (the related functions could be: __cxa_begin_catch, __cxa_end_catch, __cxa_find_matching_catch_*, and __resumeException).

However, you should take this all with a grain of salt, and do some testing of your own - I'm pretty clueless too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants