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

ms-vscode.cpptools fails with Error: EROFS: read-only file system, chmod #311425

Closed
kjeremy opened this issue May 13, 2024 · 6 comments · Fixed by #314009
Closed

ms-vscode.cpptools fails with Error: EROFS: read-only file system, chmod #311425

kjeremy opened this issue May 13, 2024 · 6 comments · Fixed by #314009
Labels
0.kind: bug Something is broken

Comments

@kjeremy
Copy link
Contributor

kjeremy commented May 13, 2024

Describe the bug

Open a C++ project in vscode with the ms-vscode.cpptools extension installed and see the following in the Extension Host output window:

2024-05-13 13:47:33.703 [error] Activating extension ms-vscode.cpptools failed due to an error:
2024-05-13 13:47:33.703 [error] Error: EROFS: read-only file system, chmod '/nix/store/3zygrdic6q4wg40lmlb3gbffrgncvdv7-vscode-extensions/share/vscode/extensions/ms-vscode.cpptools/bin/libc.so'

Steps To Reproduce

Steps to reproduce the behavior:

  1. Open a C++ project in vscode with the cpptools extension installed
  2. Notice how autocompletion etc. features do not activate.
  3. Go to the output window and select the Extension Host and you will see the following:

[error] Error: EROFS: read-only file system, chmod '/nix/store/3zygrdic6q4wg40lmlb3gbffrgncvdv7-vscode-extensions/share/vscode/extensions/ms-vscode.cpptools/bin/libc.so'

Expected behavior

The extension should work

Screenshots

image

Additional context

Add any other context about the problem here.

Notify maintainers

@jraygauthier
@StarGate01

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.6.29, NixOS, 24.05 (Uakari), 24.05.20240502.63c3a29`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.22.0`
 - channels(root): `"nixos"`
 - channels(jkolb): `""`
 - nixpkgs: `/nix/store/p69bcs7ma6ijj8v9xsrg3nq3nn8ryn95-source`

Add a 👍 reaction to issues you find important.

@kjeremy kjeremy added the 0.kind: bug Something is broken label May 13, 2024
@kjeremy
Copy link
Contributor Author

kjeremy commented May 13, 2024

I'm wondering if that libc.so should be 0555 instead of 0444.

@kjeremy
Copy link
Contributor Author

kjeremy commented May 13, 2024

Adding chmod +x $out/share/vscode/extensions/ms-vscode.cpptools/bin/libc.so to postFixup got me around this particular issue but now I'm running into microsoft/vscode-cpptools#12237 which should be resolved by moving to 1.20.5

@kjeremy
Copy link
Contributor Author

kjeremy commented May 14, 2024

Moving to 1.20.5 doesn't fix the startup issue

@kjeremy
Copy link
Contributor Author

kjeremy commented May 20, 2024

@JohnRTitor I'm replying to your comment here #311695 (comment)

I can reproduce this with the following:

[jkolb@nixos:~/blah]$ nix flake init --template "github:nixvital/flake-templates#cpp-starter-kit"
[jkolb@nixos:~/blah]$ code .

Attached is the flake I end up with.
blah.tar.gz

My system packages are the following:

environment.systemPackages = with pkgs; [
    cntr # Use with breakpointHook for nixpkg debugging
    #cmake
    direnv
    nix-diff
    nix-direnv
    docker-compose
    gdb
    #(gdb.override { enableDebuginfod = true; })
    gitFull
    gnumake
    graphviz xdot
    htop
    lldb
    nix-output-monitor
    pkg-config
    ripgrep
    nil
    rustup
    zip
    wget
    firefox
    wl-clipboard
    (vscode-with-extensions.override {
      vscodeExtensions = with vscode-extensions; [
#        jnoortheen.nix-ide
#	vadimcn.vscode-lldb
#        ms-python.python
#        ms-azuretools.vscode-docker
#        ms-vscode-remote.remote-ssh
        #xaver.clang-format
#        ms-vscode.cmake-tools
        ms-vscode.cpptools
#	ms-vscode.hexeditor
        #arrterian.nix-env-selector
#        rust-lang.rust-analyzer
      ];
    })
  ];

