bug-bash
[Top][All Lists]
Advanced

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

Re: Leaks detected by valgrind


From: Chet Ramey
Subject: Re: Leaks detected by valgrind
Date: Thu, 13 Apr 2017 16:23:19 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

On 4/13/17 4:12 PM, Reuben Thomas wrote:
> Here they are. I guess you probably won't care about them as as far as I
> can see they are all one-off allocations at initialization:
> 
> ==1289== 276 bytes in 1 blocks are definitely lost in loss record 230 of 249
> ==1289==    at 0x4C2DB2F: malloc (in
> /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
> ==1289==    by 0x4793CF: xmalloc (xmalloc.c:112)
> ==1289==    by 0x472F48: set_default_locale (locale.c:81)
> ==1289==    by 0x420900: main (shell.c:411)

This one is interesting. It's come up before. Bash makes a copy of the
default locale (as returned by setlocale()) for its own purposes.  Some
systems use a static buffer for that value; some systems, including glibc,
return allocated memory (even though the man page warns to not assume
anything about the returned string).

You're right about the two buffers for setlinebuf().

Thanks.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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