diff options
author | Jeff King <peff@peff.net> | 2015-02-09 20:07:19 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-02-10 10:35:32 -0800 |
commit | 5e915f3085db3c0edbc80269f889341172e8595b (patch) | |
tree | 40343d0ce214cc79c71d3b64e69952fbab51d346 /t/lib-gpg.sh | |
parent | Merge branch 'maint-2.0' into maint-2.1 (diff) | |
download | tgif-5e915f3085db3c0edbc80269f889341172e8595b.tar.xz |
fast-import: avoid running end_packfile recursively
When an import has finished, we run end_packfile() to
finalize the data and move the packfile into place. If this
process fails, we call die() and end up in our die_nicely()
handler. Which unfortunately includes running end_packfile
to save any progress we made. We enter the function again,
and start operating on the pack_data struct while it is in
an inconsistent state, leading to a segfault.
One way to trigger this is to simply start two identical
fast-imports at the same time. They will both create the
same packfiles, which will then try to create identically
named ".keep" files. One will win the race, and the other
will die(), and end up with the segfault.
Since 3c078b9, we already reset the pack_data pointer to
NULL at the end of end_packfile. That covers the case of us
calling die() right after end_packfile, before we have
reinitialized the pack_data pointer. This new problem is
quite similar, except that we are worried about calling
die() _during_ end_packfile, not right after. Ideally we
would simply set pack_data to NULL as soon as we enter the
function, and operate on a copy of the pointer.
Unfortunately, it is not so easy. pack_data is a global, and
end_packfile calls into other functions which operate on the
global directly. We would have to teach each of these to
take an argument, and there is no guarantee that we would
catch all of the spots.
Instead, we can simply use a static flag to avoid
recursively entering the function. This is a little less
elegant, but it's short and fool-proof.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/lib-gpg.sh')
0 files changed, 0 insertions, 0 deletions