On Mon, Jun 6, 2022 at 3:06 PM Paul Eggert <egg...@cs.ucla.edu> wrote: > On 6/6/22 12:37, Jim Meyering wrote: > > Once you push that (and assuming you have nothing else pending), I'll > > prepare another pre-release snapshot. > > Thanks, I pushed it into grep master, after fixing the commentary issue > Bruno noted.
I was going to make a snapshot, but figured I should first run the usual *SAN check: i.e., configure && make as usual, but then "make clean" followed by this on a linux system: san='-fsanitize-address-use-after-scope -fsanitize=address -static-libasan'; ASAN_OPTIONS=detect_leaks=1,allocator_may_return_null=1 make CFLAGS='-O0 -ggdb3' AM_CFLAGS="$san" AM_LDFLAGS="$san" check and it failed nearly every test, all due to leaks. You can see a few leaks with an even simpler test using valgrind and a no-ASAN binary: (this was with the patch attached below, which fixed the first one I found) $ valgrind --leak-check=full src/grep a /dev/null ==233608== Memcheck, a memory error detector ==233608== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al. ==233608== Using Valgrind-3.19.0 and LibVEX; rerun with -h for copyright info ==233608== Command: src/grep a /dev/null ==233608== ==233608== ==233608== HEAP SUMMARY: ==233608== in use at exit: 112,578 bytes in 27 blocks ==233608== total heap usage: 162 allocs, 135 frees, 140,110 bytes allocated ==233608== ==233608== 16 bytes in 1 blocks are definitely lost in loss record 7 of 25 ==233608== at 0x484486F: malloc (vg_replace_malloc.c:381) ==233608== by 0x4275DE: analyze (regcomp.c:1131) ==233608== by 0x4275DE: re_compile_internal (regcomp.c:769) ==233608== by 0x428327: rpl_re_compile_pattern (regcomp.c:217) ==233608== by 0x405084: regex_compile (dfasearch.c:164) ==233608== by 0x4053CA: Gearch.c:265) ==233608== by 0x404427: main (grep.c:2975) ==233608== ==233608== 32 bytes in 1 blocks are definitely lost in loss record 10 of 25 ==233608== at 0x484486F: malloc (vg_replace_malloc.c:381) ==233608== by 0x427156: init_dfa (regcomp.c:827) ==233608== by 0x427156: re_compile_internal (regcomp.c:732) ==233608== by 0x428327: rpl_re_compile_pattern (regcomp.c:217) ==233608== by 0x405084: regex_compile (dfasearch.c:164) ==233608== by 0x4053CA: GEAcompile (dfasearch.c:265) ==233608== by 0x404427: main (grep.c:2975) ==233608== ==233608== 48 bytes in 1 blocks are definitely lost in loss record 11 of 25 ==233608== at 0x484486F: malloc (vg_replace_malloc.c:381) ==233608== by 0x4275FC: analyze (regcomp.c:1133) ==233608== by 0x4275FC: re_compile_internal (regcomp.c:769) ==233608== by 0x428327: rpl_re_compile_pattern (regcomp.c:217) ==233608== by 0x405084: regex_compile (dfasearch.c:164) ==233608== by 0x4053CA: GEAcompile (dfasearch.c:265) ==233608== by 0x404427: main (grep.c:2975) ==233608== ==233608== 64 (48 direct, 16 indirect) bytes in 1 blocks are definitely lost in loss record 12 of 25 ==233608== at 0x484486F: malloc (vg_replace_malloc.c:381) ==233608== by 0x42760C: analyze (regcomp.c:1134) ==233608== by 0x42760C: re_compile_internal (regcomp.c:769) ==233608== by 0x428327: rpl_re_compile_pattern (regcomp.c:217) ==233608== by 0x405084: regex_compile (dfasearch.c:164) ==233608== by 0x4053CA: GEAcompile (dfasearch.c:265) ==233608== by 0x404427: main (grep.c:2975) ==233608== ==233608== 128 bytes in 1 blocks are possibly lost in loss record 19 of 25 ==233608== at 0x48496AF: realloc (vg_replace_malloc.c:1437) ==233608== by 0x42A2F8: xrealloc (xmalloc.c:65) ==233608== by 0x42A2F8: xpalloc (xmalloc.c:270) ==233608== by 0x405390: GEAcompile (dfasearch.c:258) ==233608== by 0x404427: main (grep.c:2975) ==233608== ==233608== 192 (48 direct, 144 indirect) bytes in 1 blocks are definitely lost in loss record 20 of 25 ==233608== at 0x4849464: calloc (vg_replace_malloc.c:1328) ==233608== by 0x427186: init_dfa (regcomp.c:834) ==233608== by 0x427186: re_compile_internal (regcomp.c:732) ==233608== by 0x428327: rpl_re_compile_pattern (regcomp.c:217) ==233608== by 0x405084: regex_compile (dfasearch.c:164) ==233608== by 0x4053CA: GEAcompile (dfasearch.c:265) ==233608== by 0x404427: main (grep.c:2975) ==233608== ==233608== LEAK SUMMARY: ==233608== definitely lost: 192 bytes in 5 blocks ==233608== indirectly lost: 160 bytes in 6 blocks ==233608== possibly lost: 128 bytes in 1 blocks ==233608== still reachable: 112,098 bytes in 15 blocks ==233608== suppressed: 0 bytes in 0 blocks ==233608== Reachable blocks (those to which a pointer was found) are not shown. ==233608== To see them, rerun with: --leak-check=full --show-leak-kinds=all ==233608== ==233608== For lists of detected and suppressed errors, rerun with: -s ==233608== ERROR SUMMARY: 6 errors from 6 contexts (suppressed: 0 from 0) Sharing my current incomplete state, because I'm out of time for the moment.
regex_compile.diff
Description: Binary data