Repository navigation
Open
Labels
Milestone
Description
Version of emscripten/emsdk:
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.24-git (6292601a59b6c23382e26a438c9ae3a6c3c4d3e8)
clang version 16.0.0 (https://github.com/llvm/llvm-project 69353e7c82f732ac7303fe94f9a6d527b1b221ab)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: C:\Users\kdots\.emsdk\upstream\bin
Failing command line in full:
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <cassert>
#include <stdio.h>
int main()
{
mkdir("test", S_IRUGO);
int fd = open("test/file", O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
perror("Error: ");
printf("errno - %d\n", errno);
printf("fd - %d\n", fd);
assert(errno == EACCES);
assert(fd < 0);
}
Full link command and output with -v appended:
C:\emscripten>em++ -v C:/build/test.cpp -o C:/build/test.html -s WASMFS=1
"C:/Users/kdots/.emsdk/upstream/bin\clang.exe" --version
"C:/Users/kdots/.emsdk/upstream/bin\clang++.exe" -target wasm32-unknown-emscripten -fignore-exceptions -fvisibility=default -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -DEMSCRIPTEN -IC:\emscripten\cache\sysroot\include\SDL --sysroot=C:\emscripten\cache\sysroot -Xclang -iwithsysroot/include\compat -v C:/build/test.cpp -c -o C:\Users\kdots\AppData\Local\Temp\emscripten_temp_itrpqa3s\test_0.o
clang version 16.0.0 (https://github.com/llvm/llvm-project 69353e7c82f732ac7303fe94f9a6d527b1b221ab)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: C:\Users\kdots\.emsdk\upstream\bin
(in-process)
"C:\\Users\\kdots\\.emsdk\\upstream\\bin\\clang++.exe" -cc1 -triple wasm32-unknown-emscripten -emit-obj -mrelax-all --mrelax-relocations -disable-free -clear-ast-before-backend -main-file-name test.cpp -mrelocation-model static -mframe-pointer=none -ffp-contract=on -fno-rounding-math -mconstructor-aliases -target-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -v "-fcoverage-compilation-dir=C:\\emscripten" -resource-dir "C:\\Users\\kdots\\.emsdk\\upstream\\lib\\clang\\16.0.0" -D EMSCRIPTEN -I "C:\\emscripten\\cache\\sysroot\\include\\SDL" -isysroot "C:\\emscripten\\cache\\sysroot" -internal-isystem "C:\\emscripten\\cache\\sysroot/include/wasm32-emscripten/c++/v1" -internal-isystem "C:\\emscripten\\cache\\sysroot/include/c++/v1" -internal-isystem "C:\\Users\\kdots\\.emsdk\\upstream\\lib\\clang\\16.0.0\\include" -internal-isystem "C:\\emscripten\\cache\\sysroot/include/wasm32-emscripten" -internal-isystem "C:\\emscripten\\cache\\sysroot/include" -fdeprecated-macro "-fdebug-compilation-dir=C:\\emscripten" -ferror-limit 19 -fmessage-length=167 -fvisibility=default -fgnuc-version=4.2.1 -fcxx-exceptions -fignore-exceptions -fexceptions -fcolor-diagnostics "-iwithsysroot/include\\compat" -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -o "C:\\Users\\kdots\\AppData\\Local\\Temp\\emscripten_temp_itrpqa3s\\test_0.o" -x c++ C:/build/test.cpp
clang -cc1 version 16.0.0 based upon LLVM 16.0.0git default target x86_64-pc-windows-msvc
ignoring nonexistent directory "C:\emscripten\cache\sysroot/include/wasm32-emscripten/c++/v1"
ignoring nonexistent directory "C:\emscripten\cache\sysroot/include/wasm32-emscripten"
#include "..." search starts here:
#include <...> search starts here:
C:\emscripten\cache\sysroot\include\SDL
C:\emscripten\cache\sysroot/include\compat
C:\emscripten\cache\sysroot/include/c++/v1
C:\Users\kdots\.emsdk\upstream\lib\clang\16.0.0\include
C:\emscripten\cache\sysroot/include
End of search list.
"C:/Users/kdots/.emsdk/upstream/bin\wasm-ld.exe" -o C:/build/test.wasm C:\Users\kdots\AppData\Local\Temp\emscripten_temp_itrpqa3s\test_0.o -LC:\emscripten\cache\sysroot\lib\wasm32-emscripten --whole-archive -lwasmfs-debug --no-whole-archive -lGL -lal -lhtml5 -lstubs-debug -lnoexit -lc-debug -ldlmalloc -lcompiler_rt -lc++-noexcept -lc++abi-debug-noexcept -lsockets -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --import-undefined --strip-debug --export-if-defined=main --export-if-defined=__start_em_asm --export-if-defined=__stop_em_asm --export-if-defined=__start_em_lib_deps --export-if-defined=__stop_em_lib_deps --export-if-defined=__start_em_js --export-if-defined=__stop_em_js --export-if-defined=__main_argc_argv --export-if-defined=fflush --export=emscripten_stack_get_end --export=emscripten_stack_get_free --export=emscripten_stack_get_base --export=emscripten_stack_init --export=_wasmfs_read_file --export=stackSave --export=stackRestore --export=stackAlloc --export=__wasm_call_ctors --export=__errno_location --export=__get_temp_ret --export=__set_temp_ret --export=malloc --export=free --export-table -z stack-size=5242880 --initial-memory=16777216 --no-entry --max-memory=16777216 --global-base=1024
"C:/Users/kdots/.emsdk/upstream\bin\wasm-emscripten-finalize" --dyncalls-i64 --pass-arg=legalize-js-interface-exported-helpers C:/build/test.wasm -o C:/build/test.wasm --detect-features
"C:/Users/kdots/.emsdk/node/14.18.2_64bit/bin/node.exe" C:\emscripten\src\compiler.js C:\Users\kdots\AppData\Local\Temp\tmpxffglsrr.json
"C:/Users/kdots/.emsdk/upstream/bin\llvm-objcopy.exe" C:/build/test.wasm C:/build/test.wasm --remove-section=.debug* --remove-section=producers
"C:/Users/kdots/.emsdk/node/14.18.2_64bit/bin/node.exe" C:\emscripten\tools\preprocessor.js C:\Users\kdots\AppData\Local\Temp\emscripten_temp_itrpqa3s\settings.js shell.html
Expected output (when building without wasmfs):
Error: : Permission denied
errno - 2
fd - -1
Actual output:
Error: : No error information
errno - 0
fd - 3
Aborted(Assertion failed: errno == EACCES, at: C:/build/test.cpp,14,main)
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsTodo
Activity
tlively commentedon Oct 11, 2022
I think the permissions checking is a bit spotty overall. There are probably other related bugs as well.
typedrat commentedon Oct 1, 2026
This still reproduces on 6.0.9. It's specific to file creation through
open(andmknod, which goes through the samedoOpen). In the same read-only directory,mkdirandunlinkalready fail withEACCES(renamehas the same check in the source), and the JS file system rejects all three calls the test makes.Version of emscripten/emsdk:
This is the 6.0.9 release tag as packaged by nixpkgs. nixpkgs builds it against its own LLVM 22.1.8, so there is no commit hash. Node.js v24.20.0, x86_64 Linux.
Test case (
create_perm.c):Failing command line in full (the same at
-O2):JS file system, for comparison:
Full compile and link output with
-vappended (cache and scratch paths shortened)Where:
doOpenhas// TODO: Check write permissions on the parent directory.where it creates the file (syscalls.cpp#L478).doMkdirdoes the check (syscalls.cpp#L634-L636), and so dounlink(#L873) andrename(#L1045).Suggested fix: the same check as
doMkdir.With this applied to 6.0.9, the test case matches the JS FS: