emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.59k stars 3.28k forks source link

Opening a JS based file with WASMFS hits unimplemented code #22262

Closed jonahgraham closed 1 month ago

jonahgraham commented 1 month ago

The unreachable is because we are trying to truncate the file (I fopened it in "w" mode). If I open in "a" mode so we don't truncate it works fine.

The truncating happens here:

https://github.com/emscripten-core/emscripten/blob/d72d7226f4733af8ff993dec70198cf09a24142d/system/lib/wasmfs/syscalls.cpp#L563-L564

_Originally posted by @jonahgraham in https://github.com/emscripten-core/emscripten/pull/22261#discussion_r1683665630_

jonahgraham commented 1 month ago

The test case added in #22261 can be modified to fail by changing the fopen from "a" to "w".

jonahgraham commented 1 month ago

Thanks @kripken for fixing this :-) And for all the reviews and merging on the related items.

kripken commented 1 month ago

Thanks for filing the issue, and the PRs!