Subject: Re: [PATCH v2 5/6] Win32: Thread-safe windows console output

From: Johannes Sixt <[email-masked]>
Date: Fri, 13 Jun 2014 08:10:57 +0200

Am 07.06.2014 09:57, schrieb Stepan Kasal:
> From: Karsten Blees <[email-masked]>
> Date: Sat, 14 Jan 2012 22:24:19 +0100
>
> Winansi.c has many static variables that are accessed and modified from
> the [v][f]printf / fputs functions overridden in the file. This may cause
> multi threaded git commands that print to the console to produce corrupted
> output or even crash.
>
> Additionally, winansi.c doesn't override all functions that can be used to
> print to the console (e.g. fwrite, write, fputc are missing), so that ANSI
> escapes don't work properly for some git commands (e.g. git-grep).
>
> Instead of doing ANSI emulation in just a few wrapped functions on top of
> the IO API, let's plug into the IO system and take advantage of the thread
> safety inherent to the IO system.
>
> Redirect stdout and stderr to a pipe if they point to the console. A
> background thread reads from the pipe, handles ANSI escape sequences and
> UTF-8 to UTF-16 conversion, then writes to the console.

There's something fishy with this patch. Please checkout and build 
eac14f8909d9. Then run t5000-tar-tree.sh like so from a CMD prompt:

   sh t5000-tar-tree.sh -v -i

Notice that in test 36 (invoke tar filter by extension) the tar file is 
written to the console instead of the file. Hit Ctrl-C to interrupt the 
test; do not remove the trash directory. You can verify the incorrect 
behavior like this:

   cd "t\trash directory.t5000-tar-tree"
   ..\..\git archive -o config-implicit.tar.foo HEAD

It writes the tar file to the console. When you build the parent commit, 
and repeat these two commands, there is no unexpected console output.

The patch fcd428f4a952 (Win32: fix broken pipe detection) does not fix the 
incorrect behavior.

I haven't dug (and won't dig) deeper than that.

-- Hannes

-- 
-- 
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.

You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to [email-masked]
To unsubscribe from this group, send email to
[email-masked]
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en

--- 
You received this message because you are subscribed to the Google Groups "msysGit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email-masked].
For more options, visit https://groups.google.com/d/optout.