Discussion:
results of gnulib tests with -fsanitize=leak
(too old to reply)
Bruno Haible
2017-05-19 07:43:17 UTC
Permalink
Raw Message
Results of a gnulib testdir configured with
CFLAGS="-O -ggdb -fsanitize=leak": 32 tests failed (see below).

I'm not interested in spending time to make the gnulib tests return all their
allocated memory. I think such tests should better be done in packages that
use gnulib (e.g. coreutils, wget, gettext, etc.).

Other than that, the failures of test-*printf-posix2.sh are apparently due
to the out-of-memory conditions imposed by the test.
Don't know about the failure of test-fprintf-posix3.sh.


FAIL: test-astrxfrm
===================


=================================================================
==22498==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 156 byte(s) in 4 object(s) allocated from:
#0 0x7fd1edd60795 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xc795)
#1 0x4015a6 in astrxfrm ../../gllib/astrxfrm.c:135

SUMMARY: LeakSanitizer: 156 byte(s) leaked in 4 allocation(s).
FAIL test-astrxfrm (exit status: 23)

FAIL: test-c-strcasestr
=======================


=================================================================
==22733==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 189 byte(s) in 1 object(s) allocated from:
#0 0x7fa5f03ae795 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xc795)
#1 0x40142d in main ../../gltests/test-c-strcasestr.c:226

SUMMARY: LeakSanitizer: 189 byte(s) leaked in 1 allocation(s).
FAIL test-c-strcasestr (exit status: 23)

FAIL: test-gc-arcfour
=====================


=================================================================
==23739==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 1824 byte(s) in 1 object(s) allocated from:
#0 0x7f56413ddcdd in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xccdd)
#1 0x401186 in gc_cipher_open ../../gllib/gc-gnulib.c:252

SUMMARY: LeakSanitizer: 1824 byte(s) leaked in 1 allocation(s).
FAIL test-gc-arcfour (exit status: 23)

FAIL: test-gc-des
=================


=================================================================
==23760==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 116736 byte(s) in 64 object(s) allocated from:
#0 0x7f62305fecdd in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xccdd)
#1 0x4010fa in gc_cipher_open ../../gllib/gc-gnulib.c:252

SUMMARY: LeakSanitizer: 116736 byte(s) leaked in 64 allocation(s).
FAIL test-gc-des (exit status: 23)

FAIL: test-di-set
=================


=================================================================
==24101==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 80 byte(s) in 1 object(s) allocated from:
#0 0x7faa2fba2795 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xc795)
#1 0x401b0a in hash_initialize ../../gllib/hash.c:605

Direct leak of 16 byte(s) in 1 object(s) allocated from:
#0 0x7faa2fba2795 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xc795)
#1 0x4023b2 in ino_map_insert ../../gllib/ino-map.c:133

SUMMARY: LeakSanitizer: 96 byte(s) leaked in 2 allocation(s).
FAIL test-di-set (exit status: 23)

FAIL: test-dprintf-posix2.sh
============================

FAIL test-dprintf-posix2.sh (exit status: 1)

FAIL: test-duplocale
====================

Skipping test: Spanish Unicode locale is not installed

=================================================================
==24216==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 376 byte(s) in 1 object(s) allocated from:
#0 0x7f11dc049795 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xc795)
#1 0x7f11db9986cf in __duplocale (/lib/x86_64-linux-gnu/libc.so.6+0x2d6cf)

SUMMARY: LeakSanitizer: 376 byte(s) leaked in 1 allocation(s).
FAIL test-duplocale (exit status: 23)

FAIL: test-filenamecat
======================


=================================================================
==25201==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 35 byte(s) in 10 object(s) allocated from:
#0 0x7fef2daa3795 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xc795)
#1 0x400e08 in mfile_name_concat ../../gllib/filenamecat-lgpl.c:71

SUMMARY: LeakSanitizer: 35 byte(s) leaked in 10 allocation(s).
FAIL test-filenamecat (exit status: 23)

FAIL: test-fprintf-posix2.sh
============================

==25579==ERROR: LeakSanitizer failed to allocate 0x1000 (4096) bytes of ReadFileToBuffer (errno: 12)
ERROR: Failed to mmap
FAIL test-fprintf-posix2.sh (exit status: 1)

FAIL: test-fprintf-posix3.sh
============================

FAIL test-fprintf-posix3.sh (exit status: 1)

FAIL: test-freadahead.sh
========================


=================================================================
==25644==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 5 byte(s) in 1 object(s) allocated from:
#0 0x7fcffd881795 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xc795)
#1 0x400e64 in main ../../gltests/test-freadahead.c:34

SUMMARY: LeakSanitizer: 5 byte(s) leaked in 1 allocation(s).
FAIL test-freadahead.sh (exit status: 1)

FAIL: test-freadptr.sh
======================


=================================================================
==25660==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 5 byte(s) in 1 object(s) allocated from:
#0 0x7fd999958795 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xc795)
#1 0x400eb2 in main ../../gltests/test-freadptr.c:33

SUMMARY: LeakSanitizer: 5 byte(s) leaked in 1 allocation(s).
FAIL test-freadptr.sh (exit status: 1)

FAIL: test-freadptr2.sh
=======================


=================================================================
==25674==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 5 byte(s) in 1 object(s) allocated from:
#0 0x7fac5eb11795 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xc795)
#1 0x400de0 in main ../../gltests/test-freadptr2.c:44

SUMMARY: LeakSanitizer: 5 byte(s) leaked in 1 allocation(s).
FAIL test-freadptr2.sh (exit status: 1)

FAIL: test-freadseek.sh
=======================


=================================================================
==25682==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 19 byte(s) in 1 object(s) allocated from:
#0 0x7ff37068c795 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xc795)
#1 0x40100d in main ../../gltests/test-freadseek.c:45

Direct leak of 18 byte(s) in 1 object(s) allocated from:
#0 0x7ff37068c795 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xc795)
#1 0x400ffd in main ../../gltests/test-freadseek.c:44

Direct leak of 6 byte(s) in 1 object(s) allocated from:
#0 0x7ff37068c795 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xc795)
#1 0x400fef in main ../../gltests/test-freadseek.c:43

Direct leak of 5 byte(s) in 1 object(s) allocated from:
#0 0x7ff37068c795 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xc795)
#1 0x400fe1 in main ../../gltests/test-freadseek.c:42

SUMMARY: LeakSanitizer: 48 byte(s) leaked in 4 allocation(s).
FAIL test-freadseek.sh (exit status: 1)

FAIL: test-getndelim2
=====================


=================================================================
==26285==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 12380 byte(s) in 1 object(s) allocated from:
#0 0x7fc932697e63 in __interceptor_realloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xce63)
#1 0x401eef in getndelim2 ../../gllib/getndelim2.c:173

