bugmake - Bugs: bug #45476, cygwin: stderr redirect append...

 
 

bug #45476: cygwin: stderr redirect append does not work with native Windows programs

Submitted by:  marco atzeri <matzeri>
Submitted on:  Sun Jul 5 20:36:11 2015  
 
Severity: 3 - NormalItem Group: Enhancement
Status: NonePrivacy: Public
Assigned to: Eli Zaretskii <eliz>Open/Closed: Open
Component Version: 4.1Operating System: MS Windows
Fixed Release: NoneTriage Status: Need Info

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Wed Sep 23 09:25:34 2015, comment #2:

I'm changing the status of this to "Enhancement" because the example Makefile works as expected with native Windows shell and make and sort programs.

Eli Zaretskii <eliz>
Project MemberIn charge of this item.
Mon Jul 6 19:38:05 2015, comment #1:

> redirecting stderr in append mode does not work if the program being invoked on a shell line is a native Windows executable. Instead of appending, the stderr output is written to the top of the file, corrupting it. This happens only if the 'make' process has its own stdout/err redirected to a pipe.


Isn't that an issue with how Cygwin libc implements invocation of subprocesses? I'm guessing that the implementation of standard descriptors inheritance uses Cygwin-specific hooks, and this works only if the subprocess is a Cygwin program. If this guess is correct, what would you like Make do in its upstream code to resolve this basic issue, which is really one aspect of incompatibility between Cywgin and native Windows programs?

Eli Zaretskii <eliz>
Project MemberIn charge of this item.
Sun Jul 5 20:36:11 2015, original submission:

First reported at
https://cygwin.com/ml/cygwin/2015-05/msg00140.html

I was not able to bisect make code to identify when
the issue was introduced.
Attached test case

--- original message ----

Using 32-bit cygwin 2.0.2 and make 4.1-1, in a recipe, redirecting
stderr in append mode does not work if the program being invoked on a
shell line is a native Windows executable. Instead of appending, the
stderr output is written to the top of the file, corrupting it. This
happens only if the 'make' process has its own stdout/err redirected to
a pipe.

Example recipe:

all:
echo first > output
echo
secondxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx >> output
/cygdrive/c/Windows/System32/sort.exe nonexist 2>> output; true

When "make" is run, the "output" file should be:

first
secondxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
nonexistThe system cannot find the file specified.

and in fact it is. But when "make 2>&1 | cat" is run, the output is:

nonexistThe system cannot find the file specified.
xxxxxxxxxxxxxx

even though it should be the same as before. The error message written
by sort.exe went to the top of the file instead of the end.

The problem does not happen if 'sort.exe' is replaced with a cygwin
program such as /usr/bin/sort.

The problem does not happen if stdout is redirected instead of stderr.

The problem does not happen if the output of 'make' is redirected to
a file instead of a pipe.

The problem does not happen if the sequence of commands in the recipe
is copied into a shell script and the shell invoked with its output
redirected to a pipe. That is why I am filing this against 'make'.
However, it is possible the bug is in the shell (or a different shell?)
and I just don't know how to invoke it properly to imitate what 'make'
does.

I am attaching a reproducer Makefile. Run "make 2>&1 | cat" to see
the incorrect output:

$ make 2>&1 | cat
echo first > output
echo secondxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx >>
output
/cygdrive/c/Windows/System32/sort.exe nonexist 2>> output; true
----- BEGIN output -----
nonexistThe system cannot find the file specified.
xxxxxxxxxxxxxx
----- END output -----

The bug happens with both make 4.1 and make 4.0 on cygwin 2.0.2. It
does not happen with make 3.82.90 and cygwin 1.7.23.

marco atzeri <matzeri>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #34383:  Makefile added by matzeri (293B - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by eliz (Posted a comment)
  • -unavailable- added by matzeri (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed Sep 23 09:25:34 2015elizItem GroupBug=>Enhancement
      Assigned toNone=>eliz
      Triage StatusNone=>Need Info
    Sun Jul 5 20:36:11 2015matzeriAttached File-=>Added Makefile, #34383

    Back to the top


    Powered by Savane 3.1-cleanup1