New issue
Advanced search Search tips

Issue 830209 link

Starred by 5 users

Issue metadata

Status: Verified
Owner:
Closed: Jun 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 1
Type: Bug

Blocked on:
issue 819324



Sign in to add a comment

vscode sets stdin to O_NONBLOCK and breaks bash

Project Member Reported by smbar...@chromium.org, Apr 7 2018

Issue description

Repro:
1) Install vscode in Debian container
2) Launch "code" from bash
3) stdin is now set to O_NONBLOCK, breaking all sorts of things

example with cat:
smbarber@stretch:~$ cat
cat: -: Resource temporarily unavailable

Something in vscode (electron or vscode itself) is setting stdin (/dev/pts/<pts number>) to O_NONBLOCK and not setting it back. Also doesn't repro in zsh:

zsh:
[smbarber@stretch:~]
% ./test
stdin flags are 0x8002
O_NONBLOCK is false
[smbarber@stretch:~]
% code
[smbarber@stretch:~]
% ./test
stdin flags are 0x8002
O_NONBLOCK is false

bash:
smbarber@stretch:~$ ./test
stdin flags are 0x8002
O_NONBLOCK is false
smbarber@stretch:~$ code
smbarber@stretch:~$ ./test
stdin flags are 0x8802
O_NONBLOCK is true

test program:
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>

int main(int argc, char* argv[]) {
        int ret = fcntl(STDIN_FILENO, F_GETFL);

        printf("stdin flags are 0x%x\n", ret);
        printf("O_NONBLOCK is %s\n", ret & O_NONBLOCK ? "true" : "false");

        return 0;
}
 
Confirmed not to repro on native installs of Ubuntu 16.04 and Debian stretch.
Okay, this is a known issue that I had hoped most applications wouldn't trigger :(

SSH:
smbarber@stretch:~$ ls -l /proc/self/fd
total 0
lrwx------. 1 smbarber smbarber 64 Apr  7 22:35 0 -> /dev/pts/0
lrwx------. 1 smbarber smbarber 64 Apr  7 22:35 1 -> /dev/pts/0
lrwx------. 1 smbarber smbarber 64 Apr  7 22:35 2 -> /dev/pts/0

vsh, then /bin/login via run_container.sh:
smbarber@stretch:~$ ls -l /proc/self/fd
total 0
lrwx------. 1 smbarber smbarber 64 Apr  7 22:40 0 -> /dev/pts/2
lrwx------. 1 smbarber smbarber 64 Apr  7 22:40 1 -> /dev/pts/2
lrwx------. 1 smbarber smbarber 64 Apr  7 22:40 2 -> /dev/pts/2

In the vsh case, /dev/pts/2 is referring to a pty in the root namespace, not the container namespace. This breaks lots of software that expects this to be correct, and in particular breaks a few libc functions. See https://github.com/lxc/lxd/issues/936

I think we might want to start running vsh in the container's namespace.
Blockedon: 819324
 Issue 829879  has been merged into this issue.
Labels: Hotlist-Crostini-Platform
Owner: smbar...@chromium.org
Status: Assigned (was: Untriaged)
<triage>@smbarber, will this be fixed by the vsh improvements you're working on?</triage>
Labels: -Pri-3 Pri-1

Comment 7 by vapier@chromium.org, May 23 2018

Labels: -Restrict-View-Google
Status: Verified (was: Assigned)
Verified on 10798.0.0

Sign in to add a comment