canonical / multipass

Multipass orchestrates virtual Ubuntu instances
https://multipass.run
GNU General Public License v3.0
7.79k stars 643 forks source link

[windows] `exec` hanging when output is redirected #1170

Open Saviq opened 4 years ago

Saviq commented 4 years ago

There's a couple of similar bugs (#667 and #577 at least), but this is specifically about:

PS> multipass exec <instance> -- lsb_release -a | Out-Null

This hangs indefinitely, and is a blocker for Snapcraft on Windows.

NickZ commented 4 years ago

This is still present in the windows build of 1.1.0rc. I haven't been able to reproduce on guests using the 16.04 image, but I can get 18.04 guests to trigger this. This affects snapcraft, which will hang during the build process.

I was having a difficult time reproducing this bug, as my snapcraft builds would sometimes hang and sometimes not. I eventually figured out a way to reliably reproduce using this python script: https://gist.github.com/NickZ/58e87d6beaf6473a61da6856802154da

NickZ commented 4 years ago

You can also just run multipass exec primary -- sudo -i env printenv HOME | Out-Null in powershell a few times and it will eventually trigger

townsend2010 commented 4 years ago

Hey @NickZ,

Yeah, I can reproduce as well :frowning_face: I'll just reopen this and continue to investigate. Thanks for reporting!

NickZ commented 4 years ago

Unfortunately, still able to trigger this on the latest build here: https://github.com/canonical/multipass/pull/1375#issuecomment-593880436

While it may take a while longer, given enough iterations it will trigger.

Using my python script above.

PS C:\Users\nick\Documents> python .\trigger_1170.py
Using primary
testing output...
mesg: ttyname failed: Inappropriate ioctl for device
b'/root\n'
testing output...
mesg: ttyname failed: Inappropriate ioctl for device
b'/root\n'
testing output...
mesg: ttyname failed: Inappropriate ioctl for device
b'/root\n'
testing output...
mesg: ttyname failed: Inappropriate ioctl for device
b'/root\n'
testing output...
mesg: ttyname failed: Inappropriate ioctl for device
b'/root\n'
testing output...
mesg: ttyname failed

where it hangs.

townsend2010 commented 4 years ago

Hey @NickZ,

Thanks for letting us know. I think the behavior is much better than before as I think your script is an extreme case and in normal operation, this should work. That said, we will continue to work on a better fix, but it won't block our upcoming release.

ricab commented 8 months ago

Same thing in reverse:


C:\Users\ricab>multipass exec -n rich-zorilla -- bash -c "echo some_file contents > some_file"

C:\Users\ricab>echo asdf | multipass exec -n rich-zorilla -- cat -E some_file - some_file
some_file contents$
[blinking cursor]