Repository: node
Issue: FATAL ERROR: v8::Object::GetAlignedPointerFromInternalField() Internal field out of bounds
Labels: wasi

### Version

v20.2.0

### Platform

Darwin foo.local 22.4.0 Darwin Kernel Version 22.4.0: Mon Mar  6 21:01:02 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T8112 arm64

### Subsystem

_No response_

### What steps will reproduce the bug?

No idea.
This is code I can not share and I don't understand the issue, so I can't create a reproduction.

I am fully aware how useful it is to have reproducible bug, but I really can not provide a reproduction in this case.

I will check internally if the code in question can be made open source so that I can share it.

### How often does it reproduce? Is there a required condition?

Intermittent.
Some runs work, others do not.

### What is the expected behavior? Why is that the expected behavior?

No Fatal error, segfaults or bus error

### What do you see instead?

These errors never happened before on node 18 or lower :

```
/Users/foo/.volta/tools/image/npm/9.6.7/bin/npm: line 10: 41074 Bus error: 10           node "$basedir/npm-cli.js" "$@"
```

```
/Users/foo/.volta/tools/image/npm/9.6.7/bin/npm: line 10: 41225 Segmentation fault: 11  node "$basedir/npm-cli.js" "$@"
```
```
FATAL ERROR: v8::Object::GetAlignedPointerFromInternalField() Internal field out of bounds
 1: 0x1048b214c node::Abort() [/Users/foo/.volta/tools/image/node/20.2.0/bin/node]
 2: 0x1048b2238 node::OOMErrorHandler(char const*, v8::OOMDetails const&) [/Users/foo/.volta/tools/image/node/20.2.0/bin/node]
 3: 0x104a4dfe8 v8::InternalFieldOK(v8::internal::Handle<v8::internal::JSReceiver>, int, char const*) [/Users/foo/.volta/tools/image/node/20.2.0/bin/node]
 4: 0x104a4e134 v8::Object::SlowGetAlignedPointerFromInternalField(int) [/Users/foo/.volta/tools/image/node/20.2.0/bin/node]
 5: 0x1049585fc node::wasi::WASI::WasiFunction<unsigned int (*)(node::wasi::WASI&, node::wasi::WasmMemory, unsigned int, unsigned int, unsigned int, unsigned int), &node::wasi::WASI::FdWrite(node::wasi::WASI&, node::wasi::WasmMemory, unsigned int, unsigned int, unsigned int, unsigned int), unsigned int, unsigned int, unsigned int, unsigned int, unsigned int>::FastCallback(v8::Local<v8::Object>, unsigned int, unsigned int, unsigned int, unsigned int, v8::FastApiCallbackOptions&) [/Users/foo/.volta/tools/image/node/20.2.0/bin/node]
 6: 0x16741f29c9cc 
 7: 0x16741f201e0c 
 8: 0x16741f21af40 
 9: 0x16741f200e90 
10: 0x16741f200ca8 
11: 0x16741f202344 
12: 0x16741f203c44 
13: 0x16741f1ff80c 
14: 0x16741f1fc608 
15: 0x16741f0c7a60 
16: 0x16741f0c6444 
17: 0x16741f0c6314 
18: 0x16741f0bf884 
19: 0x16741f0bf708 
20: 0x16741f0bf628 
21: 0x16741f0bef50 
22: 0x10531cf10 Builtins_GenericJSToWasmWrapper [/Users/foo/.volta/tools/image/node/20.2.0/bin/node]
23: 0x10a2dcb2c 
24: 0x10a38ef24 
25: 0x1052d3210 Builtins_AsyncFunctionAwaitResolveClosure [/Users/foo/.volta/tools/image/node/20.2.0/bin/node]
26: 0x105380fb8 Builtins_PromiseFulfillReactionJob [/Users/foo/.volta/tools/image/node/20.2.0/bin/node]
27: 0x1052c2b94 Builtins_RunMicrotasks [/Users/foo/.volta/tools/image/node/20.2.0/bin/node]
28: 0x10529a3f4 Builtins_JSRunMicrotasksEntry [/Users/foo/.volta/tools/image/node/20.2.0/bin/node]
29: 0x104b71124 v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [/Users/foo/.volta/tools/image/node/20.2.0/bin/node]
30: 0x104b71610 v8::internal::(anonymous namespace)::InvokeWithTryCatch(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [/Users/foo/.volta/tools/image/node/20.2.0/bin/node]
31: 0x104b717ec v8::internal::Execution::TryRunMicrotasks(v8::internal::Isolate*, v8::internal::MicrotaskQueue*) [/Users/foo/.volta/tools/image/node/20.2.0/bin/node]
32: 0x104b988a8 v8::internal::MicrotaskQueue::RunMicrotasks(v8::internal::Isolate*) [/Users/foo/.volta/tools/image/node/20.2.0/bin/node]
33: 0x104b99044 v8::internal::MicrotaskQueue::PerformCheckpoint(v8::Isolate*) [/Users/foo/.volta/tools/image/node/20.2.0/bin/node]
34: 0x1047e8c64 node::InternalCallbackScope::Close() [/Users/foo/.volta/tools/image/node/20.2.0/bin/node]
35: 0x1047e87c4 node::InternalCallbackScope::~InternalCallbackScope() [/Users/foo/.volta/tools/image/node/20.2.0/bin/node]
36: 0x1049114e8 node::PerIsolatePlatformData::RunForegroundTask(std::__1::unique_ptr<v8::Task, std::__1::default_delete<v8::Task>>) [/Users/foo/.volta/tools/image/node/20.2.0/bin/node]
37: 0x1049101fc node::PerIsolatePlatformData::FlushForegroundTasksInternal() [/Users/foo/.volta/tools/image/node/20.2.0/bin/node]
38: 0x10527a618 uv__async_io [/Users/foo/.volta/tools/image/node/20.2.0/bin/node]
39: 0x10528cbcc uv__io_poll [/Users/foo/.volta/tools/image/node/20.2.0/bin/node]
40: 0x10527aae8 uv_run [/Users/foo/.volta/tools/image/node/20.2.0/bin/node]
41: 0x1047e9754 node::SpinEventLoopInternal(node::Environment*) [/Users/foo/.volta/tools/image/node/20.2.0/bin/node]
42: 0x1048f0124 node::NodeMainInstance::Run() [/Users/foo/.volta/tools/image/node/20.2.0/bin/node]
43: 0x10487e44c node::LoadSnapshotDataAndRun(node::SnapshotData const**, node::InitializationResultImpl const*) [/Users/foo/.volta/tools/image/node/20.2.0/bin/node]
44: 0x10487e76c node::Start(int, char**) [/Users/foo/.volta/tools/image/node/20.2.0/bin/node]
45: 0x19b3e3f28 start [/usr/lib/dyld]
/Users/foo/.volta/tools/image/npm/9.6.7/bin/npm: line 10: 41361 Abort trap: 6           node "$basedir/npm-cli.js" "$@"
```

### Additional information

This is related to `WASI`