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

Add a way to configure WASM plugin runtime (wasmi) stack size #3987

Open
mainrs opened this issue Apr 23, 2024 · 5 comments
Open

Add a way to configure WASM plugin runtime (wasmi) stack size #3987

mainrs opened this issue Apr 23, 2024 · 5 comments
Labels
feature request New feature or request

Comments

@mainrs
Copy link

mainrs commented Apr 23, 2024

Description

Either as a CLI flag that I can set for the current compiler invocation or as a permanent configuration (if that is possible with typst).

Use Case

I am developing a WASM plugin and every time I use/execute it, I get a plugin error: call stack exhausted error. I think it is because the WASM runtime has a stack limit that I exceed. It is hard to

References

#3985

@mainrs mainrs added the feature request New feature or request label Apr 23, 2024
@istudyatuni
Copy link
Contributor

If I understand it correctly, stack size is pretty big (second argument)

stacker::maybe_grow(32 * 1024, 2 * 1024 * 1024, f)

This message means that you have deep recursion (probably infinite), or something like that

@mainrs
Copy link
Author

mainrs commented Apr 23, 2024

This message means that you have deep recursion (probably infinite), or something like that

If that was the case, wouldn't the same code running on a normal Linux host fail too? If I execute the program as-is by adding a main function that calls my WASM library function, I do not have any problems.

@mainrs
Copy link
Author

mainrs commented Apr 23, 2024

I could narrow the issue down to a call into tree-sitter:

https://github.com/shadaj/tree-sitter-c2rust/blob/1205f15c2112979cf058a0f6dd7c6213524a6204/lib/binding_rust/lib.rs#L441C1-L448C6

However, I have no idea why this causes the above-mentioned issue when running as a WASM library. The Linux version works perfectly fine.

@istudyatuni
Copy link
Contributor

wouldn't the same code running on a normal Linux host fail too?

That makes sense

@laurmaedje
Copy link
Member

laurmaedje commented Apr 29, 2024

If I understand it correctly, stack size is pretty big (second argument) ...

This stack size applies to the compiler itself, not the WASM plugin executor.

I'm honestly not sure whether the stack size is in control of wasmi or if the WASM file itself can also specify something (I think it can). To debug this, it would be great if you could provide a minimal reproducible example.

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

No branches or pull requests

3 participants