On Sun, Dec 03, 2017 at 05:36:10PM +0200, Lari Rasku wrote:
> OpenBSD nasu.my.domain 6.2 GENERIC.MP#238 amd64.
>
> The following trivial program:
>
> #include <stdio.h>
>
> int
> main(int argc, char *argv[])
> {
> printf("Hello, world!\n");
> return 0;
> }
>
> Gives the following malloc.out output when run with MALLOC_OPTIONS=D:
>
> ******** Start dump testes *******
> MT=0 I=1 F=0 U=0 J=1 R=0 X=0 C=0 cache=64 G=0
> Malloc dir of testes pool 0 at 0x7b935db0050
> Region slots free 511/512
> Finds 0/0
> Inserts 1/0
> Deletes 0/0
> Cheap reallocs 0/0
> In use 77824
> Guarded 0
> Free chunk structs:
> Free pages cached: 0
> slot) hash d type page f size [free/n]
> 8e) # 8e 0 pages 0x7b9f1391000 0x7b70b611bd7 65536
> Leak report
> f sum # avg
> 0x7b70b611bd7 65536 1 65536
>
> ******** End dump testes *******
>
> When fclose(stdout) is added before the return, the leak disappears, so I
> guess libc either doesn't free its own (lazily allocated?) FILE*s, or
> MALLOC_OPTIONS=D dumps its stats before it is done. Closing
> stdin/stdout/stderr probably shouldn't be required of a program to be
> leak-free?
Malloc 'D' is diagnostic aid, with some limitations and to be used
with some understanding on how a C runtime works. In this case, the
"leak" is completely harmless, so I will not spend any effort in fixing
this.
-Otto