SUMMARY: LeakSanitizer: 12380 byte(s) leaked in 1 allocation(s).
FAIL test-getndelim2 (exit status: 23)

FAIL: test-memmem
=================


=================================================================
==23953==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 189 byte(s) in 1 object(s) allocated from:
#0 0x7fc39775a795 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xc795)
#1 0x401956 in main ../../gltests/test-memmem.c:277

SUMMARY: LeakSanitizer: 189 byte(s) leaked in 1 allocation(s).
FAIL test-memmem (exit status: 23)

FAIL: test-pipe-filter-gi1.sh
=============================


=================================================================
==24503==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 571 byte(s) in 1 object(s) allocated from:
#0 0x7fdcb973b795 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xc795)
#1 0x402324 in fread_file ../../gllib/read-file.c:73

SUMMARY: LeakSanitizer: 571 byte(s) leaked in 1 allocation(s).
FAIL test-pipe-filter-gi1.sh (exit status: 1)

FAIL: test-pipe-filter-ii1.sh
=============================


=================================================================
==24631==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 571 byte(s) in 1 object(s) allocated from:
#0 0x7f25a74e2795 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xc795)
#1 0x4021c6 in fread_file ../../gllib/read-file.c:73

SUMMARY: LeakSanitizer: 571 byte(s) leaked in 1 allocation(s).
FAIL test-pipe-filter-ii1.sh (exit status: 1)

FAIL: test-printf-posix2.sh
===========================

==24987==ERROR: LeakSanitizer failed to allocate 0x1000 (4096) bytes of ReadFileToBuffer (errno: 12)
ERROR: Failed to mmap
FAIL test-printf-posix2.sh (exit status: 1)

FAIL: test-readtokens.sh
========================


=================================================================
==25622==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 128 byte(s) in 1 object(s) allocated from:
#0 0x7f87cae05e63 in __interceptor_realloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xce63)
#1 0x403900 in xrealloc ../../gllib/xmalloc.c:61

SUMMARY: LeakSanitizer: 128 byte(s) leaked in 1 allocation(s).
FAIL test-readtokens.sh (exit status: 1)

FAIL: test-striconveh
=====================


=================================================================
==29120==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 112 byte(s) in 1 object(s) allocated from:
#0 0x7f45c98f9795 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xc795)
#1 0x7f45c923c3e0 (/lib/x86_64-linux-gnu/libc.so.6+0x213e0)
#2 0x7f45c923be29 in iconv_open (/lib/x86_64-linux-gnu/libc.so.6+0x20e29)
#3 0x400fd0 in main ../../gltests/test-striconveh.c:65

Direct leak of 112 byte(s) in 1 object(s) allocated from:
#0 0x7f45c98f9795 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xc795)
#1 0x7f45c923c3e0 (/lib/x86_64-linux-gnu/libc.so.6+0x213e0)
#2 0x7f45c923be29 in iconv_open (/lib/x86_64-linux-gnu/libc.so.6+0x20e29)
#3 0x400f34 in main ../../gltests/test-striconveh.c:57

Direct leak of 112 byte(s) in 1 object(s) allocated from:
#0 0x7f45c98f9795 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xc795)
#1 0x7f45c923c3e0 (/lib/x86_64-linux-gnu/libc.so.6+0x213e0)
#2 0x7f45c923be29 in iconv_open (/lib/x86_64-linux-gnu/libc.so.6+0x20e29)
#3 0x400f6e in main ../../gltests/test-striconveh.c:60

Indirect leak of 32640 byte(s) in 1 object(s) allocated from:
#0 0x7f45c98f9795 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xc795)
#1 0x7f45c923c44b (/lib/x86_64-linux-gnu/libc.so.6+0x2144b)
#2 0x7f45c923be29 in iconv_open (/lib/x86_64-linux-gnu/libc.so.6+0x20e29)
#3 0x400fd0 in main ../../gltests/test-striconveh.c:65

Indirect leak of 8160 byte(s) in 1 object(s) allocated from:
#0 0x7f45c98f9795 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xc795)
#1 0x7f45c923c44b (/lib/x86_64-linux-gnu/libc.so.6+0x2144b)
#2 0x7f45c923be29 in iconv_open (/lib/x86_64-linux-gnu/libc.so.6+0x20e29)
#3 0x400f34 in main ../../gltests/test-striconveh.c:57

Indirect leak of 8160 byte(s) in 1 object(s) allocated from:
#0 0x7f45c98f9795 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xc795)
#1 0x7f45c923c44b (/lib/x86_64-linux-gnu/libc.so.6+0x2144b)
#2 0x7f45c923be29 in iconv_open (/lib/x86_64-linux-gnu/libc.so.6+0x20e29)
#3 0x400f6e in main ../../gltests/test-striconveh.c:60

Indirect leak of 624 byte(s) in 3 object(s) allocated from:
#0 0x7f45c98f9795 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xc795)
#1 0x7f45c9245314 (/lib/x86_64-linux-gnu/libc.so.6+0x2a314)

SUMMARY: LeakSanitizer: 49920 byte(s) leaked in 9 allocation(s).
FAIL test-striconveh (exit status: 23)

FAIL: test-u16-conv-to-enc
==========================


=================================================================
==30085==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 136 byte(s) in 1 object(s) allocated from:
#0 0x7ff9f8036795 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xc795)
#1 0x401154 in new_offsets ../../gltests/uniconv/test-u16-conv-to-enc.c:35
#2 0x401154 in main ../../gltests/uniconv/test-u16-conv-to-enc.c:97

SUMMARY: LeakSanitizer: 136 byte(s) leaked in 1 allocation(s).
FAIL test-u16-conv-to-enc (exit status: 23)

FAIL: test-u32-conv-to-enc
==========================


=================================================================
==30113==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 136 byte(s) in 1 object(s) allocated from:
#0 0x7fdc7bb68795 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xc795)
#1 0x40114b in new_offsets ../../gltests/uniconv/test-u32-conv-to-enc.c:35
#2 0x40114b in main ../../gltests/uniconv/test-u32-conv-to-enc.c:97

SUMMARY: LeakSanitizer: 136 byte(s) leaked in 1 allocation(s).
FAIL test-u32-conv-to-enc (exit status: 23)

FAIL: test-u8-conv-to-enc
=========================


=================================================================
==30141==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 144 byte(s) in 1 object(s) allocated from:
#0 0x7f0e0f83c795 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xc795)
#1 0x400ef6 in new_offsets ../../gltests/uniconv/test-u8-conv-to-enc.c:36

