Skip to content

Weird __proxy stripping for arrow functions #20264

@RReverser

Description

@RReverser

Please include the following in your bug report:

Version of emscripten/emsdk:

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.46-git (19607820c447a13fd8d0b7680c56148427d6e1b8)
clang version 18.0.0 (https://github.com/llvm/llvm-project d2ab97b00ce702006f7b1098e3530094759c8841)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /home/rreverser/emsdk/upstream/bin

Failing command line in full:

emcc test.c --js-library test-lib.js -pthread -s PROXY_TO_PTHREAD

test.c:

extern void foobar();

int main() {
	foobar();
}

test-lib.js:

addToLibrary({
	foobar: () => setTimeout(() => {
		console.log('hello from main thread');
	}, 1000),
	foobar__proxy: 'sync',
});

For some reason arrow functions wrapped like this (whether it's setTimeout, Asyncify.handleSleep or anything else) get quietly unwrapped in the output so it becomes:

  function _foobar() {
  if (ENVIRONMENT_IS_PTHREAD)
    return proxyToMainThread(4, 1);
  
  		console.log('hello from main thread');
  	
  }

Which, of course, behaves very differently in weird ways in runtime.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions