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

msync() on anonymous mapping fails with TypeError: Cannot read property 'stream_ops' of undefined #16350

Closed
tiran opened this issue Feb 20, 2022 · 2 comments
Labels

Comments

@tiran
Copy link
Contributor

tiran commented Feb 20, 2022

Version of emscripten/emsdk:

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.2 (a77b559a8b40b7e89fc8c17e41034128df9543e4)
clang version 14.0.0 (https://github.com/llvm/llvm-project 782c0dd1a1c235afb09a34e7da4a1267ead14765)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /emsdk/upstream/bin

Failing command line in full:
Calling msync on an anonymous mmap results in a JS type error and abort. msync of an anonymous mappings is a no-op. It should verify the argument (address is multiple of page size, flags are correct) and return with an error.

#include <sys/mman.h>
#include <string.h>
#include <assert.h>

int main(void)
{
    size_t map_size = 1 << 16;

    void *map = mmap(NULL, map_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
    assert(map != MAP_FAILED);

    memset(map, 0, map_size);

    assert(msync(map, map_size, MS_SYNC) != -1);

    assert(munmap(map, map_size) != -1);
    return 0;
}
$ gcc -o msync msync.c && ./msync

$ emcc -sNODERAWFS -o msync.js msync.c && node msync.js
/python-wasm/cpython/builddir/msync.js:147
      throw ex;
      ^

TypeError: Cannot read property 'stream_ops' of undefined
    at Object.msync (/python-wasm/cpython/builddir/msync.js:2842:20)
    at Object.msync (/python-wasm/cpython/builddir/msync.js:4828:103)
    at Object.doMsync (/python-wasm/cpython/builddir/msync.js:4478:12)
    at ___syscall_msync (/python-wasm/cpython/builddir/msync.js:4611:16)
    at <anonymous>:wasm-function[12]:0x5bc
    at <anonymous>:wasm-function[6]:0x2fc
    at main (<anonymous>:wasm-function[7]:0x3b7)
    at /python-wasm/cpython/builddir/msync.js:1544:22
    at callMain (/python-wasm/cpython/builddir/msync.js:5191:15)
    at doRun (/python-wasm/cpython/builddir/msync.js:5248:23)

@kripken kripken added the wasmfs label Feb 22, 2022
@kripken
Copy link
Member

kripken commented Feb 22, 2022

Adding the wasmfs label here because if we don't get around to fixing this in the old FS, we may want to make sure the new FS fixes this before we enable it by default.

@sbc100
Copy link
Collaborator

sbc100 commented Feb 22, 2022

It looks like this is already fixed in 3.1.5 (I could reproduce in 3.1.4 but not in 3.1.5).

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

No branches or pull requests

3 participants