SUMMARY: LeakSanitizer: 144 byte(s) leaked in 1 allocation(s).
FAIL test-u8-conv-to-enc (exit status: 23)

SKIP: unigbrk/test-ulc-grapheme-breaks.sh
=========================================

Skipping test: no traditional Arabic locale is installed
SKIP unigbrk/test-ulc-grapheme-breaks.sh (exit status: 77)

FAIL: uninorm/test-u32-nfc-big.sh
=================================


=================================================================
==32746==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 4380680 byte(s) in 1095170 object(s) allocated from:
#0 0x7f3714116e63 in __interceptor_realloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xce63)
#1 0x401fc9 in u32_normalize ../../gllib/uninorm/u-normalize-internal.h:357

[many more]

SUMMARY: LeakSanitizer: 6346692 byte(s) leaked in 1187148 allocation(s).
FAIL uninorm/test-u32-nfc-big.sh (exit status: 23)

FAIL: uninorm/test-u32-nfd-big.sh
=================================


=================================================================
==1835==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 4380680 byte(s) in 1095170 object(s) allocated from:
#0 0x7f36a0360e63 in __interceptor_realloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xce63)
#1 0x401f7e in u32_normalize ../../gllib/uninorm/u-normalize-internal.h:357

[many more]

SUMMARY: LeakSanitizer: 6346692 byte(s) leaked in 1187148 allocation(s).
FAIL uninorm/test-u32-nfd-big.sh (exit status: 23)

FAIL: uninorm/test-u32-nfkc-big.sh
==================================


=================================================================
==2859==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 4380684 byte(s) in 1095171 object(s) allocated from:
#0 0x7efcb95b9e63 in __interceptor_realloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xce63)
#1 0x401fbb in u32_normalize ../../gllib/uninorm/u-normalize-internal.h:357

[many more]

SUMMARY: LeakSanitizer: 6346696 byte(s) leaked in 1187149 allocation(s).
FAIL uninorm/test-u32-nfkc-big.sh (exit status: 23)

FAIL: uninorm/test-u32-nfkd-big.sh
==================================


=================================================================
==4031==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 4380680 byte(s) in 1095170 object(s) allocated from:
#0 0x7fe9597fce63 in __interceptor_realloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xce63)
#1 0x401f7b in u32_normalize ../../gllib/uninorm/u-normalize-internal.h:357

[many more]

SUMMARY: LeakSanitizer: 6346692 byte(s) leaked in 1187148 allocation(s).
FAIL uninorm/test-u32-nfkd-big.sh (exit status: 23)

FAIL: test-u16-chr
==================


=================================================================
==4766==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 4194304 byte(s) in 1 object(s) allocated from:
#0 0x7ff730942795 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xc795)
#1 0x400e8c in main ../../gltests/unistr/test-chr.h:26

SUMMARY: LeakSanitizer: 4194304 byte(s) leaked in 1 allocation(s).
FAIL test-u16-chr (exit status: 23)

FAIL: test-u16-strchr
=====================


=================================================================
==4875==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 4194308 byte(s) in 1 object(s) allocated from:
#0 0x7f7d78507795 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xc795)
#1 0x400e2d in test_strchr ../../gltests/unistr/test-strchr.h:27
#2 0x400e2d in main ../../gltests/unistr/test-u16-strchr.c:39

SUMMARY: LeakSanitizer: 4194308 byte(s) leaked in 1 allocation(s).
FAIL test-u16-strchr (exit status: 23)

FAIL: test-u8-chr
=================


=================================================================
==5295==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 4194304 byte(s) in 1 object(s) allocated from:
#0 0x7f1d3d22d795 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xc795)
#1 0x400f1c in main ../../gltests/unistr/test-chr.h:26

SUMMARY: LeakSanitizer: 4194304 byte(s) leaked in 1 allocation(s).
FAIL test-u8-chr (exit status: 23)

FAIL: test-u8-strchr
====================


=================================================================
==5509==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 4194308 byte(s) in 1 object(s) allocated from:
#0 0x7f32ff875795 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xc795)
#1 0x400f1c in test_strchr ../../gltests/unistr/test-strchr.h:27
#2 0x400f1c in main ../../gltests/unistr/test-u8-strchr.c:39

SUMMARY: LeakSanitizer: 4194308 byte(s) leaked in 1 allocation(s).
FAIL test-u8-strchr (exit status: 23)
Bruno Haible
2017-05-19 15:02:00 UTC
Permalink
Raw Message
Here are the test results of a gnulib testdir configured with
CFLAGS="-O -ggdb -fsanitize=address".

Most of the memory leaks of -fsanitize=leak are reported here as well.
Additionally there are the following failures (see below).

Notable ones are:

1)
$ ./test-readtokens
$ echo $?
1
$ strace ./test-readtokens
...
ioctl(2, TCGETS, 0x7ffd80fbb890) = -1 EBADF (Bad file descriptor)
write(2, "\n==============================="..., 67) = -1 EBADF (Bad file descriptor)
write(2, "RawWrite can't output requested "..., 40) = -1 EBADF (Bad file descriptor)
exit_group(1) = ?

It looks like the problem comes from the 'closeout' module: When main() is finished,
it closes fd 1 and 2, and the libasan then cannot perform the output it wants to do.

2) test-u8-casecoll
It fails because HAVE_ICONV is not defined - because the test program in m4/iconv.m4
fails due to an iconv_t leak / memory leak.

What is the best practice here? Should -fsanitize=address only be activated
after configure has run? Or should all configure run tests be changed so that they
free all allocated memory?

Bruno


FAIL: test-gc-arctwo
====================


=================================================================
==31231==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 1824 byte(s) in 1 object(s) allocated from:
#0 0x7f2060d4879a in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x9879a)
#1 0x42c247 in rpl_calloc ../../gllib/calloc.c:65

SUMMARY: AddressSanitizer: 1824 byte(s) leaked in 1 allocation(s).
FAIL test-gc-arctwo (exit status: 23)

FAIL: test-fprintf-posix2.sh
============================

==781==ERROR: AddressSanitizer failed to allocate 0x4c7000 (5009408) bytes of LargeMmapAllocator (errno: 12)
ERROR: Failed to mmap
FAIL test-fprintf-posix2.sh (exit status: 1)

FAIL: test-getgroups
====================

=================================================================
==1746==ERROR: AddressSanitizer: negative-size-param: (size=-4)
#0 0x7f0d68a7df25 (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x49f25)
#1 0x402179 in getgroups /usr/include/x86_64-linux-gnu/bits/unistd.h:275
#2 0x402179 in rpl_getgroups ../../gllib/getgroups.c:85
#3 0x401784 in main ../../gltests/test-getgroups.c:58
#4 0x7f0d6838282f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
#5 0x4013f8 in _start (/media/develdata/devel/GNULIB/testdir-all/build-sana/gltests/test-getgroups+0x4013f8)

