public inbox for dwz@sourceware.org
 help / color / mirror / Atom feed
* [Bug default/27643] New: [dwz] more low mem memory leaks
@ 2021-03-24  8:40 vries at gcc dot gnu.org
  2021-03-24  8:43 ` [Bug default/27643] " vries at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: vries at gcc dot gnu.org @ 2021-03-24  8:40 UTC (permalink / raw)
  To: dwz

https://sourceware.org/bugzilla/show_bug.cgi?id=27643

            Bug ID: 27643
           Summary: [dwz] more low mem memory leaks
           Product: dwz
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: default
          Assignee: nobody at sourceware dot org
          Reporter: vries at gcc dot gnu.org
                CC: dwz at sourceware dot org
  Target Milestone: ---

After applying this patch to make the problem visible:
...
diff --git a/testsuite/dwz.tests/twice-multifile.sh
b/testsuite/dwz.tests/twice-multifile.s
h
index 8a66e25..1ff0166 100644
--- a/testsuite/dwz.tests/twice-multifile.sh
+++ b/testsuite/dwz.tests/twice-multifile.sh
@@ -24,7 +24,10 @@ if [ $(grep -qv "DWARF compression not beneficial" dwz.err \
     exit 1
 fi

-[ $status -eq 0 ]
+if [ $status -ne 0 ]; then
+    cat dwz.err
+    exit 1
+fi

 smaller-than.sh 1 1.saved

...
we have:
...
Running /home/vries/dwz/dwz.git/testsuite/dwz.tests/dwz-tests.exp ...
dwz: 1: DWARF compression not beneficial - old size 3372 new size 3372
dwz: 2: DWARF compression not beneficial - old size 3372 new size 3372

=================================================================
==14974==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 432 byte(s) in 6 object(s) allocated from:
    #0 0x7fc5a266d6d8 in __interceptor_calloc (/usr/lib64/libasan.so.4+0xdc6d8)
    #1 0x475dc1 in htab_try_create /home/vries/dwz/dwz.git/hashtab.c:164
    #2 0x44c610 in build_abbrevs /home/vries/dwz/dwz.git/dwz.c:11230
    #3 0x44ee00 in compute_abbrevs /home/vries/dwz/dwz.git/dwz.c:11510
    #4 0x46f07c in dwz /home/vries/dwz/dwz.git/dwz.c:15396
    #5 0x474e0d in dwz_files_1 /home/vries/dwz/dwz.git/dwz.c:16327
    #6 0x475699 in dwz_files /home/vries/dwz/dwz.git/dwz.c:16417
    #7 0x4759fc in main /home/vries/dwz/dwz.git/dwz.c:16458
    #8 0x7fc5a1fe2349 in __libc_start_main (/lib64/libc.so.6+0x24349)

Indirect leak of 2928 byte(s) in 6 object(s) allocated from:
    #0 0x7fc5a266d6d8 in __interceptor_calloc (/usr/lib64/libasan.so.4+0xdc6d8)
    #1 0x475de7 in htab_try_create /home/vries/dwz/dwz.git/hashtab.c:168
    #2 0x44c610 in build_abbrevs /home/vries/dwz/dwz.git/dwz.c:11230
    #3 0x44ee00 in compute_abbrevs /home/vries/dwz/dwz.git/dwz.c:11510
    #4 0x46f07c in dwz /home/vries/dwz/dwz.git/dwz.c:15396
    #5 0x474e0d in dwz_files_1 /home/vries/dwz/dwz.git/dwz.c:16327
    #6 0x475699 in dwz_files /home/vries/dwz/dwz.git/dwz.c:16417
    #7 0x4759fc in main /home/vries/dwz/dwz.git/dwz.c:16458
    #8 0x7fc5a1fe2349 in __libc_start_main (/lib64/libc.so.6+0x24349)

SUMMARY: AddressSanitizer: 3360 byte(s) leaked in 12 allocation(s).
child process exited abnormally
FAIL: /home/vries/dwz/dwz.git/testsuite/dwz.tests/twice-multifile.sh
...

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug default/27643] [dwz] more low mem memory leaks
  2021-03-24  8:40 [Bug default/27643] New: [dwz] more low mem memory leaks vries at gcc dot gnu.org
@ 2021-03-24  8:43 ` vries at gcc dot gnu.org
  2021-03-24  9:06 ` [Bug default/27643] [dwz] build_abbrevs memory leak vries at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: vries at gcc dot gnu.org @ 2021-03-24  8:43 UTC (permalink / raw)
  To: dwz

https://sourceware.org/bugzilla/show_bug.cgi?id=27643

--- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> ---
To reproduce:
...
$ make hello; cp hello 1; ./dwz 1; cp 1 2; ./dwz -m 3 1 2
...

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug default/27643] [dwz] build_abbrevs memory leak
  2021-03-24  8:40 [Bug default/27643] New: [dwz] more low mem memory leaks vries at gcc dot gnu.org
  2021-03-24  8:43 ` [Bug default/27643] " vries at gcc dot gnu.org
@ 2021-03-24  9:06 ` vries at gcc dot gnu.org
  2021-03-24 10:52 ` vries at gcc dot gnu.org
  2021-03-24 17:08 ` vries at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: vries at gcc dot gnu.org @ 2021-03-24  9:06 UTC (permalink / raw)
  To: dwz

https://sourceware.org/bugzilla/show_bug.cgi?id=27643

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[dwz] more low mem memory   |[dwz] build_abbrevs memory
                   |leaks                       |leak

--- Comment #2 from Tom de Vries <vries at gcc dot gnu.org> ---
OK, the test run was on top of a few proposed patches, which moves the
dwz_with_low_mem call into a separate process, such that we only see the
problem later, which explains why we don't see dwz_with_low_mem in comment 0.

On trunk, we do get dwz_with_low_mem instead of dwz:
...
Direct leak of 432 byte(s) in 6 object(s) allocated from:
    #0 0x7f8d6a37d6d8 in __interceptor_calloc (/usr/lib64/libasan.so.4+0xdc6d8)
    #1 0x475e34 in htab_try_create /home/vries/dwz/dwz.git/hashtab.c:164
    #2 0x44c610 in build_abbrevs /home/vries/dwz/dwz.git/dwz.c:11230
    #3 0x44ee00 in compute_abbrevs /home/vries/dwz/dwz.git/dwz.c:11510
    #4 0x46f07c in dwz /home/vries/dwz/dwz.git/dwz.c:15396
    #5 0x4748f5 in dwz_with_low_mem /home/vries/dwz/dwz.git/dwz.c:16274
    #6 0x474eb5 in dwz_files_1 /home/vries/dwz/dwz.git/dwz.c:16343
    #7 0x47570c in dwz_files /home/vries/dwz/dwz.git/dwz.c:16427
    #8 0x475a6f in main /home/vries/dwz/dwz.git/dwz.c:16468
    #9 0x7f8d69cf2349 in __libc_start_main (/lib64/libc.so.6+0x24349)
...

Anyway, looks like the problem is not specific to low-mem, adapting summary.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug default/27643] [dwz] build_abbrevs memory leak
  2021-03-24  8:40 [Bug default/27643] New: [dwz] more low mem memory leaks vries at gcc dot gnu.org
  2021-03-24  8:43 ` [Bug default/27643] " vries at gcc dot gnu.org
  2021-03-24  9:06 ` [Bug default/27643] [dwz] build_abbrevs memory leak vries at gcc dot gnu.org
@ 2021-03-24 10:52 ` vries at gcc dot gnu.org
  2021-03-24 17:08 ` vries at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: vries at gcc dot gnu.org @ 2021-03-24 10:52 UTC (permalink / raw)
  To: dwz

https://sourceware.org/bugzilla/show_bug.cgi?id=27643

--- Comment #3 from Tom de Vries <vries at gcc dot gnu.org> ---
Tentative patch:
...
diff --git a/dwz.c b/dwz.c
index c115b54..b212d6d 100644
--- a/dwz.c
+++ b/dwz.c
@@ -15092,10 +15092,15 @@ write_multifile (DSO *dso)
       dw_cu_ref *cup;

       for (cup = &first_cu; *cup && (*cup)->cu_kind != CU_TYPES; )
-       if ((*cup)->cu_die->die_no_multifile == 0)
-         cup = &(*cup)->cu_next;
-       else
-         *cup = (*cup)->cu_next;
+       {
+         if ((*cup)->cu_new_abbrev)
+           htab_delete ((*cup)->cu_new_abbrev);
+
+         if ((*cup)->cu_die->die_no_multifile == 0)
+           cup = &(*cup)->cu_next;
+         else
+           *cup = (*cup)->cu_next;
+       }
       *cup = NULL;
       multifile_mode = MULTIFILE_MODE_WR;
       if (tracing)
...

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug default/27643] [dwz] build_abbrevs memory leak
  2021-03-24  8:40 [Bug default/27643] New: [dwz] more low mem memory leaks vries at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-03-24 10:52 ` vries at gcc dot gnu.org
@ 2021-03-24 17:08 ` vries at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: vries at gcc dot gnu.org @ 2021-03-24 17:08 UTC (permalink / raw)
  To: dwz

https://sourceware.org/bugzilla/show_bug.cgi?id=27643

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Tom de Vries <vries at gcc dot gnu.org> ---
https://sourceware.org/git/?p=dwz.git;a=commit;h=e948e307737dd7034692b886b07522aba8c98415

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-03-24 17:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-24  8:40 [Bug default/27643] New: [dwz] more low mem memory leaks vries at gcc dot gnu.org
2021-03-24  8:43 ` [Bug default/27643] " vries at gcc dot gnu.org
2021-03-24  9:06 ` [Bug default/27643] [dwz] build_abbrevs memory leak vries at gcc dot gnu.org
2021-03-24 10:52 ` vries at gcc dot gnu.org
2021-03-24 17:08 ` vries at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).