Bug 24275 - hardlink handling leaves temporary file if not file compressed
Summary: hardlink handling leaves temporary file if not file compressed
Status: RESOLVED FIXED
Alias: None
Product: dwz
Classification: Unclassified
Component: default (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Nobody
URL:
Keywords:
: 26645 (view as bug list)
Depends on:
Blocks:
 
Reported: 2019-02-27 09:39 UTC by Tom de Vries
Modified: 2021-03-04 08:07 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom de Vries 2019-02-27 09:39:48 UTC
[ Filed before at:
- rbc#1625780 - "dwz crashed on s390x and armv7hl and rpmbuild leave
    s390x.debug.#dwz#"
  https://bugzilla.redhat.com/show_bug.cgi?id=1625780
- rbc#1671883 - "dwz fails to remove temporary files if input files are
    hardlinked"
  https://bugzilla.redhat.com/show_bug.cgi?id=1671883
]

Consider a hello world executable a.out:
...
$ gcc -g hello.c
...

with a hardlink b.out:
...
$ ln a.out b.out
...

Running dwz once (with hardlink support) compresses them:
...
$ dwz -h a.out b.out
...

and trying once more, doesn't compress them further:
...
$ dwz -h a.out b.out
dwz: a.out: DWARF compression not beneficial - old size 3452 new size 3452
...

but leaves a temporary file:
...
$ ls a.out* b.out*
a.out  b.out  b.out.#dwz#.uiIcPY
...
Comment 1 Tom de Vries 2019-02-27 09:46:36 UTC
AFAIU, the problem originates from the fact that the dedicated handling for this case in the dwz function:
...
          /* If a hardlink to this has been processed before                                                      
             and we didn't change it, just assume the same                                                        
             state.  */
          if (resa[n].res == 1)
            {
              close (fd);
              res->res = -2;
              return 1;
            }
...
is not triggered  when called with b.out argument because this code at the end of dwz:
...
  free (dso);
  if (ret == 0 && !low_mem)
    res->res = 0;
  return ret;
...
sets resa[n].res to 0 when called with a.out argument, irregardless of whether a.out was changed or not.
Comment 2 Tom de Vries 2019-03-07 06:18:27 UTC
posted patch: https://sourceware.org/ml/dwz/2019-q1/msg00060.html
Comment 3 Jakub Jelinek 2020-01-09 21:55:39 UTC
Tom, has this been fixed already or forgotten?
Comment 4 Tom de Vries 2020-01-10 06:43:11 UTC
(In reply to Jakub Jelinek from comment #3)
> Tom, has this been fixed already or forgotten?

Neither, I just didn't plan this for the upcoming release, but for the one after that.
Comment 5 Jiri Slaby 2020-10-02 04:09:16 UTC
(In reply to Tom de Vries from comment #4)
> Neither, I just didn't plan this for the upcoming release, but for the one
> after that.

So what about now? It still triggers, currently it bites perf in openSUSE, see bug 26645 and https://build.opensuse.org/package/view_file/openSUSE:Factory/perf/perf.spec?expand=1:
# a bug in dwz leaves temporary trace-*.debug.#dwz#.* on 64 bits in place
# remove this once fixed, see:
# https://sourceware.org/bugzilla/show_bug.cgi?id=26645
%define _find_debuginfo_dwz_opts %{nil}
Comment 6 Mark Wielaard 2020-11-08 22:25:33 UTC
The new testcase still fails, but the fix doesn't apply as is because the code logic has changed a bit.
Comment 7 Mark Wielaard 2021-02-13 22:57:38 UTC
*** Bug 26645 has been marked as a duplicate of this bug. ***