WSL: Zsh script with pipes hang
This bug-tracker is monitored by developers and other technical types. We like detail! So please use this form and tell us, concisely but precisely, what’s up. Please fill out ALL THE FIELDS!
If you have a feature request, please post to the UserVoice. If you’re reporting a BSOD, don’t post here! Instead, e-mail “secure@microsoft.com”, and if possible attach the minidump from "C:\Windows\minidump".
-
Your Windows build number: Microsoft Windows [Version 10.0.15063]
-
What you’re doing and what’s happening:
Here’s a sample script that causes an issue
#!/bin/zsh
find /mnt/c/Windows/ -type f -readable -print0 | while IFS= read -r -d "" file ; do
while :; do
stat "$file"
checksum=$(cat "$file" | sha256sum -b - | awk '{print $1}')
done
done
-
What’s wrong / what should be happening instead: What’s wrong: The script stops running in the middle. set -x to see where it gets stuck. CPU and disk are idle. What should happen: The script should complete running and exit eventually.
-
Strace of the failing command, if applicable: (If
<cmd>is failing, then runstrace -o strace.txt -ff <cmd>, and post the strace.txt output here) If I run it with strace, it doesn’t get stuck. Isn’t that just evil?
See our contributing instructions for assistance.
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Reactions: 2
- Comments: 15 (7 by maintainers)
@wbkang - Thanks! We like to fix things quickly around here, our driver was built from the ground up for issues to be easy to identify and diagnose.
I’d be happy to share a little detail. I first thought this could be related to pipes since your scripts are piping a bunch of commands together, however when running your repro I hit an assertion in our code that was making sure that we aren’t delivering signals to threadgroups that have already terminated. Turns out there was a race condition where a kill system call could come in and end up delivering a SIGCONT signal to a threadgroup that has already terminated. This would cause any caller waiting on the threadgroup to terminate to hang.
@wbkang - Thanks for the additional information, I was able to reproduce this locally and will spend some time debugging what is going wrong.
@benhillis
I took a look into creating a new user, and seeing how minimal I could make my environment and still reproduce the startup hang (100% of the time).
This is the very minimal zplug setup:
Thank you. If this is blocking some very common scenarios it may be a good candidate for servicing. If you can provide as much detail as possible about different scenarios this is causing issue I can use that as an argument why my fix should be backported via Windows Update.
I have checked in a fix for this issue, it should reach Windows Insider fast in a few weeks.