[Patch] Fix libstdc++/12540

Paolo Carlini pcarlini@unitus.it
Thu Oct 16 07:31:00 GMT 2003


Hi,

as per Pétur's PR, running 12352 with LC_ALL not set and LANG set to
something not "C", reveals more leaks due to exceptions unsafety.
Specifically, this one, already hinted to in the report:

==32590== 336 bytes in 56 blocks are definitely lost in loss record 3 of 3
==32590== at 0x4002B6F1: malloc (vg_replace_malloc.c:153)
==32590== by 0x403B9A9F: __GI___strdup (strdup.c:43)
==32590== by 0x4029B564: std::locale::locale(char const*) (locale.cc:219)
==32590== by 0x8048C49: main (12352.cc:86)
==32590== by 0x40353CA5: __libc_start_main 
(../sysdeps/generic/libc-start.c:152)
==32590== by 0x8048940: (within /home/paolo/a.out)

but also this one:

==32590== 208 bytes in 4 blocks are definitely lost in loss record 2 of 3
==32590== at 0x4002B6F1: malloc (vg_replace_malloc.c:153)
==32590== by 0x8048A0F: allocate(unsigned) (12352.cc:13)
==32590== by 0x8048A69: operator new(unsigned) (12352.cc:27)
==32590== by 0x402DBA10: std::moneypunct<wchar_t, 
false>::_M_initialize_moneypunct(__locale_struct*, char const*) 
(monetary_members.cc:454)
==32590== by 0x402BFD24: std::locale::_Impl::_Impl(char const*, 
unsigned) (locale_facets.h:1654)
==32590== by 0x4029B717: std::locale::locale(char const*) (locale.cc:291)
==32590== by 0x8048C49: main (12352.cc:86)
==32590== by 0x40353CA5: __libc_start_main 
(../sysdeps/generic/libc-start.c:152)

I have fixed both in the obvious way, by wrapping the allocations in
appropriate try/catch blocks.

I'm going to look for other issues lurking around, but for now I'd like
to check in this patch to close the report.

Tested x86-linux. Will wait a few hours for comments...

Paolo.

////////////
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: CL_12540
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20031016/c2708062/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch_12540
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20031016/c2708062/attachment-0001.ksh>


More information about the Libstdc++ mailing list