GNU bug report logs - #32685
Memory leaks in test suite make check after building with build-asan

Previous Next

Package: sed;

Reported by: deltatau <deltatau <at> protonmail.com>

Date: Mon, 10 Sep 2018 15:34:03 UTC

Severity: normal

Done: Assaf Gordon <assafgordon <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 32685 in the body.
You can then email your comments to 32685 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-sed <at> gnu.org:
bug#32685; Package sed. (Mon, 10 Sep 2018 15:34:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to deltatau <deltatau <at> protonmail.com>:
New bug report received and forwarded. Copy sent to bug-sed <at> gnu.org. (Mon, 10 Sep 2018 15:34:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: deltatau <deltatau <at> protonmail.com>
To: "bug-sed <at> gnu.org" <bug-sed <at> gnu.org>
Subject: Memory leaks in test suite make check after building with build-asan
Date: Mon, 10 Sep 2018 07:31:14 +0000
[Message part 1 (text/plain, inline)]
Hi everyone

I think I may have found 3 memory leak bugs in sed.

When I built in the following way.
git clone git://git.sv.gnu.org/sed sed-build-asan
cd sed-build-asan
./bootstrap
./configure
make build-asan
make check

Make check told me that gnulib-tests/test-suite.log would contain details.
You can find this file attached as test-suite.log.

The version of sed which I am using, according to make check, is GNU sed 4.5.31-261c7-dirty.

My system is an up-to-date arch linux
uname -a
Linux archlinux 4.18.5-arch1-1-ARCH #1 SMP PREEMPT Fri Aug 24 12:48:58 UTC 2018 x86_64 GNU/Linux

Please forgive me if there is anything incomplete or wrong about this report. This is my first time submitting a bug. I am happy to help out by running some patches or something but I am no more than a novice to C programming.

- deltatau
[test-suite.log (text/x-log, attachment)]

Reply sent to Assaf Gordon <assafgordon <at> gmail.com>:
You have taken responsibility. (Tue, 09 Oct 2018 13:47:02 GMT) Full text and rfc822 format available.

Notification sent to deltatau <deltatau <at> protonmail.com>:
bug acknowledged by developer. (Tue, 09 Oct 2018 13:47:02 GMT) Full text and rfc822 format available.

Message #10 received at 32685-done <at> debbugs.gnu.org (full text, mbox):

From: Assaf Gordon <assafgordon <at> gmail.com>
To: deltatau <deltatau <at> protonmail.com>, 32685-done <at> debbugs.gnu.org
Subject: Re: bug#32685: Memory leaks in test suite make check after building
 with build-asan
Date: Tue, 9 Oct 2018 07:46:16 -0600
Hello,

On 10/09/18 01:31 AM, deltatau wrote:
> [...] This is my first time submitting a bug. I am happy to help
> out by running some patches or something but I am no more than a
> novice to C programming.

First and foremost, thank you for taking the time to run the tests
and reporting this bug in details.
This is helpful and encouraged.

As for the bugs:

> I think I may have found 3 memory leak bugs in sed.

> Make check told me that gnulib-tests/test-suite.log would contain 
> details. You can find this file attached as test-suite.log.
> 

FAIL: test-copy-acl.sh
======================
[...]

Direct leak of 17 byte(s) in 1 object(s) allocated from:
    #0 0x7fa615dbe019 in __interceptor_malloc 
/build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:86
    #1 0x563664a51531 in fread_file 
/home/ksk/delete/sed-build-asan/gnulib-tests/read-file.c:73
    #2 0x563664a51908 in internal_read_file 
/home/ksk/delete/sed-build-asan/gnulib-tests/read-file.c:147
    #3 0x563664a51a36 in read_file 
/home/ksk/delete/sed-build-asan/gnulib-tests/read-file.c:174
    #4 0x563664a50545 in main 
/home/ksk/delete/sed-build-asan/gnulib-tests/test-sameacls.c:58
    #5 0x7fa615924222 in __libc_start_main (/usr/lib/libc.so.6+0x24222)
[...]


So, these are indeed memory leaks (and it's nice that using the recent 
'build-asan' addition it was easy to find).

There are two subtleties here:

First,
These leaks happen in the gnulib tests - gnulib is a separate project
from sed. gnulib is used by many gnu project for common code.
I will report this to their mailing list (and CC you).

Second,
In C programming, it is sometimes customary to skip freeing memory
when it is known that the program will terminate soon.
When a program terminates, the operating system automatically
frees all the program's memory. So freeing the memory explicitly is
redundant.
This is even more so in small tests - which are more concerned with
the correctness of the code, and less with memory issues.

However,
With automated testing (like ASAN) it could be useful to
free the allocated memory to reduce noise and false positives.

In sed, we recently added additional code to free memory *if*
we are running under such memory checkers like ASAN:
https://git.savannah.gnu.org/cgit/sed.git/commit/?id=35b30b124c6f05fcfdd09a2dadabcfe570856c79


As such, I'm marking this as "not a bug" (for sed)
and closing it.

Thanks again and keep up the good work,
regards,
 - assaf





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 07 Nov 2018 12:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 5 years and 171 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.