Skip to content

WebAssembly.LinkError caused by enabling ALLOW_TABLE_GROWTH without RESERVED_FUNCTION_POINTERS #8003

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

Closed
AlexAltea opened this issue Feb 4, 2019 · 2 comments
Labels

Comments

@AlexAltea
Copy link

AlexAltea commented Feb 4, 2019

Commit b472d78 introduced ALLOW_TABLE_GROWTH, which is extremely useful when it comes to dynamic linking and JIT-compiling modules, e.g. #7082 (comment).

With the latest incoming revision, it seems that ALLOW_TABLE_GROWTH requires a non-zero value in RESERVED_FUNCTION_POINTERS. This seems counter-intuitive to me: Unlike in asm.js, we should have no need to reserve in advance a fixed array of function pointers.

Example:

$ cat demo.c
#include <stdio.h>
int main() { printf("Hello!\n"); return 0; }

$ emcc demo.c -s ALLOW_TABLE_GROWTH=1 -s RESERVED_FUNCTION_POINTERS=1 -o demo.js && node demo.js
Hello!

$ emcc demo.c -s ALLOW_TABLE_GROWTH=1 -s RESERVED_FUNCTION_POINTERS=0 -o demo.js && node demo.js
failed to asynchronously prepare wasm: LinkError: WebAssembly Instantiation: table import 21 has no maximum length, expected 10
[...]

$ emcc demo.c -s ALLOW_TABLE_GROWTH=1 -o demo.js && node demo.js
failed to asynchronously prepare wasm: LinkError: WebAssembly Instantiation: table import 21 has no maximum length, expected 10
[...]
@kripken
Copy link
Member

kripken commented Feb 5, 2019

I think the problem here is that with asm2wasm we don't know the size of the function table, not until asm2wasm happens, which is after we emit the JS.

This is not a problem with the LLVM wasm backend, so going forward this will go away anyhow. You may want to already use it now, btw, if it fixes this issue for you - it's getting close to being the default anyhow.

@stale
Copy link

stale bot commented Feb 5, 2020

This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 7 days. Feel free to re-open at any time if this issue is still relevant.

@stale stale bot added the wontfix label Feb 5, 2020
@stale stale bot closed this as completed Feb 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants