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

JSPI and dynamic linking messed up by stub trampoline #23395

Open
hoodmane opened this issue Jan 14, 2025 · 1 comment · May be fixed by #23619
Open

JSPI and dynamic linking messed up by stub trampoline #23395

hoodmane opened this issue Jan 14, 2025 · 1 comment · May be fixed by #23619
Labels

Comments

@hoodmane
Copy link
Collaborator

The dynamic linking code will generate a stub if it's not resolved when first imported:

          // Return a stub function that will resolve the symbol
          // when first called.
          if (!(prop in stubs)) {
            var resolved;
            stubs[prop] = (...args) => {
              resolved ||= resolveSymbol(prop);
              return resolved(...args);
            };
          }

https://github.com/emscripten-core/emscripten/blob/main/src/library_dylink.js?plain=1#L724-L727
This causes trouble when mixed with stack switching. Working around it will be a bit convoluted, but it should be possible with a little helper wasm module.

@hoodmane
Copy link
Collaborator Author

hoodmane commented Feb 3, 2025

With experimental-wasm-type-reflection this can be dealt with by looking at WebAssembly.Module.imports. Otherwise, we have to hope that we've been asked to compile a buffer and then we can parse the import types out of the buffer.

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

Successfully merging a pull request may close this issue.

2 participants