[PATCH] Clean up temporary file in hardlink mode

Mark Wielaard mark@klomp.org
Wed Mar 3 22:57:29 GMT 2021


Hi Tom,

On Tue, Mar 02, 2021 at 11:10:27AM +0100, Tom de Vries wrote:
> Consider an executable file with hardlinks a.out and b.out.
> 
> When running dwz once:
> ...
> $ dwz -h a.out b.out
> ...
> a.out and b.out are updated, and remain hardlinks to the same file.
> 
> But when running dwz once more, a.out and b.out remain unchanged, and a
> temporary file b.out.#dwz#.XXXXXX is left.
> 
> This is caused by the fact that the code in function dwz that is intended to
> handle unchanged hardlinks is never triggered.  It is guarded by a
> "resa[n].res == 1" condition, but res->res is set to 0 at the end of function
> dwz, irrespective of whether the file changed or not.
> 
> Fix this by only setting res->res to 0 if the file changed.

This looks correct. This works because at the start of the dwz
function res->res is set to -1 (ignore) or 1 (unchanged) and then only
set to -2 for the hardlink case or 0 if write_dso succeeds.

> This makes test-case twice-multifile.sh fail, we'll deal with that in a
> seperate patch.

I haven't look at that patch yet, but if at all possible I would like
to get them in together. Or otherwise make the testcase skip. Having
failing tests in between commits makes things like bisecting a bit
messy (and will trigger warnings from the buildbots).

Thanks,

Mark


More information about the Dwz mailing list