@kjeremy
Copy link
Contributor Author

kjeremy commented May 22, 2024

After changing the permission of libc.so this is what I get:

[nix-shell:~/nixpkgs]$ strace ./result/share/vscode/extensions/ms-vscode.cpptools/bin/cpptools-srv 
execve("./result/share/vscode/extensions/ms-vscode.cpptools/bin/cpptools-srv", ["./result/share/vscode/extensions"...], 0x7ffc03370bc0 /* 146 vars */) = 0
brk(NULL)                               = 0x15e2000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fdd7a26d000
readlinkat(AT_FDCWD, "/proc/self/exe", "/nix/store/qsmy2dq2mnl1wfp2h414z"..., 4096) = 146
access("/etc/ld-nix.so.preload", R_OK)  = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/qsmy2dq2mnl1wfp2h414zsiyrhcay6b5-vscode-extension-ms-vscode-cpptools-1.20.5/share/vscode/extensions/ms-vscode.cpptools/bin/glibc-hwcaps/x86-64-v3/libc.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/nix/store/qsmy2dq2mnl1wfp2h414zsiyrhcay6b5-vscode-extension-ms-vscode-cpptools-1.20.5/share/vscode/extensions/ms-vscode.cpptools/bin/glibc-hwcaps/x86-64-v3/", 0x7ffff4ed4800, 0) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/qsmy2dq2mnl1wfp2h414zsiyrhcay6b5-vscode-extension-ms-vscode-cpptools-1.20.5/share/vscode/extensions/ms-vscode.cpptools/bin/glibc-hwcaps/x86-64-v2/libc.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/nix/store/qsmy2dq2mnl1wfp2h414zsiyrhcay6b5-vscode-extension-ms-vscode-cpptools-1.20.5/share/vscode/extensions/ms-vscode.cpptools/bin/glibc-hwcaps/x86-64-v2/", 0x7ffff4ed4800, 0) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/qsmy2dq2mnl1wfp2h414zsiyrhcay6b5-vscode-extension-ms-vscode-cpptools-1.20.5/share/vscode/extensions/ms-vscode.cpptools/bin/libc.so", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\233\305\5\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0555, st_size=835064, ...}) = 0
mmap(NULL, 708832, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fdd7a1bf000
mmap(0x7fdd7a268000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xa8000) = 0x7fdd7a268000
mmap(0x7fdd7a26a000, 8416, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fdd7a26a000
close(3)                                = 0
arch_prctl(ARCH_SET_FS, 0x7fdd7a26e380) = 0
set_tid_address(0x7fdd7a26e650)         = 17337
set_robust_list(0x7fdd7a26e660, 24)     = 0
rseq(0x7fdd7a26eca0, 0x20, 0, 0x53053053) = 0
mprotect(0x7fdd7a268000, 4096, PROT_READ) = 0
mprotect(0x1027000, 36864, PROT_READ)   = 0
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=NULL} ---
+++ killed by SIGSEGV (core dumped) +++
Segmentation fault (core dumped)

If instead I run cpptool-srv through libc.so manually I make some progress (it's looking for .conan/ in my home directory) and it exits.

[nix-shell:~/nixpkgs]$ strace ./result/share/vscode/extensions/ms-vscode.cpptools/bin/libc.so ./result/share/vscode/extensions/ms-vscode.cpptools/bin/cpptools-srv /home/jkolb/blah/
execve("./result/share/vscode/extensions/ms-vscode.cpptools/bin/libc.so", ["./result/share/vscode/extensions"..., "./result/share/vscode/extensions"..., "/home/jkolb/blah/"], 0x7ffe307d1500 /* 146 vars */) = 0
arch_prctl(ARCH_SET_FS, 0x7fd3c10acb88) = 0
set_tid_address(0x7fd3c10acff8)         = 19664
open("./result/share/vscode/extensions/ms-vscode.cpptools/bin/cpptools-srv", O_RDONLY|O_LARGEFILE) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\2\0>\0\1\0\0\0\376qd\0\0\0\0\0"..., 960) = 960
mmap(0x3ff000, 17502208, PROT_READ|PROT_WRITE, MAP_PRIVATE, 3, 0) = 0x3ff000
mmap(0x400000, 12742656, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0x1000) = 0x400000
mmap(0x1027000, 4755456, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0xc27000) = 0x1027000
mmap(0x108c000, 4341760, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x108c000
close(3)                                = 0
brk(NULL)                               = 0x555557156000
brk(0x555557158000)                     = 0x555557158000
mmap(0x555557156000, 4096, PROT_NONE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x555557156000
mprotect(0x7fd3c10a9000, 4096, PROT_READ) = 0
mprotect(0x1027000, 36864, PROT_READ)   = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd3c0fff000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd3c0ffe000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd3c0ffd000
sched_getaffinity(0, 128, [0 1 2 3])    = 16
rt_sigprocmask(SIG_UNBLOCK, [RT_1 RT_2], NULL, 8) = 0
membarrier(MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED, 0) = 0
mmap(NULL, 1060864, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd3c0efa000
mprotect(0x7fd3c0efc000, 1052672, PROT_READ|PROT_WRITE) = 0
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0
clone(child_stack=0x7fd3c0ffcac8, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|0x400000, parent_tid=[19665], tls=0x7fd3c0ffcb38, child_tidptr=0x7fd3c10acff8) = 19665
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd3c0ef9000
mmap(NULL, 1060864, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd3c0df6000
mprotect(0x7fd3c0df8000, 1052672, PROT_READ|PROT_WRITE) = 0
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0
clone(child_stack=0x7fd3c0ef8ac8, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|0x400000, parent_tid=[19666], tls=0x7fd3c0ef8b38, child_tidptr=0x7fd3c10acff8) = 19666
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
mmap(NULL, 1060864, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd3c0cf3000
mprotect(0x7fd3c0cf5000, 1052672, PROT_READ|PROT_WRITE) = 0
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0
clone(child_stack=0x7fd3c0df5ac8, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|0x400000, parent_tid=[19667], tls=0x7fd3c0df5b38, child_tidptr=0x7fd3c10acff8) = 19667
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
mmap(NULL, 1060864, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd3c0bf0000
mprotect(0x7fd3c0bf2000, 1052672, PROT_READ|PROT_WRITE) = 0
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0
clone(child_stack=0x7fd3c0cf2ac8, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|0x400000, parent_tid=[19668], tls=0x7fd3c0cf2b38, child_tidptr=0x7fd3c10acff8) = 19668
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
futex(0x14a1934, FUTEX_WAKE_PRIVATE, 1) = 1
mmap(NULL, 1060864, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd3c0aed000
mprotect(0x7fd3c0aef000, 1052672, PROT_READ|PROT_WRITE) = 0
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0
clone(child_stack=0x7fd3c0befac8, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|0x400000, parent_tid=[19669], tls=0x7fd3c0befb38, child_tidptr=0x7fd3c10acff8) = 19669
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
mmap(NULL, 73728, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd3c0adb000
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7fd3c104af2a}, NULL, 8) = 0
open("/dev/null", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 3
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd3c0ada000
ioctl(3, TIOCGWINSZ, 0x7ffe27a18bc8)    = -1 ENOTTY (Inappropriate ioctl for device)
dup2(3, 2)                              = 2
close(3)                                = 0
munmap(0x7fd3c0ada000, 4096)            = 0
stat("/home/jkolb/.conan", 0x7ffe27a179d0) = -1 ENOENT (No such file or directory)
futex(0x7fd3c0ffc974, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x14a1934, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x7ffe27a18c24, FUTEX_WAIT_PRIVATE, 2, NULL) = 0
munmap(0x7fd3c0aed000, 1060864)         = 0
munmap(0x7fd3c0ef9000, 4096)            = 0
exit_group(1)                           = ?
+++ exited with 1 +++

@kjeremy
Copy link
Contributor Author

kjeremy commented May 22, 2024

This is most likely #94228

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant