Skip Menu |

This queue is for tickets about the Git-Repository CPAN distribution.

Report information
The Basics
Id: 114301
Status: resolved
Priority: 0/
Queue: Git-Repository

People
Owner: Nobody in particular
Requestors: Lisa.Hansen [...] sas.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 1.320



Subject: Git::Repository / System::Command modules
Date: Tue, 10 May 2016 13:43:41 +0200
To: bug-git-repository [...] rt.cpan.org
From: Lisa Hansen <Lisa.Hansen [...] sas.com>
Hi, I have been using your Git::Repository module for some time, with great success (it was in fact the only Git module I could ever get working in Windows). Unfortunately I have run into a problem (due to a stupid hook that I am not able to change), which I am not sure if it is related to System::Command or IPC::Run, but I am hoping that you can help me. My apologies if this seems like a long story... A couple of years ago, Git::Repository ran perfect on Windows 2003. When forced to upgrade to Windows 2008, we started having hangs, but only every 3 or 4 weeks and occasionally a few times over the period of a day or two and then nothing again for a few weeks. Basically the three pipes would be left open, and the script would hang, even if I forked the Git::Repository "run" command. I wrote this off as a problem with IPC::Run and I created a way to detect when a process was hanging and email me and then I manually killed the pipe to stderr, and the script continued as it should (I usually got all of the output to stdout, and this was good enough) or I could easily recover from that point and re-run our process. You have recently made great improvements and most of the hangs were resolved, but I found that on one of the repositories we use, there is a server side trigger that prints a diff when running git push, and if there were many files changed, IPC::Run would hang because the stderr pipe would receive too much data (sometimes a change was several hundred files and therefore the output was huge). Since the output was coming from the server, using a --quiet for the git push command didn't work. But with your new changes, the hang was different and with the Git::Repository "run" command forked, my script could automatically detect when it was hanging and kill the command (but then I didn't get any output from the command) and then an automatic retry of the command would say everything was up to date, and no manual intervention was required. And since I could actually see what was happening, I also found a way to reproduce it and attempted to fix System::Command. Unfortunately, I could not find a solution that I can submit to you for a fix, but I can tell you what I tried. Then, maybe you can fix it, or you can tell me if I need to open a bug against IPC::Run, if it isn't something you can fix (or isn't something you want to fix because it isn't a problem with your module). The first thing I tried was changing System::Command::Reaper.pm from: $out and $out->opened and $out->close || carp "error closing stdout: $!"; $err and $err->opened and $err->close || carp "error closing stderr: $!"; To: $out and $out->opened and $out->flush and $out->close || carp "error closing stdout: $!"; $err and $err->opened and $err->flush and $err->close || carp "error closing stderr: $!"; This at least gave me the output that System::Command had received, but the process didn't continue. I am passing this on, because I think that maybe this would still be a good idea to implement, because at least if someone encounters a similar error and kills the command, they might see some output. Then I tried changing the stderr pipe to use a file instead, so, from: $pid = IPC::Run::start( [@cmd], '<pipe' => $in, '>pipe' => $out, '2>pipe' => $err, ); To: my ($fh, $file); eval { ($fh, $file) = tempfile(TEMPLATE => 'errXXXXX', DIR => $ENV{TEMP}, SUFFIX => '.txt', UNLINK => 1); }; if ($@) { croak "error: Unable to open temp file to capture stderr: $@\n"; } else { #this call passes stderr via a file $pid = IPC::Run::start( debug => 0, [@cmd], '<pipe' => $in, '>pipe' => $out, '2>' => $file, ); $err = \*$fh; } But I found that the following no longer worked: $cmd = $r->command( 'checkout', $branch ); @errput = $cmd->stderr->getlines(); I, for the life of me, cannot figure out why getlines doesn't read from the file handle, but maybe you can figure that out. Then I changed it to: my ($fh, $file); eval { ($fh, $file) = tempfile(TEMPLATE => 'errXXXXX', DIR => $ENV{TEMP}, SUFFIX => '.txt', UNLINK => 1, EXLOCK => 0 ); }; if ($@) { croak "error: Unable to open temp file to capture stderr: $@\n"; } else { #this call combines stderr with stdout $pid = IPC::Run::start( debug => 0, [@cmd], '<pipe' => $in, '>pipe' => $out, '2>&1' ); $err = \*$fh; #using an empty temp file keeps the reaper for complaining that $err isn't open } A surprise to me, but this doesn't hang. Of course it only works because all output goes to stdout and therefore this still doesn't work: $cmd = $r->command( 'checkout', $branch ); @errput = $cmd->stderr->getlines(); But to get what I need, I can just use the following command, and parse the output looking for fatal or error after running this: @output = $r->run( 'checkout', $branch ); Anyway, I hope this is useful and I hope you can help me and fix System::Command so it won't hang. If you need more information, please let me know. Kind Regards, Lisa
Subject: Re: [rt.cpan.org #114301] Git::Repository / System::Command modules
Date: Tue, 10 May 2016 13:51:38 +0200
To: bug-git-repository [...] rt.cpan.org
From: "Philippe Bruhat (BooK)" <book [...] cpan.org>
On Mon, May 09, 2016 at 09:52:44AM +0000, Lisa Hansen wrote: Show quoted text
> > I have been using your Git::Repository module for some time, with > great success (it was in fact the only Git module I could ever get > working in Windows).
That's good to know, thanks for the information. Maybe you could mention this in a review: http://cpanratings.perl.org/dist/Git-Repository Show quoted text
> My apologies if this seems like a long story...
No worries. And thanks for the detailed report. Show quoted text
> You have recently made great improvements and most of the hangs were > resolved, but I found that on one of the repositories we use, there is > a server side trigger that prints a diff when running git push, and if > there were many files changed, IPC::Run would hang because the stderr pipe > would receive too much data (sometimes a change was several hundred files > and therefore the output was huge).
I think the buffers are basically 4k, so anything bigger than that will cause trouble. Luckily, the latest version of System::Command (1.117) has a new method, loop_on(), that should help with this issue. https://metacpan.org/pod/System::Command#loop_on I'll rewrite Git::Repository::Command's final_output() method using System::Command's loop_on() and point you to a branch, so you can test it before I actually release it. Show quoted text
> And since I could actually see what was happening, I also found a way > to reproduce it and attempted to fix System::Command.
I would be very interested in seeing how you reproduce the issue. That would make a great addition to the Git::Repository or System::Command test suite. Show quoted text
> Anyway, I hope this is useful and I hope you can help me and fix > System::Command so it won't hang. If you need more information, please > let me know.
Yes, it is very useful. Many thanks for the detailed report and tentative patches. This was the best bug reports I got (to be better it would have to include a test and a working patch, but I wouldn't be of much use then ;-) -- Philippe Bruhat (BooK) All of life is a series of trades. And the more you exchange, the less you have to show for it. (Moral from Groo The Wanderer #4 (Pacific))
Subject: RE: [rt.cpan.org #114301] Git::Repository / System::Command modules
Date: Tue, 10 May 2016 13:54:56 +0200
To: bug-git-repository [...] rt.cpan.org
From: Lisa Hansen <Lisa.Hansen [...] sas.com>
Show quoted text
> -----Original Message----- > From: Philippe Bruhat (BooK) [mailto:book@cpan.org] > Sent: 10. maj 2016 09:30 > To: Lisa Hansen <Lisa.Hansen@sas.com> > Subject: Re: Git::Repository / System::Command modules > > Maybe you could mention this in a review: > http://cpanratings.perl.org/dist/Git-Repository >
Done. Show quoted text
> I think the buffers are basically 4k, so anything bigger than that will cause > trouble.
That is correct for stderr, at least. I never had stdout hang, even after I piped stderr to it. Show quoted text
> Luckily, the latest version of System::Command (1.117) has a new method, > loop_on(), that should help with this issue. > https://metacpan.org/pod/System::Command#loop_on > > I'll rewrite Git::Repository::Command's final_output() method using > System::Command's loop_on() and point you to a branch, so you can test it > before I actually release it.
OK, I've never tested a pre-release before, sounds cool. Show quoted text
> > And since I could actually see what was happening, I also found a way > > to reproduce it and attempted to fix System::Command.
> > I would be very interested in seeing how you reproduce the issue. > That would make a great addition to the Git::Repository or > System::Command test suite.
This is what I did to reproduce it: The repository has a server-side diff hook after the push (ours runs "git diff --name-status <commit_id_old> <commit_id_new>"). 1) Created a test branch from the main branch using a commit id in the past where there were several hundred files (>300) that differed from the current head. 2) Pushed this test branch to the server. 3) Merged the main branch (head) into my test branch. 4) Pushed my test branch and it would generate a long diff that prints to stderr and the script would hang. (this push was forked) 5) After 10 minutes of waiting on my forked child to complete, I would find the end process in my process tree and kill it (it was ssh, so I also had to kill the git process in the process tree above it, and then the script would continue). If you decide to add a kill, in case of a hang, I used pslist to find the process in Windows, but maybe you can use the ps in cygwin with Windows Git in order to make it platform independent. Show quoted text
> Yes, it is very useful. Many thanks for the detailed report and tentative > patches. This was the best bug reports I got (to be better it would have to > include a test and a working patch, but I wouldn't be of much use then ;-)
Maybe next time I'll do better ;-) But that would require that I learn how to write a test :-O Thanks for your fast response, you really made my day. :-) Lisa
On Tue May 10 07:55:12 2016, Lisa.Hansen@sas.com wrote: Show quoted text
>
> > Luckily, the latest version of System::Command (1.117) has a new > > method, > > loop_on(), that should help with this issue. > > https://metacpan.org/pod/System::Command#loop_on > > > > I'll rewrite Git::Repository::Command's final_output() method using > > System::Command's loop_on() and point you to a branch, so you can > > test it > > before I actually release it.
It turned out that the code in System-Command 1.117 was producing lost of warnings, so I fixed it and made a new release (v1.118). I've finally pushed the fix for Git::Repository to Github, as commit aabbecbadba67af293bca3e2decef8664ae5b507 on the master branch. Show quoted text
> OK, I've never tested a pre-release before, sounds cool.
Sorry for the delay. Let me know if that fixes your issue. Regards, -- BooK
Subject: RE: [rt.cpan.org #114301] Git::Repository / System::Command modules
Date: Fri, 3 Jun 2016 12:26:13 +0000
To: "bug-Git-Repository [...] rt.cpan.org" <bug-Git-Repository [...] rt.cpan.org>
From: Lisa Hansen <Lisa.Hansen [...] sas.com>
Hi BooK, Unfortunately this didn't do the trick. It still hangs. Lisa
Subject: Re: [rt.cpan.org #114301] Git::Repository / System::Command modules
Date: Fri, 3 Jun 2016 15:22:07 +0200
To: Lisa Hansen via RT <bug-Git-Repository [...] rt.cpan.org>
From: "Philippe Bruhat (BooK)" <book [...] cpan.org>
On Fri, Jun 03, 2016 at 08:26:37AM -0400, Lisa Hansen via RT wrote: Show quoted text
> Queue: Git-Repository > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=114301 > > > Unfortunately this didn't do the trick. It still hangs. >
Thanks for the feedback. Do you think you could write a test script that exposes the issue? If it's easier for you, it can work with one of your repositories (just send my a bundle or tarball in private). I will anonymize it / generate a similar one before publishing the code on CPAN, of course. Regards, -- Philippe Bruhat (BooK) Even when the words are true, they may not speak the truth. (Moral from Groo The Wanderer #70 (Epic))
Subject: RE: [rt.cpan.org #114301] Git::Repository / System::Command modules
Date: Mon, 6 Jun 2016 07:44:47 +0000
To: "bug-Git-Repository [...] rt.cpan.org" <bug-Git-Repository [...] rt.cpan.org>
From: Lisa Hansen <Lisa.Hansen [...] sas.com>
I will try writing a test script by making a dummy repository. How long it takes depends on how busy I am at work, so I can't guarantee when I can have it done. Lisa
Subject: Re: [rt.cpan.org #114301] Git::Repository / System::Command modules
Date: Mon, 6 Jun 2016 10:12:46 +0200
To: Lisa Hansen via RT <bug-Git-Repository [...] rt.cpan.org>
From: "Philippe Bruhat (BooK)" <book [...] cpan.org>
On Mon, Jun 06, 2016 at 03:45:06AM -0400, Lisa Hansen via RT wrote: Show quoted text
> Queue: Git-Repository > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=114301 > > > I will try writing a test script by making a dummy repository. How long it takes depends on how busy I am at work, so I can't guarantee when I can have it done. >
Don't worry about the delays. Once I have the test script, I can work on finding where the issue is, fixing it, and making sure it's gone. Many thanks for your help in improving this module! -- Philippe Bruhat (BooK) When you double-cross a friend, you triple-cross yourself. (Moral from Groo The Wanderer #8 (Epic))
Subject: RE: [rt.cpan.org #114301] Git::Repository / System::Command modules
Date: Thu, 9 Jun 2016 07:17:05 +0000
To: "bug-Git-Repository [...] rt.cpan.org" <bug-Git-Repository [...] rt.cpan.org>
From: Lisa Hansen <Lisa.Hansen [...] sas.com>
I thought of a quick and dirty way to make my test script fail with most any repository. I started by choosing a random repository from GitHub and cloning it. Then, by creating a local pre-rebase hook (and adjusting the hook to repeat the print of output until it is enough that the command hangs), setting my test branch to a past commit ID, and then rebasing from master, it will hang on the rebase. I hope this is good enough. The test script is attached (as a txt file). Thanks! Lisa Show quoted text
> -----Original Message----- > From: Philippe Bruhat (BooK) via RT [mailto:bug-Git-Repository@rt.cpan.org] > Sent: 6. juni 2016 14:52 > To: Lisa Hansen <Lisa.Hansen@sas.com> > Subject: Re: [rt.cpan.org #114301] Git::Repository / System::Command > modules > > <URL: https://rt.cpan.org/Ticket/Display.html?id=114301 > > > On Mon, Jun 06, 2016 at 03:45:06AM -0400, Lisa Hansen via RT wrote:
> > Queue: Git-Repository > > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=114301 > > > > > I will try writing a test script by making a dummy repository. How long it
> takes depends on how busy I am at work, so I can't guarantee when I can > have it done.
> >
> > Don't worry about the delays. Once I have the test script, I can work on > finding where the issue is, fixing it, and making sure it's gone. > > Many thanks for your help in improving this module! > > -- > Philippe Bruhat (BooK) > > When you double-cross a friend, you triple-cross yourself. > (Moral from Groo The Wanderer #8 (Epic))

Message body is not shown because sender requested not to inline it.

On Thu Jun 09 03:17:28 2016, Lisa.Hansen@sas.com wrote: Show quoted text
> I thought of a quick and dirty way to make my test script fail with > most any repository. I started by choosing a random repository from > GitHub and cloning it.
Awesome idea! Show quoted text
> Then, by creating a local pre-rebase hook (and > adjusting the hook to repeat the print of output until it is enough > that the command hangs), setting my test branch to a past commit ID, > and then rebasing from master, it will hang on the rebase. > > I hope this is good enough. > > The test script is attached (as a txt file).
Many thanks for the test, I'll use it to try to figure out what is happening and how to fix the issue. -- BooK
Subject: [rt.cpan.org #114301] Re: Git::Repository at CPAN PR Challenge
Date: Mon, 20 Jun 2016 09:50:20 +0200
To: bug-Git-Repository [...] rt.cpan.org
From: "E. Choroba" <choroba [...] cpan.org>
Hi BooK, I'm not able to reproduce the issue - I'm on Linux. I changed the test script to chmod the hook, but it doesn't hang, even if I enlarge its output 3000 times. It takes few seconds to finish, but that's it. Google shows three possibly related issues: 1. "Hang in git.Repo.clone_from() [Inter-process Communication Problem]" https://github.com/gitpython-developers/GitPython/issues/72 2. "Push tags=True blocks on github" https://github.com/gitpython-developers/GitPython/issues/145 3. "stderr output from .NET apps causes shell hangs when cygwin is not running in Windows console" https://www.cygwin.com/ml/cygwin/2012-06/msg00128.html Unfortunately, I'm not sure whether I can get to a MSWin machine in the near future to experiment further. Cheers, Ch.
Subject: RE: [rt.cpan.org #114301] Re: Git::Repository at CPAN PR Challenge
Date: Wed, 10 Aug 2016 08:25:06 +0000
To: "bug-Git-Repository [...] rt.cpan.org" <bug-Git-Repository [...] rt.cpan.org>
From: Lisa Hansen <Lisa.Hansen [...] sas.com>
Can I suggest that you test with a windows 10 evaluation version in a VM on linux? Lisa
Subject: RE: [rt.cpan.org #114301] Git::Repository / System::Command modules
Date: Wed, 5 Oct 2016 09:52:23 +0000
To: "bug-Git-Repository [...] rt.cpan.org" <bug-Git-Repository [...] rt.cpan.org>
From: Lisa Hansen <Lisa.Hansen [...] sas.com>
Hi BooK, I tried to install Git-Repository-1.320 on Window Server, but it doesn't work. The tests start failing at t05 (see attached build.log), and after forcing the install, git commands don't work, either. I have tried 2008 R2 Sp1 and 2012 R2, 1.319 works, but 1.320 fails. BTW, both versions work on Windows 7. I am assuming the changes are related to this, so I'm adding the comment here. Lisa
Download build.log
application/octet-stream 15.7k

Message body not shown because it is not plain text.

Hi, On Wed Oct 05 05:52:42 2016, Lisa.Hansen@sas.com wrote: Show quoted text
> > I tried to install Git-Repository-1.320 on Window Server, but it > doesn't work. The tests start failing at t05 (see attached build.log), > and after forcing the install, git commands don't work, either. I have > tried 2008 R2 Sp1 and 2012 R2, 1.319 works, but 1.320 fails. BTW, both > versions work on Windows 7. I am assuming the changes are related to > this, so I'm adding the comment here. >
Have you checked if git itself works? The log looks like every git command is failing, including `git --version`. -- BooK
Subject: RE: [rt.cpan.org #114301] Git::Repository / System::Command modules
Date: Fri, 14 Oct 2016 09:47:42 +0000
To: "bug-Git-Repository [...] rt.cpan.org" <bug-Git-Repository [...] rt.cpan.org>
From: Lisa Hansen <Lisa.Hansen [...] sas.com>
Yes, git works fine. I was using 1.319, with my script everything was working fine. I used cpanm to try to update, got the errors I sent, ran some of the failing tests manually from the command line (e.g. "perl .cpanm\work\1475657921.4176\Git-Repository-1.320\t\06-version.t" no special environment setup so 1.319 was used). It went fine. Thought maybe that there was something weird with the build environment, since it could find git but couldn't even run "git --version" so forced the install of 1.320 anyway. Tested script, failed with fatal errors for every git command. Downgraded to 1.319 using cpanm, script is working again. Lisa
On Wed Oct 05 05:52:42 2016, Lisa.Hansen@sas.com wrote: Show quoted text
> > I tried to install Git-Repository-1.320 on Window Server, but it > doesn't work. The tests start failing at t05 (see attached build.log), > and after forcing the install, git commands don't work, either. I have > tried 2008 R2 Sp1 and 2012 R2, 1.319 works, but 1.320 fails. BTW, both > versions work on Windows 7. I am assuming the changes are related to > this, so I'm adding the comment here. >
Luckily, the changes between v1.319 and v1.320 are quite small: https://github.com/book/Git-Repository/compare/v1.319...v1.320 Given this diff, I really think this issue is related to the change in lib/Git/Repository/Command.pm, which depends on a more recent version of System::Command. See also: https://github.com/book/Git-Repository/compare/v1.319...v1.320#diff-a580a87ff9da14b51504d149be8ecaffR23 Which version of System::Command is installed on your system? -- BooK
Subject: RE: [rt.cpan.org #114301] Git::Repository / System::Command modules
Date: Sun, 16 Oct 2016 14:51:45 +0000
To: "bug-Git-Repository [...] rt.cpan.org" <bug-Git-Repository [...] rt.cpan.org>
From: Lisa Hansen <Lisa.Hansen [...] sas.com>
They are all running 1.118, and I thought they were all running the same version of it, because I had patched it to keep our scripts from hanging, but apparently the Win7 PC didn't have my patch and that it why it worked (and it doesn't run the Git scripts, I just try to keep all the modules we use up to date on it). I removed the patch on one of the servers and now 1.320 works in our script. I still have to test to see if it hangs, which I won't be able to get to in the next couple of weeks, but at least I have something to test with now. Sorry about the false alarm! Lisa
Subject: RE: [rt.cpan.org #114301] Git::Repository / System::Command modules
Date: Fri, 18 Nov 2016 14:14:52 +0000
To: "bug-Git-Repository [...] rt.cpan.org" <bug-Git-Repository [...] rt.cpan.org>
From: Lisa Hansen <Lisa.Hansen [...] sas.com>
I have tested Git-Repository-1.320. This works, and I could not get the test script to hang, even with 10 times the data that would cause it to hang before (I didn't test more). :-) The problem is resolved. Lisa