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

Using Node.js 20, rake npm:ruby-head-wasm-wasi:check does not work #314

Open
ledsun opened this issue Nov 22, 2023 · 7 comments
Open

Using Node.js 20, rake npm:ruby-head-wasm-wasi:check does not work #314

ledsun opened this issue Nov 22, 2023 · 7 comments

Comments

@ledsun
Copy link
Contributor

ledsun commented Nov 22, 2023

What happened.

I installed Node.js 20.8.0 and ran rake npm:ruby-head-wasm-wasi:check and got the following error:

►rake npm:ruby-head-wasm-wasi:check
npm test

> ruby-head-wasm-wasi@2.2.0 test
> RUBY_NPM_PACKAGE_ROOT=../ruby-head-wasm-wasi npm -C ../ruby-wasm-wasi run test:run


> @ruby/wasm-wasi@2.2.0 test:run
> npm run test:unit && npm run test:jest && npm run test:e2e


> @ruby/wasm-wasi@2.2.0 test:unit
> ./tools/run-test-unit.mjs

(node:66391) ExperimentalWarning: WASI is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
node:internal/errors:497
    ErrorCaptureStackTrace(err);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "options.version" property must be of type string. Received undefined
    at new NodeError (node:internal/errors:406:5)
    at validateString (node:internal/validators:162:11)
    at new WASI (node:wasi:51:5)
    at instantiateNodeWasi (file:///home/ledsun/ruby.wasm/packages/npm-packages/ruby-wasm-wasi/tools/run-test-unit.mjs:30:16)
    at async test (file:///home/ledsun/ruby.wasm/packages/npm-packages/ruby-wasm-wasi/tools/run-test-unit.mjs:128:24)
    at async main (file:///home/ledsun/ruby.wasm/packages/npm-packages/ruby-wasm-wasi/tools/run-test-unit.mjs:162:3) {
  code: 'ERR_INVALID_ARG_TYPE'
}

Node.js v20.8.0
npm ERR! Lifecycle script `test:unit` failed with error:
npm ERR! Error: command failed
npm ERR!   in workspace: @ruby/wasm-wasi@2.2.0
npm ERR!   at location: /home/ledsun/ruby.wasm/packages/npm-packages/ruby-wasm-wasi
npm ERR! Lifecycle script `test` failed with error:
npm ERR! Error: command failed
npm ERR!   in workspace: ruby-head-wasm-wasi@2.2.0
npm ERR!   at location: /home/ledsun/ruby.wasm/packages/npm-packages/ruby-head-wasm-wasi
rake aborted!
Command failed with status (1): [npm test]
/home/ledsun/ruby.wasm/tasks/packaging.rake:21:in `block (4 levels) in <top (required)>'
Tasks: TOP => npm:ruby-head-wasm-wasi:check
(See full trace by running task with --trace)

It worked fine using Node.js 18.8.2.

What I tried

Added version property to the argument of the WASI constructor.

const wasi = new nodeWasi.WASI({
stdio: "inherit",
args: ["ruby.wasm"].concat(process.argv.slice(2)),
env: {
...process.env,
// Extend fiber stack size to be able to run test-unit
"RUBY_FIBER_MACHINE_STACK_SIZE": String(1024 * 1024 * 20),
},
preopens,
});

I have tried both unstable and preview1 according to https://nodejs.org/docs/latest-v20.x/api/wasi.html.
The test ended with a Segmentation fault.

ledsun@MSI:~/ruby.wasm►rake npm:ruby-head-wasm-wasi:check
npm test

> ruby-head-wasm-wasi@2.2.0 test
> RUBY_NPM_PACKAGE_ROOT=../ruby-head-wasm-wasi npm -C ../ruby-wasm-wasi run test:run


> @ruby/wasm-wasi@2.2.0 test:run
> npm run test:unit && npm run test:jest && npm run test:e2e


> @ruby/wasm-wasi@2.2.0 test:unit
> ./tools/run-test-unit.mjs

(node:68755) ExperimentalWarning: WASI is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
Ignoring debug-1.8.0 because its extensions are not built. Try: gem pristine debug --version 1.8.0
Ignoring racc-1.7.3 because its extensions are not built. Try: gem pristine racc --version 1.7.3
Ignoring rbs-3.3.2 because its extensions are not built. Try: gem pristine rbs --version 3.3.2
Loaded suite /__root__/test/test_unit
Started
Segmentation fault
npm ERR! Lifecycle script `test:unit` failed with error:
npm ERR! Error: command failed
npm ERR!   in workspace: @ruby/wasm-wasi@2.2.0
npm ERR!   at location: /home/ledsun/ruby.wasm/packages/npm-packages/ruby-wasm-wasi
npm ERR! Lifecycle script `test` failed with error:
npm ERR! Error: command failed
npm ERR!   in workspace: ruby-head-wasm-wasi@2.2.0
npm ERR!   at location: /home/ledsun/ruby.wasm/packages/npm-packages/ruby-head-wasm-wasi
rake aborted!
Command failed with status (1): [npm test]
/home/ledsun/ruby.wasm/tasks/packaging.rake:21:in `block (4 levels) in <top (required)>'
Tasks: TOP => npm:ruby-head-wasm-wasi:check
(See full trace by running task with --trace)
@kateinoigakukun
Copy link
Member

From my bisect, it looks like there should be something wrong in Node.js v19.3.0...v19.4.0.

Here is the detailed backtrace for the segmentation fault.

$ RUBY_NPM_PACKAGE_ROOT=../ruby-head-wasm-wasi ./tools/run-test-unit.mjs
(node:3296220) ExperimentalWarning: WASI is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)


#
# Fatal error in , line 0
# unreachable code
#
#
#
#FailureMessage Object: 0x7ffd18712500
 1: 0xd15331  [node]
 2: 0x20ef531 V8_Fatal(char const*, ...) [node]
 3: 0x1120796 v8::internal::MarkCompactCollector::ProcessMarkingWorklist(unsigned long, v8::internal::MarkCompactCollector::MarkingWorklistProcessingMode) [node]
 4: 0x11231f2 v8::internal::MarkCompactCollector::ProcessEphemerons() [node]
 5: 0x11234a9 v8::internal::MarkCompactCollector::MarkTransitiveClosureUntilFixpoint() [node]
 6: 0x11243e8 v8::internal::MarkCompactCollector::MarkTransitiveClosure() [node]
 7: 0x112f996 v8::internal::MarkCompactCollector::MarkLiveObjects() [node]
 8: 0x11343d2 v8::internal::MarkCompactCollector::CollectGarbage() [node]
 9: 0x10e2306 v8::internal::Heap::MarkCompact() [node]
10: 0x10e795d v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::internal::GarbageCollectionReason, char const*) [node]
11: 0x10e7e4c v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
12: 0x10e8b6a v8::internal::Heap::FinalizeIncrementalMarkingIfComplete(v8::internal::GarbageCollectionReason) [node]
13: 0x10e8747 v8::internal::Heap::ReportExternalMemoryPressure() [node]
14: 0xed6be2 v8::Isolate::AdjustAmountOfExternalAllocatedMemory(long) [node]
15: 0x123ccca v8::internal::BackingStore::GrowWasmMemoryInPlace(v8::internal::Isolate*, unsigned long, unsigned long) [node]
16: 0x17a64d0 v8::internal::WasmMemoryObject::Grow(v8::internal::Isolate*, v8::internal::Handle<v8::internal::WasmMemoryObject>, unsigned int) [node]
17: 0x1633aeb v8::internal::Runtime_WasmMemoryGrow(int, unsigned long*, v8::internal::Isolate*) [node]
18: 0x1930ef6  [node]
zsh: trace trap  RUBY_NPM_PACKAGE_ROOT=../ruby-head-wasm-wasi ./tools/run-test-unit.mjs

@terrablue
Copy link
Contributor

I can confirm this doesn't work with Node.js 21 either. By the way, the fix to https://github.com/ruby/ruby.wasm/blob/main/packages/npm-packages/ruby-wasm-wasi/tools/run-test-unit.mjs#L30 (adding { version: "preview1" }) can be done independently of that. Should I send a PR?

@kateinoigakukun
Copy link
Member

@terrablue Yes, that would be helpful :)

@terrablue
Copy link
Contributor

@kateinoigakukun is it possible to run at least part of the tests or isolate this problem down to a particular test? I would like to start contributing, but it's hard to know if I'm introducing regressions otherwise.

@kateinoigakukun
Copy link
Member

kateinoigakukun commented Dec 16, 2023

I think the easiest way at this time is just using Node.js older than 19. Or you can find how to execute a part of test suites by checking rake outputs.

@ralyodio
Copy link

we are using node 20 LTS in production.

@kateinoigakukun
Copy link
Member

I suspect nodejs/node#43697 includes something wrong

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

No branches or pull requests

4 participants