Output from WSL command pipeline is randomly truncated #1441

Closed
opened 2026-01-30 22:27:10 +00:00 by claunia · 6 comments
Owner

Originally created by @petsuter on GitHub (May 31, 2019).

Environment

Windows build number: 10.0.17134.765

Steps to reproduce

  • Open cmd.exe and enter the following commands:
mkdir test && cd test
FOR /L %i IN (100,1,999) DO echo %i >> data.txt
FOR /L %i IN (1,1,100) DO copy data.txt data%i.txt
wsl cat * | wsl sort | wsl uniq

Repeat the last line multiple times to repeat the problem with randomly different behavior.

Expected behavior

After the last command the terminal should display all integers from 100 to 999.

Actual behavior

After the last command the terminal only displays all integers from 100 to some random integer smaller than 999 (e.g. 978). Sometimes the last integer is not shown completely (e.g. only "97" instead of "978").


The output is truncated? One of the programs in the pipeline is aborted early? It might be a timing issue? Repeating the last command often results in the same "random" number, but sometimes it gets stops later / earlier.

Using different counts (e.g. 100 to 400 instead of 100 to 999) the problem also occurs.

Using slightly different commands the problem does not occur, e.g. this works correctly:

wsl
cat * | sort | uniq
Originally created by @petsuter on GitHub (May 31, 2019). # Environment ```none Windows build number: 10.0.17134.765 ``` # Steps to reproduce * Open `cmd.exe` and enter the following commands: ``` mkdir test && cd test FOR /L %i IN (100,1,999) DO echo %i >> data.txt FOR /L %i IN (1,1,100) DO copy data.txt data%i.txt wsl cat * | wsl sort | wsl uniq ``` Repeat the last line multiple times to repeat the problem with randomly different behavior. # Expected behavior After the last command the terminal should display all integers from 100 to 999. # Actual behavior After the last command the terminal only displays all integers from 100 to some random integer smaller than 999 (e.g. 978). Sometimes the last integer is not shown completely (e.g. only "97" instead of "978"). ---- The output is truncated? One of the programs in the pipeline is aborted early? It might be a timing issue? Repeating the last command often results in the same "random" number, but sometimes it gets stops later / earlier. Using different counts (e.g. 100 to 400 instead of 100 to 999) the problem also occurs. Using slightly different commands the problem does not occur, e.g. this works correctly: ``` wsl cat * | sort | uniq ```
claunia added the Product-WSLArea-OutputIssue-BugResolution-External labels 2026-01-30 22:27:10 +00:00
Author
Owner

@zadjii-msft commented on GitHub (May 31, 2019):

@benhillis Is this some sort of WSL bug?

It seems to occur regardless of conhost vs terminal. The fact that running cat * | sort | uniq without starting wsl each time makes me think it might be just an issue in WSL

@zadjii-msft commented on GitHub (May 31, 2019): @benhillis Is this some sort of WSL bug? It seems to occur regardless of conhost vs terminal. The fact that running `cat * | sort | uniq` without starting wsl each time makes me think it might be just an issue in WSL
Author
Owner

@benhillis commented on GitHub (May 31, 2019):

I have seen instances of this in the past, let me see if I can still repro...

@benhillis commented on GitHub (May 31, 2019): I have seen instances of this in the past, let me see if I can still repro...
Author
Owner

@DHowett-MSFT commented on GitHub (Jun 2, 2019):

This report is on 17134, and it seems to be related to piping from WSL to WSL. I'm going to say with 100% certainty that it's not a Console bug. 😄

@DHowett-MSFT commented on GitHub (Jun 2, 2019): This report is on _17134_, and it seems to be related to piping from WSL to WSL. I'm going to say with 100% certainty that it's not a Console bug. :smile:
Author
Owner

@petsuter commented on GitHub (Jun 2, 2019):

Thanks all for checking. 👍 Should I reopen this issue somewhere else?

(I originally intended to open it at https://github.com/microsoft/WSL/issues/new but there it says:

If this is a console issue (a problem with layout, rendering, colors, etc.), please post to the console issue tracker.

So I did that here instead. From outside it's difficult to know if this is a rendering issue or not. For all I know it could be a bug in cat, sort, uniq, wsl, cmd or whatever else is internally involved with piping. 🤔)

Please let me know or just reopen the issue wherever the appropriate place is, thanks!

@petsuter commented on GitHub (Jun 2, 2019): Thanks all for checking. 👍 Should I reopen this issue somewhere else? (I originally intended to open it at https://github.com/microsoft/WSL/issues/new but there it says: > If this is a console issue (a problem with layout, rendering, colors, etc.), please post to the [console issue tracker](https://github.com/microsoft/console/issues). So I did that here instead. From outside it's difficult to know if this is a rendering issue or not. For all I know it could be a bug in `cat`, `sort`, `uniq`, `wsl`, `cmd` or whatever else is internally involved with piping. 🤔) Please let me know or just reopen the issue wherever the appropriate place is, thanks!
Author
Owner

@zadjii-msft commented on GitHub (Jun 3, 2019):

Yea, sometimes it's really hard to tell externally if something like this is better suited for the WSL repo or the console repo. In this case, this is probably a bug with WSL itself, so it probably belongs in Microsoft/WSL

@zadjii-msft commented on GitHub (Jun 3, 2019): Yea, sometimes it's really hard to tell externally if something like this is better suited for the WSL repo or the console repo. In this case, this is probably a bug with WSL itself, so it probably belongs in [Microsoft/WSL](https://www.github.com/Microsoft/WSL)
Author
Owner

@petsuter commented on GitHub (Jun 3, 2019):

OK thanks, I opened a new issue there.

@petsuter commented on GitHub (Jun 3, 2019): OK thanks, I opened a [new issue there](https://github.com/microsoft/WSL/issues/4082).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#1441