0x60400000dfd0 is located 0 bytes inside of 44-byte region [0x60400000dfd0,0x60400000dffc)
allocated by thread T0 here:
#0 0x7f0d68acc602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)
#1 0x401690 in main ../../gltests/test-getgroups.c:48

SUMMARY: AddressSanitizer: negative-size-param ??:0 ??
==1746==ABORTING
FAIL test-getgroups (exit status: 1)

FAIL: test-printf-posix2.sh
===========================

==11485==ERROR: AddressSanitizer failed to allocate 0x4c7000 (5009408) bytes of LargeMmapAllocator (errno: 12)
ERROR: Failed to mmap
FAIL test-printf-posix2.sh (exit status: 1)

FAIL: test-readtokens.sh
========================

FAIL test-readtokens.sh (exit status: 1)

FAIL: test-u16-casecoll
=======================

../../gltests/unicase/test-casecmp.h:34: assertion 'my_casecmp (input, SIZEOF (input), NULL, 0, NULL, nf, &cmp) == 0' failed
FAIL test-u16-casecoll (exit status: 134)

FAIL: test-u32-casecoll
=======================

../../gltests/unicase/test-casecmp.h:34: assertion 'my_casecmp (input, SIZEOF (input), NULL, 0, NULL, nf, &cmp) == 0' failed
FAIL test-u32-casecoll (exit status: 134)

FAIL: test-u8-casecoll
======================

../../gltests/unicase/test-casecmp.h:34: assertion 'my_casecmp (input, SIZEOF (input), NULL, 0, NULL, nf, &cmp) == 0' failed
FAIL test-u8-casecoll (exit status: 134)

FAIL: test-u16-normcoll
=======================

../../gltests/uninorm/test-u16-normcmp.h:34: assertion 'my_normcmp (input, SIZEOF (input), NULL, 0, nf, &cmp) == 0' failed
FAIL test-u16-normcoll (exit status: 134)

FAIL: test-u32-normcoll
=======================

../../gltests/uninorm/test-u32-normcmp.h:34: assertion 'my_normcmp (input, SIZEOF (input), NULL, 0, nf, &cmp) == 0' failed
FAIL test-u32-normcoll (exit status: 134)

FAIL: test-u8-normcoll
======================

../../gltests/uninorm/test-u8-normcmp.h:34: assertion 'my_normcmp (input, SIZEOF (input), NULL, 0, nf, &cmp) == 0' failed
FAIL test-u8-normcoll (exit status: 134)

FAIL: test-u16-vasnprintf1
==========================

../../gltests/unistdio/test-u16-printf1.h:196: assertion 'result != NULL' failed
FAIL test-u16-vasnprintf1 (exit status: 134)

FAIL: test-u16-vasprintf1
=========================

../../gltests/unistdio/test-u16-printf1.h:196: assertion 'result != NULL' failed
FAIL test-u16-vasprintf1 (exit status: 134)

FAIL: test-u16-vsnprintf1
=========================

../../gltests/unistdio/test-u16-printf1.h:196: assertion 'result != NULL' failed
FAIL test-u16-vsnprintf1 (exit status: 134)

FAIL: test-u16-vsprintf1
========================

../../gltests/unistdio/test-u16-printf1.h:196: assertion 'result != NULL' failed
FAIL test-u16-vsprintf1 (exit status: 134)

FAIL: test-u32-vasnprintf1
==========================

../../gltests/unistdio/test-u32-printf1.h:196: assertion 'result != NULL' failed
FAIL test-u32-vasnprintf1 (exit status: 134)

FAIL: test-u32-vasprintf1
=========================

../../gltests/unistdio/test-u32-printf1.h:196: assertion 'result != NULL' failed
FAIL test-u32-vasprintf1 (exit status: 134)

FAIL: test-u32-vsnprintf1
=========================

../../gltests/unistdio/test-u32-printf1.h:196: assertion 'result != NULL' failed
FAIL test-u32-vsnprintf1 (exit status: 134)

FAIL: test-u32-vsprintf1
========================

../../gltests/unistdio/test-u32-printf1.h:196: assertion 'result != NULL' failed
FAIL test-u32-vsprintf1 (exit status: 134)

FAIL: test-u8-vasnprintf1
=========================

../../gltests/unistdio/test-u8-printf1.h:176: assertion 'result != NULL' failed
FAIL test-u8-vasnprintf1 (exit status: 134)

FAIL: test-u8-vasprintf1
========================

../../gltests/unistdio/test-u8-printf1.h:176: assertion 'result != NULL' failed
FAIL test-u8-vasprintf1 (exit status: 134)

FAIL: test-u8-vsnprintf1
========================

../../gltests/unistdio/test-u8-printf1.h:176: assertion 'result != NULL' failed
FAIL test-u8-vsnprintf1 (exit status: 134)

FAIL: test-u8-vsprintf1
=======================

../../gltests/unistdio/test-u8-printf1.h:176: assertion 'result != NULL' failed
FAIL test-u8-vsprintf1 (exit status: 134)

FAIL: test-ulc-vasnprintf1
==========================

../../gltests/unistdio/test-ulc-printf1.h:63: assertion 'result != NULL' failed
FAIL test-ulc-vasnprintf1 (exit status: 134)

FAIL: test-ulc-vasprintf1
=========================

../../gltests/unistdio/test-ulc-printf1.h:63: assertion 'result != NULL' failed
FAIL test-ulc-vasprintf1 (exit status: 134)

FAIL: test-ulc-vsnprintf1
=========================

../../gltests/unistdio/test-ulc-printf1.h:63: assertion 'result != NULL' failed
FAIL test-ulc-vsnprintf1 (exit status: 134)

FAIL: test-ulc-vsprintf1
========================

../../gltests/unistdio/test-ulc-printf1.h:63: assertion 'result != NULL' failed
FAIL test-ulc-vsprintf1 (exit status: 134)
Paul Eggert
2017-05-19 16:11:29 UTC
Permalink
Raw Message
Post by Bruno Haible
the problem comes from the 'closeout' module: When main() is finished,
it closes fd 1 and 2, and the libasan then cannot perform the output it wants to do.
Yes, closeout should not close stderr when addresses are being
sanitized. I installed the attached patch to work around the problem.
Perhaps a better fix could be made (e.g., close_stdout could
conditionally call AddressSanitizer's leak_check_at_exit before closing
stderr), but this workaround should suffice for now.
Post by Bruno Haible
2) test-u8-casecoll
It fails because HAVE_ICONV is not defined - because the test program in m4/iconv.m4
fails due to an iconv_t leak / memory leak.
What is the best practice here? Should -fsanitize=address only be activated
after configure has run? Or should all configure run tests be changed so that they
free all allocated memory?
The latter is surely too much work for not enough benefit. In general, a
'configure'-time test should focus on one individual feature, and not
attempt to test a combination of features, as there are too many
combinations. This is partly why we advise people not to run 'configure'
with -Werror, as that tests not only the desired features but also
whether the 'configure'-time test pacifies picky compilers. Similarly,
we should advise people not to run 'configure' with sanitization options
like memory-leak detection that affect valid (albeit inefficient) test
programs.

However, it should be OK to configure with -fsanitize=address if the
ASAN_OPTIONS environment variable suppresses checks for
valid-albeit-inefficent behavior. For example,
ASAN_OPTIONS='detect_leaks=0' may suffice. (I haven't checked this.)
Bruno Haible
2017-05-19 17:21:32 UTC
Permalink
Raw Message
Post by Paul Eggert
I installed the attached patch to work around the problem.
Thanks! I confirm that 'test-readtokens.sh' now properly reports a memory leak:

FAIL: test-readtokens.sh
========================


=================================================================
==22965==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 128 byte(s) in 1 object(s) allocated from:
#0 0x7f3d77fa7961 in realloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98961)
#1 0x40632c in xrealloc ../../gllib/xmalloc.c:61

SUMMARY: AddressSanitizer: 128 byte(s) leaked in 1 allocation(s).
FAIL test-readtokens.sh (exit status: 1)
Post by Paul Eggert
Similarly,
we should advise people not to run 'configure' with sanitization options
like memory-leak detection that affect valid (albeit inefficient) test
programs.
However, it should be OK to configure with -fsanitize=address if the
ASAN_OPTIONS environment variable suppresses checks for
valid-albeit-inefficent behavior. For example,
ASAN_OPTIONS='detect_leaks=0' may suffice. (I haven't checked this.)
Good to hear this, thanks. So, people should
1. set ASAN_OPTIONS='detect_leaks=0' [1]
2. run configure
3. set ASAN_OPTIONS to whatever value they need [2]
4. run "make check"

Bruno

[1] https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer
[2] https://github.com/google/sanitizers/wiki/AddressSanitizerFlags
Bruno Haible
2017-05-20 13:34:45 UTC
Permalink
Raw Message
Post by Bruno Haible
What is the best practice here? Should -fsanitize=address only be activated
after configure has run? Or should all configure run tests be changed so that they
free all allocated memory?
... This is partly why we advise people not to run 'configure'
with -Werror
This argument is not very convincing: With -Werror, we would need to deal
with all possible gcc warnings (there are many warning options) on all
supported platforms (there are many). This is impossible to handle.

Whereas here, memory leaks don't depend on gcc options, nor on the platform.

And the issue with -Werror keeps reappearing.


In fact, you already started the elimination of memory leaks from all gnulib
configure tests a year ago:

2016-02-06 Paul Eggert <***@cs.ucla.edu>

misc: port better to gcc -fsanitize=address
Without these patches, ./configure CFLAGS='-fsanitize=address'
would compute incorrect values. This patch fixes some (but not all)
test failures with recent glibc, with this configuration.

Let me complete your work here.


2017-05-20 Bruno Haible <***@clisp.org>

Avoid wrong configure results with gcc -fsanitize=address.
This completes the work done on 2016-02-06 on this topic.
* m4/memmem.m4 (gl_FUNC_MEMMEM): Free allocated memory before returning.
* m4/getcwd.m4 (gl_FUNC_GETCWD_NULL): Likewise.
* m4/strcasestr.m4 (gl_FUNC_STRCASESTR): Likewise.
* m4/strstr.m4 (gl_FUNC_STRSTR): Likewise.
* m4/fopen.m4 (gl_FUNC_FOPEN): Close allocated FILE streams before
returning.
* m4/fflush.m4 (gl_FUNC_FFLUSH_STDIN): Likewise.
* m4/fpurge.m4 (gl_FUNC_FPURGE): Likewise.
* m4/ftello.m4 (gl_FUNC_FTELLO): Likewise.
* m4/rmdir-errno.m4 (gl_FUNC_RMDIR_NOTEMPTY): Likewise.
* m4/signbit.m4 (gl_FLOATTYPE_SIGN_LOCATION): Likewise.
* m4/ungetc.m4 (gl_FUNC_UNGETC_WORKS): Likewise.
* m4/getdelim.m4 (gl_FUNC_GETDELIM): Close allocated FILE streams and
free allocated memory before returning.
* m4/getline.m4 (gl_FUNC_GETLINE): Likewise.
* m4/d-ino.m4 (gl_CHECK_TYPE_STRUCT_DIRENT_D_INO): Close allocated DIR
objects before returning.
* m4/iconv.m4 (AM_ICONV_LINK): Close allocated iconv_t handles before
returning.

diff --git a/m4/d-ino.m4 b/m4/d-ino.m4
index 79731ca..65cd4d8 100644
--- a/m4/d-ino.m4
+++ b/m4/d-ino.m4
@@ -1,4 +1,4 @@
-# serial 15
+# serial 16

dnl From Jim Meyering.
dnl
@@ -29,11 +29,11 @@ AC_DEFUN([gl_CHECK_TYPE_STRUCT_DIRENT_D_INO],
return 1;
e = readdir (dp);
if (! e)
- return 2;
+ { closedir (dp); return 2; }
if (lstat (e->d_name, &st) != 0)
- return 3;
+ { closedir (dp); return 3; }
if (e->d_ino != st.st_ino)
- return 4;
+ { closedir (dp); return 4; }
closedir (dp);
return 0;
]])],
diff --git a/m4/fflush.m4 b/m4/fflush.m4
index 1d1f1ba..7732234 100644
--- a/m4/fflush.m4
+++ b/m4/fflush.m4
@@ -1,4 +1,4 @@
-# fflush.m4 serial 15
+# fflush.m4 serial 16

# Copyright (C) 2007-2017 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
@@ -44,16 +44,16 @@ AC_DEFUN([gl_FUNC_FFLUSH_STDIN],
return 1;
fd = fileno (f);
if (fd < 0 || fread (buffer, 1, 5, f) != 5)
- return 2;
+ { fclose (f); return 2; }
/* For deterministic results, ensure f read a bigger buffer. */
if (lseek (fd, 0, SEEK_CUR) == 5)
- return 3;
+ { fclose (f); return 3; }
/* POSIX requires fflush-fseek to set file offset of fd. This fails
on BSD systems and on mingw. */
if (fflush (f) != 0 || fseek (f, 0, SEEK_CUR) != 0)
- return 4;
+ { fclose (f); return 4; }
if (lseek (fd, 0, SEEK_CUR) != 5)
- return 5;
+ { fclose (f); return 5; }
/* Verify behaviour of fflush after ungetc. See
<http://www.opengroup.org/austin/aardvark/latest/xshbug3.txt> */
/* Verify behaviour of fflush after a backup ungetc. This fails on
@@ -62,14 +62,15 @@ AC_DEFUN([gl_FUNC_FFLUSH_STDIN],
ungetc (c, f);
fflush (f);
if (fgetc (f) != c)
- return 6;
+ { fclose (f); return 6; }
/* Verify behaviour of fflush after a non-backup ungetc. This fails
on glibc 2.8 and on BSD systems. */
c = fgetc (f);
ungetc ('@', f);
fflush (f);
if (fgetc (f) != c)
- return 7;
+ { fclose (f); return 7; }
+ fclose (f);
return 0;
]])], [gl_cv_func_fflush_stdin=yes], [gl_cv_func_fflush_stdin=no],
[gl_cv_func_fflush_stdin=cross])
diff --git a/m4/fopen.m4 b/m4/fopen.m4
index 0d09e4e..3772e50 100644
--- a/m4/fopen.m4
+++ b/m4/fopen.m4
@@ -1,4 +1,4 @@
-# fopen.m4 serial 9
+# fopen.m4 serial 10
dnl Copyright (C) 2007-2017 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -27,7 +27,11 @@ AC_DEFUN([gl_FUNC_FOPEN],
#include <stdio.h>
int main ()
{
- return fopen ("conftest.sl/", "w") != NULL;
+ FILE *fp = fopen ("conftest.sl/", "w");
+ int result = (fp != NULL);
+ if (fp != NULL)
+ fclose (fp);
+ return result;
}]])],
[gl_cv_func_fopen_slash=yes],
[gl_cv_func_fopen_slash=no],
diff --git a/m4/fpurge.m4 b/m4/fpurge.m4
index 57be1b9..3533f4b 100644
--- a/m4/fpurge.m4
+++ b/m4/fpurge.m4
@@ -1,4 +1,4 @@
-# fpurge.m4 serial 7
+# fpurge.m4 serial 8
dnl Copyright (C) 2007, 2009-2017 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -14,23 +14,40 @@ AC_DEFUN([gl_FUNC_FPURGE],
HAVE_FPURGE=1
# Detect BSD bug. Only cygwin 1.7 is known to be immune.
AC_CACHE_CHECK([whether fpurge works], [gl_cv_func_fpurge_works],
- [AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>
-]], [FILE *f = fopen ("conftest.txt", "w+");
- if (!f) return 1;
- if (fputc ('a', f) != 'a') return 2;
- rewind (f);
- if (fgetc (f) != 'a') return 3;
- if (fgetc (f) != EOF) return 4;
- if (fpurge (f) != 0) return 5;
- if (putc ('b', f) != 'b') return 6;
- if (fclose (f) != 0) return 7;
- if ((f = fopen ("conftest.txt", "r")) == NULL) return 8;
- if (fgetc (f) != 'a') return 9;
- if (fgetc (f) != 'b') return 10;
- if (fgetc (f) != EOF) return 11;
- if (fclose (f) != 0) return 12;
- if (remove ("conftest.txt") != 0) return 13;
- return 0;])],
+ [AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <stdio.h>
+]],
+ [FILE *f = fopen ("conftest.txt", "w+");
+ if (!f)
+ return 1;
+ if (fputc ('a', f) != 'a')
+ { fclose (f); return 2; }
+ rewind (f);
+ if (fgetc (f) != 'a')
+ { fclose (f); return 3; }
+ if (fgetc (f) != EOF)
+ { fclose (f); return 4; }
+ if (fpurge (f) != 0)
+ { fclose (f); return 5; }
+ if (putc ('b', f) != 'b')
+ { fclose (f); return 6; }
+ if (fclose (f) != 0)
+ return 7;
+ if ((f = fopen ("conftest.txt", "r")) == NULL)
+ return 8;
+ if (fgetc (f) != 'a')
+ { fclose (f); return 9; }
+ if (fgetc (f) != 'b')
+ { fclose (f); return 10; }
+ if (fgetc (f) != EOF)
+ { fclose (f); return 11; }
+ if (fclose (f) != 0)
+ return 12;
+ if (remove ("conftest.txt") != 0)
+ return 13;
+ return 0;
+ ])],
[gl_cv_func_fpurge_works=yes], [gl_cv_func_fpurge_works=no],
[gl_cv_func_fpurge_works='guessing no'])])
if test "x$gl_cv_func_fpurge_works" != xyes; then
diff --git a/m4/ftello.m4 b/m4/ftello.m4
index 0867c2a..8a4cdc5 100644
--- a/m4/ftello.m4
+++ b/m4/ftello.m4
@@ -1,4 +1,4 @@
-# ftello.m4 serial 11
+# ftello.m4 serial 12
dnl Copyright (C) 2007-2017 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -73,7 +73,7 @@ main (void)
if (fp == NULL)
return 70;
if (fwrite ("foogarsh", 1, 8, fp) < 8)
- return 71;
+ { fclose (fp); return 71; }
if (fclose (fp))
return 72;

@@ -84,19 +84,19 @@ main (void)
if (fp == NULL)
return 73;
if (fseek (fp, -1, SEEK_END))
- return 74;
+ { fclose (fp); return 74; }
if (!(getc (fp) == 'h'))
- return 1;
+ { fclose (fp); return 1; }
if (!(getc (fp) == EOF))
- return 2;
+ { fclose (fp); return 2; }
if (!(ftell (fp) == 8))
- return 3;
+ { fclose (fp); return 3; }
if (!(ftell (fp) == 8))
- return 4;
+ { fclose (fp); return 4; }
if (!(putc ('!', fp) == '!'))
- return 5;
+ { fclose (fp); return 5; }
if (!(ftell (fp) == 9))
- return 6;
+ { fclose (fp); return 6; }
if (!(fclose (fp) == 0))
return 7;
fp = fopen (TESTFILE, "r");
@@ -105,9 +105,9 @@ main (void)
{
char buf[10];
if (!(fread (buf, 1, 10, fp) == 9))
- return 10;
+ { fclose (fp); return 10; }
if (!(memcmp (buf, "foogarsh!", 9) == 0))
- return 11;
+ { fclose (fp); return 11; }
}
if (!(fclose (fp) == 0))
return 12;
diff --git a/m4/getcwd.m4 b/m4/getcwd.m4
index ec6b637..a3f62c4 100644
--- a/m4/getcwd.m4
+++ b/m4/getcwd.m4
@@ -6,7 +6,7 @@
# with or without modifications, as long as this notice is preserved.

# Written by Paul Eggert.
-# serial 13
+# serial 14

AC_DEFUN([gl_FUNC_GETCWD_NULL],
[
@@ -37,9 +37,9 @@ AC_DEFUN([gl_FUNC_GETCWD_NULL],
if (! f)
return 2;
if (f[0] != '/')
- return 3;
+ { free (f); return 3; }
if (f[1] != '\0')
- return 4;
+ { free (f); return 4; }
free (f);
return 0;
}
diff --git a/m4/getdelim.m4 b/m4/getdelim.m4
index 24adb94..67afdba 100644
--- a/m4/getdelim.m4
+++ b/m4/getdelim.m4
@@ -1,4 +1,4 @@
-# getdelim.m4 serial 11
+# getdelim.m4 serial 12

dnl Copyright (C) 2005-2007, 2009-2017 Free Software Foundation, Inc.
dnl
@@ -39,7 +39,7 @@ AC_DEFUN([gl_FUNC_GETDELIM],
size_t siz = 0;
int len = getdelim (&line, &siz, '\n', in);
if (!(len == 4 && line && strcmp (line, "foo\n") == 0))
- return 2;
+ { free (line); fclose (in); return 2; }
}
{
/* Test result for a NULL buffer and a non-zero size.
@@ -47,7 +47,7 @@ AC_DEFUN([gl_FUNC_GETDELIM],
char *line = NULL;
size_t siz = (size_t)(~0) / 4;
if (getdelim (&line, &siz, '\n', in) == -1)
- return 3;
+ { fclose (in); return 3; }
free (line);
}
fclose (in);
diff --git a/m4/getline.m4 b/m4/getline.m4
index dcea772..bd91bef 100644
--- a/m4/getline.m4
+++ b/m4/getline.m4
@@ -1,4 +1,4 @@
-# getline.m4 serial 27
+# getline.m4 serial 28

dnl Copyright (C) 1998-2003, 2005-2007, 2009-2017 Free Software Foundation,
dnl Inc.
@@ -46,7 +46,7 @@ AC_DEFUN([gl_FUNC_GETLINE],
size_t siz = 0;
int len = getline (&line, &siz, in);
if (!(len == 4 && line && strcmp (line, "foo\n") == 0))
- return 2;
+ { free (line); fclose (in); return 2; }
free (line);
}
{
@@ -55,7 +55,7 @@ AC_DEFUN([gl_FUNC_GETLINE],
char *line = NULL;
size_t siz = (size_t)(~0) / 4;
if (getline (&line, &siz, in) == -1)
- return 3;
+ { fclose (in); return 3; }
free (line);
}
fclose (in);
diff --git a/m4/iconv.m4 b/m4/iconv.m4
index bdafc54..81ac1a6 100644
--- a/m4/iconv.m4
+++ b/m4/iconv.m4
@@ -1,4 +1,4 @@
-# iconv.m4 serial 20
+# iconv.m4 serial 21
dnl Copyright (C) 2000-2002, 2007-2014, 2016 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -167,15 +167,27 @@ AC_DEFUN([AM_ICONV_LINK],
#endif
/* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is
provided. */
- if (/* Try standardized names. */
- iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1)
- /* Try IRIX, OSF/1 names. */
- && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1)
- /* Try AIX names. */
- && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1)
- /* Try HP-UX names. */
- && iconv_open ("utf8", "eucJP") == (iconv_t)(-1))
- result |= 16;
+ {
+ /* Try standardized names. */
+ iconv_t cd1 = iconv_open ("UTF-8", "EUC-JP");
+ /* Try IRIX, OSF/1 names. */
+ iconv_t cd2 = iconv_open ("UTF-8", "eucJP");
+ /* Try AIX names. */
+ iconv_t cd3 = iconv_open ("UTF-8", "IBM-eucJP");
+ /* Try HP-UX names. */
+ iconv_t cd4 = iconv_open ("utf8", "eucJP");
+ if (cd1 == (iconv_t)(-1) && cd2 == (iconv_t)(-1)
+ && cd3 == (iconv_t)(-1) && cd4 == (iconv_t)(-1))
+ result |= 16;
+ if (cd1 != (iconv_t)(-1))
+ iconv_close (cd1);
+ if (cd2 != (iconv_t)(-1))
+ iconv_close (cd2);
+ if (cd3 != (iconv_t)(-1))
+ iconv_close (cd3);
+ if (cd4 != (iconv_t)(-1))
+ iconv_close (cd4);
+ }
return result;
]])],
[am_cv_func_iconv_works=yes], ,
diff --git a/m4/memmem.m4 b/m4/memmem.m4
index 9ef4dd4..334cb66 100644
--- a/m4/memmem.m4
+++ b/m4/memmem.m4
@@ -1,4 +1,4 @@
-# memmem.m4 serial 24
+# memmem.m4 serial 25
dnl Copyright (C) 2002-2004, 2007-2017 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -113,6 +113,9 @@ static void quit (int sig) { _exit (sig + 128); }
if (!memmem (haystack, 2 * m + 1, needle, m + 1))
result |= 1;
}
+ /* Free allocated memory, in case some sanitizer is watching. */
+ free (haystack);
+ free (needle);
return result;
]])],
[gl_cv_func_memmem_works_fast=yes], [gl_cv_func_memmem_works_fast=no],
diff --git a/m4/rmdir-errno.m4 b/m4/rmdir-errno.m4
index c290a48..a389329 100644
--- a/m4/rmdir-errno.m4
+++ b/m4/rmdir-errno.m4
@@ -1,4 +1,4 @@
-# serial 10
+# serial 11

