sed-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fix memory leaks and enable ASAN/UBSAN


From: Jim Meyering
Subject: Re: fix memory leaks and enable ASAN/UBSAN
Date: Mon, 6 Aug 2018 10:04:17 +0200

On Sun, Aug 5, 2018 at 7:12 AM, Assaf Gordon <address@hidden> wrote:
> Hello,
>
> Attached same patch, rebased to latest master (mostly due to
> space-after-parens  syntax check which changed hundreds of lines).
>
> On 02/08/18 12:01 AM, Assaf Gordon wrote:
>>
>> Attached few patches that fix memory leaks.
>> Most are not critical, and only enabled with DEBUG_LEAKS.
>> But one does need review, I suspect it is a runtime leak.
>>
>> With these patches, sed can be compiled with gcc's address
>> sanitizer (ASAN) and undefined-behavior sanitizer (UBSAN),
>> and all tests pass under the sanitizers.
>>
>>
>> === patches ===
>> sed: do not close stderr on exit
>> sed: free allocated memory under DEBUG_LEAKS
>> sed: fix memory leak (TODO: REVIEW)
>> gnulib: update to latest (for regex memory leaks)
>> maint: add address-sanitizer build target
>> maint: add undefined-behavior build target
>> ===

$ gzip -dc sed-sanitize-2.patch.gz |g am
...
Applying: maint: add address-sanitizer build target
.git/rebase-apply/patch:24: new blank line at EOF.
+
...

As syntax-check now reports, the above is complaining about the
trailing empty line in cfg.mk.

There were some typos in log messages:
- s/with sed/when sed/
- s/bufferin /buffer in /
- s/()/(match_regex)/ in "sed/regexp.c (): Free the previously"
- s/address/leak/ in "prevents address-sanitizing from working", since
I'm pretty sure the closing of stderr affects only LSAN's
atexit-generated output, not the ASAN-abort report.

Did you consider using the "lint" cpp symbol, along with its IF_LINT
for single-line suppressions? That is what coreutils does. Spurious
leaks are just another type of "lint" after all.

Re your question in "sed: fix memory leak", I agree: that is indeed a
real leak, and worth fixing unconditionally. Good catch.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]