ls-remote bug
- From
- Lior Zeltzer <liorz@marvell.com>
- Date
- Oct 24, 2023, 10:55 UTC
- Message-ID
- <BL0PR18MB2130A3CA5DEF0DD7199F2979BADFA@BL0PR18MB2130.namprd18.prod.outlook.com>
- In-Reply-To
- <BL0PR18MB2130C672D503E49F955E04E8BADFA@BL0PR18MB2130.namprd18.prod.outlook.com>
>uname -a
Linux dc3lp-veld0045 3.10.0-1160.21.1.el7.x86_64 #1 SMP Tue Mar 16 18:28:22 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Gerrit version : 3.8.0
Bug description : When running ls-remote : sometime data gets cut in the middle
Reproducing : You need a few files with a few repo names (I used 4 files with 10 repos each) Call then l1..l4 And the code below just cd into each of them does ls-remote twice and compares the data Doing it in parallel on all lists. Data received in both ls-remotes should be the same , if not, it prints *** Repos should contain a lot of tags and refs
Note : 1. without stderr redirection (2>&1) all works well 2. On local repos (not through gerrit) all works well
I compared various git vers and found the bug to be between 2.31.8 and 2.32.0 Comparing ls-remote.c file between those vers gave me :
Lines : if (transport_disconnect(transport)) return 1;
moved to end of sub
copying ls-remote.c from 2.31.8 to 2.32.0 - fixed the bug
Code reproducing bug :
#!/proj/mislcad/areas/DAtools/tools/perl/5.10.1/bin/perl -w use strict; use Cwd qw(cwd);
my $count = 4;
for my $f (1..$count) {
my $child = fork();
if (!$child) {
my $curr = cwd();
my @repos = `cat l$f`;
foreach my $repo (@repos) {
chomp $repo;
print "$repo\n";
chdir($repo);
my $remote_tags_str = `git ls-remote 2>&1`;
my $remote_tags_str2 = `git ls-remote 2>&1 `;
chdir($curr);
if ( $remote_tags_str ne $remote_tags_str2) {
print "***\n";
}
}
exit(0);
}
}
while (wait != -1) {}
1;