# Copyright (C) 2000-2001, 2005-2006, 2009-2017 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
@@ -33,6 +33,7 @@ AC_DEFUN([gl_FUNC_RMDIR_NOTEMPTY],
val = errno;
s = fopen ("confdir2/errno", "w");
fprintf (s, "%d\n", val);
+ fclose (s);
return 0;
}
]])],
diff --git a/m4/signbit.m4 b/m4/signbit.m4
index 9d2b0a8..f387ee9 100644
--- a/m4/signbit.m4
+++ b/m4/signbit.m4
@@ -1,4 +1,4 @@
-# signbit.m4 serial 13
+# signbit.m4 serial 14
dnl Copyright (C) 2007-2017 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -272,6 +272,7 @@ int main ()
{
/* More than one bit difference. */
fprintf (fp, "unknown");
+ fclose (fp);
return 2;
}
if (x)
@@ -284,6 +285,7 @@ int main ()
{
/* No difference. */
fprintf (fp, "unknown");
+ fclose (fp);
return 3;
}
/* Now m = plus.word[k] ^ ~minus.word[k]. */
@@ -292,6 +294,7 @@ int main ()
/* Oh? The sign bit is set in the positive and cleared in the negative
numbers? */
fprintf (fp, "unknown");
+ fclose (fp);
return 4;
}
for (i = 0; ; i++)
diff --git a/m4/strcasestr.m4 b/m4/strcasestr.m4
index 7d15c65..3af9582 100644
--- a/m4/strcasestr.m4
+++ b/m4/strcasestr.m4
@@ -1,4 +1,4 @@
-# strcasestr.m4 serial 21
+# strcasestr.m4 serial 22
dnl Copyright (C) 2005, 2007-2017 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -102,6 +102,9 @@ static void quit (int sig) { _exit (sig + 128); }
if (!strcasestr (haystack, needle))
result |= 1;
}
+ /* Free allocated memory, in case some sanitizer is watching. */
+ free (haystack);
+ free (needle);
return result;
]])],
[gl_cv_func_strcasestr_linear=yes], [gl_cv_func_strcasestr_linear=no],
diff --git a/m4/strstr.m4 b/m4/strstr.m4
index 9f7da64..4b472ee 100644
--- a/m4/strstr.m4
+++ b/m4/strstr.m4
@@ -1,4 +1,4 @@
-# strstr.m4 serial 17
+# strstr.m4 serial 18
dnl Copyright (C) 2008-2017 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -99,6 +99,9 @@ static void quit (int sig) { _exit (sig + 128); }
if (!strstr (haystack, needle))
result |= 1;
}
+ /* Free allocated memory, in case some sanitizer is watching. */
+ free (haystack);
+ free (needle);
return result;
]])],
[gl_cv_func_strstr_linear=yes], [gl_cv_func_strstr_linear=no],
diff --git a/m4/ungetc.m4 b/m4/ungetc.m4
index 9fd3db9..72e8334 100644
--- a/m4/ungetc.m4
+++ b/m4/ungetc.m4
@@ -1,4 +1,4 @@
-# ungetc.m4 serial 3
+# ungetc.m4 serial 4
dnl Copyright (C) 2009-2017 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -14,19 +14,31 @@ AC_DEFUN_ONCE([gl_FUNC_UNGETC_WORKS],
[AC_RUN_IFELSE([AC_LANG_PROGRAM([[
#include <stdio.h>
]], [FILE *f;
- if (!(f = fopen ("conftest.tmp", "w+"))) return 1;
- if (fputs ("abc", f) < 0) return 2;
+ if (!(f = fopen ("conftest.tmp", "w+")))
+ return 1;
+ if (fputs ("abc", f) < 0)
+ { fclose (f); return 2; }
rewind (f);
- if (fgetc (f) != 'a') return 3;
- if (fgetc (f) != 'b') return 4;
- if (ungetc ('d', f) != 'd') return 5;
- if (ftell (f) != 1) return 6;
- if (fgetc (f) != 'd') return 7;
- if (ftell (f) != 2) return 8;
- if (fseek (f, 0, SEEK_CUR) != 0) return 9;
- if (ftell (f) != 2) return 10;
- if (fgetc (f) != 'c') return 11;
- fclose (f); remove ("conftest.tmp");])],
+ if (fgetc (f) != 'a')
+ { fclose (f); return 3; }
+ if (fgetc (f) != 'b')
+ { fclose (f); return 4; }
+ if (ungetc ('d', f) != 'd')
+ { fclose (f); return 5; }
+ if (ftell (f) != 1)
+ { fclose (f); return 6; }
+ if (fgetc (f) != 'd')
+ { fclose (f); return 7; }
+ if (ftell (f) != 2)
+ { fclose (f); return 8; }
+ if (fseek (f, 0, SEEK_CUR) != 0)
+ { fclose (f); return 9; }
+ if (ftell (f) != 2)
+ { fclose (f); return 10; }
+ if (fgetc (f) != 'c')
+ { fclose (f); return 11; }
+ fclose (f);
+ remove ("conftest.tmp");])],
[gl_cv_func_ungetc_works=yes], [gl_cv_func_ungetc_works=no],
[case "$host_os" in
# Guess yes on glibc and bionic systems.
Paul Eggert
2017-05-20 20:53:50 UTC
Permalink
Raw Message
Post by Bruno Haible
Whereas here, memory leaks don't depend on gcc options, nor on the platform.
I was worried more about something like this: a test for feature X has a subtest
for feature Y that fails, then the feature-X test calls fclose but fclose
doesn't free the storage because of the feature-Y failure, so then the test for
X falsely fails because of the leak. I don't want us to get into the business of
debugging fclose internals merely when we're trying to test for feature X. This
is partly why I stopped sanitizing tests last year.

Admittedly I don't have any concrete examples of this right now, but if the
issue starts cropping up then I suspect I will still favor advising people to
avoid leak-testing when running "configure", rather than bothering to plug leaks
in the tests. Leaks are not always bugs.
Bruno Haible
2017-05-21 18:28:32 UTC
Permalink
Raw Message
Post by Paul Eggert
I was worried more about something like this: a test for feature X has a subtest
for feature Y that fails, then the feature-X test calls fclose but fclose
doesn't free the storage because of the feature-Y failure, so then the test for
X falsely fails because of the leak. I don't want us to get into the business of
debugging fclose internals merely when we're trying to test for feature X. This
is partly why I stopped sanitizing tests last year.
I'm not sure I understand.
- Do you mean fclose() could have some bugs that we don't know about yet? I
would better like to know about them.
- Do you mean our tests are so complex that we wouldn't call fclose correctly?
Well, our FILE* tests are simple: They open only one FILE* at a time.
Only our tests with file descriptors are more complex (dup2.m4 and fcntl.m4
in particular), but no sanitizer requires us to avoid file descriptor "leaks".
Post by Paul Eggert
Admittedly I don't have any concrete examples of this right now, but if the
issue starts cropping up then I suspect I will still favor advising people to
avoid leak-testing when running "configure", rather than bothering to plug leaks
in the tests. Leaks are not always bugs.
This advice is good anyway, because we have only fixed the autoconf tests in
gnulib, not the ones that come from the package that uses gnulib.

Bruno
Paul Eggert
2017-05-21 19:09:56 UTC
Permalink
Raw Message
Post by Bruno Haible
- Do you mean fclose() could have some bugs that we don't know about yet?
It could be that. But I was more worried that a feature that we're trying to
test, and which doesn't work, breaks fclose when we try to use the feature.
Loading...