Skip to content

Emscripten pthread-based WASM module fails to initialize in Bun while working in Node #29211

@kevgeoleo

Description

@kevgeoleo

What version of Bun is running?

1.3.11-canary.1+9e93bfa1b

What platform is your computer?

Linux 5.10.0-12-amd64 x86_64 x86_64

What steps can reproduce the bug?

Hi,

I would like to report a behavior in Bun that can be reproduced using the below snippet:

import { init } from "z3-solver";

const { Context } = await init();
const { Solver, Int, And } = new Context("main");

const x = Int.const("x");

const solver = new Solver();
solver.add(And(x.ge(0), x.le(9)));

// This call should complete without throwing, printing a satisfiability result such as `sat`.
console.log(await solver.check());

What is the expected behavior?

Work without throwing Assertion error

root@KContainer:~/17171# node poc.mjs
sat

What do you see instead?

root@KContainer:~/17171# bun run poc.mjs
Aborted(Assertion failed)
worker: onmessage() captured an uncaught exception: RuntimeError: Aborted(Assertion failed)
RuntimeError: Aborted(Assertion failed)
    at abort (/home/c01kele/node_modules/z3-solver/build/z3-built.js:848:27)
    at assert (/home/c01kele/node_modules/z3-solver/build/z3-built.js:396:5)
    at removeRunDependency (/home/c01kele/node_modules/z3-solver/build/z3-built.js:805:5)
    at receiveInstance (/home/c01kele/node_modules/z3-solver/build/z3-built.js:1019:5)
    at wasmModuleReceived (/home/c01kele/node_modules/z3-solver/build/z3-built.js:1062:9)
    at handleMessage (/home/c01kele/node_modules/z3-solver/build/z3-built.js:539:9)
Pthread 0x01d1d0e8 sent an error! undefined:undefined: Aborted(Assertion failed)
1616 |           var message = 'worker sent an error!';
1617 |           if (worker.pthread_ptr) {
1618 |             message = `Pthread ${ptrToString(worker.pthread_ptr)} sent an error!`;
1619 |           }
1620 |           err(`${message} ${e.filename}:${e.lineno}: ${e.message}`);
1621 |           throw e;
                       ^
error: Aborted(Assertion failed)
      at <anonymous> (/home/c01kele/node_modules/z3-solver/build/z3-built.js:1621:17)
      at <anonymous> (/home/c01kele/node_modules/z3-solver/build/z3-built.js:1626:44)
      at emitError (node:events:43:23)
      at #onError (node:worker_threads:222:14)
^C

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions