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

Unable to open terminal with linux arm and arm64 servers on qemu #172992

Closed
deepak1556 opened this issue Feb 1, 2023 · 5 comments · Fixed by #173090
Closed

Unable to open terminal with linux arm and arm64 servers on qemu #172992

deepak1556 opened this issue Feb 1, 2023 · 5 comments · Fixed by #173090
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders linux Issues with VS Code on Linux terminal-process Problems launching processes, managing ptys, exiting, process leaks, etc. verified Verification succeeded virtual-machine Issues related to virtualbox, parallels etc
Milestone

Comments

@deepak1556
Copy link
Contributor

Sanity testing 1.75 on linux servers following the steps at https://github.com/microsoft/vscode-remote-release/wiki/Sanity-Check-VS-Code-Servers#linux-platforms and attempting to open a terminal throws the following error.

Screenshot 2023-02-01 at 11 47 03

Issue is from the pty module, following snippet can trigger the error on any of the containers

> var ptyProcess = pty.spawn('bash', [], {cwd: process.env.HOME});
Unsupported ioctl: cmd=0x5441
Uncaught Error: chdir() failed: Not a directory
    at new UnixTerminal (/root/.vscode-server/bin/e8bf7514f31cef005c988b206c61948e56aab9cb/node_modules/node-pty/lib/unixTerminal.js:106:24)
    at Object.spawn (/root/.vscode-server/bin/e8bf7514f31cef005c988b206c61948e56aab9cb/node_modules/node-pty/lib/index.js:29:12)
@deepak1556 deepak1556 added bug Issue identified by VS Code Team member as probable bug candidate Issue identified as probable candidate for fixing in the next release labels Feb 1, 2023
@deepak1556 deepak1556 added this to the January 2023 milestone Feb 1, 2023
@deepak1556
Copy link
Contributor Author

deepak1556 commented Feb 1, 2023

The bug seems to be localized to qemu environment, if I open arm64 container from arm64 host the terminal launches fine inside the container.

@deepak1556 deepak1556 changed the title Unable to open terminal with linux arm and arm64 servers Unable to open terminal with linux arm and arm64 servers on qemu Feb 1, 2023
@bpasero bpasero removed the candidate Issue identified as probable candidate for fixing in the next release label Feb 1, 2023
@bpasero bpasero modified the milestones: January 2023, February 2023 Feb 1, 2023
@bpasero
Copy link
Member

bpasero commented Feb 1, 2023

Talked in standup to not take as candidate.

@deepak1556
Copy link
Contributor Author

I will try to sum-up my findings here:

  • The issue only affects when running on top of qemu
  • The way https://github.com/hypriot/qemu-register works is that it ships docker image with qemu built for certain architectures and during run it installs the qemu binaries as interpreters for the relevant architectures via the binfmt_misc kernel feature https://docs.kernel.org/admin-guide/binfmt-misc.html
  • The default behavior of binfmt_misc is to override the argv[0] with the full path to the binary that is being executed. For our case, the spawn-helper gets the following argv[] under qemu
["absolute-path-to-helper-binary", "uid_value", "gid_value"] -> see how `cwd` value at 0 is replaced
  • This affects our expected positional argument
  • Couple of solutions,
    (i) When launching the helper executable, always set an environment variable QEMU_ARGV0 set to the argv[0] value we expect in the child process. This would force qemu to use this as argv[0] in the child process.
    (ii) Alternatively, we align the argument array to have the first position as path to the program that is being executed since that is what is expected in the unix platforms. So we would basically launch the helper executable with the following arguments
["absolute-path-to-helper-binary", "cwd", "uid_value",....] -> see how we are explicitly passing the first argument as the program name

I am inclined to solution (ii) as it aligns with unix expectations and also avoids using any environment particular to a platform.

@deepak1556 deepak1556 added linux Issues with VS Code on Linux terminal-process Problems launching processes, managing ptys, exiting, process leaks, etc. virtual-machine Issues related to virtualbox, parallels etc labels Feb 1, 2023
@VSCodeTriageBot VSCodeTriageBot added unreleased Patch has not yet been released in VS Code Insiders insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Feb 2, 2023
@rzhao271 rzhao271 added the verified Verification succeeded label Feb 22, 2023
@rzhao271
Copy link
Contributor

rzhao271 commented Feb 22, 2023

Opening the terminal works when sanity testing Linux server with the current instructions, though I noticed instead of getting hypriot/qemu, it seems to get tonistiigi/binfmt.
The terminal name says qemu-aarch64 on the arm64v8/ubuntu container, though.

@deepak1556
Copy link
Contributor Author

Yeah the server instructions were changed to use tonistiigi/binfmt that comes with newer qemu version that also addresses this issue. You can test with hypriot/qemu to see if the flow still works.

The terminal name says qemu-aarch64 on the arm64v8/ubuntu container, though.

This hasn't changed.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders linux Issues with VS Code on Linux terminal-process Problems launching processes, managing ptys, exiting, process leaks, etc. verified Verification succeeded virtual-machine Issues related to virtualbox, parallels etc
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants