template<typename Facet> locale locale::combine(locale l1, locale l2) const leaks memory if an exception is thrown because Facet isn't found in l2.
Created attachment 4851 [details] Test case
The signature of combine is of course template<typename Facet> locale locale::combine(const locale& l2) const
Confirmed. Seems easy to fix, now ;)
Hi Pétur. How many iterations do you think are necessary? I have tried up to 1000000 without an hard fail (disk thrashing, however). Thanks, Paolo.
> How many iterations do you think are necessary? I have tried up to > 1000000 without an hard fail (disk thrashing, however). The program won't crash until it runs out of memory, which may take a very long time. There is a function named set_memory_limits() in testsuite_hooks.h. Maybe you can use that to make the program run out of memory sooner? I don't think we want tests that use all virtual memory in the system, or that take several hours to run.
Thanks Pétur, I will make use of your suggestion!
Subject: Bug 12438 CVSROOT: /cvs/gcc Module name: gcc Changes by: paolo@gcc.gnu.org 2003-09-30 13:45:00 Modified files: libstdc++-v3 : ChangeLog libstdc++-v3/include/bits: locale_facets.tcc locale_classes.h Added files: libstdc++-v3/testsuite/22_locale/locale/cons: 12438.cc Log message: 2003-09-30 Paolo Carlini <pcarlini@unitus.it> PR libstdc++/12438 * include/bits/locale_facets.tcc (locale::combine): Don't leak memory if _M_replace_facet throws. * testsuite/22_locale/locale/cons/12438.cc: New, from the PR. * include/bits/locale_classes.h (locale::locale(const locale&, _Facet*)): Tweak, use consistently _M_remove_reference. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/ChangeLog.diff?cvsroot=gcc&r1=1.1977&r2=1.1978 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/locale_facets.tcc.diff?cvsroot=gcc&r1=1.112&r2=1.113 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/locale_classes.h.diff?cvsroot=gcc&r1=1.11&r2=1.12 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/22_locale/locale/cons/12438.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1
Fixed.
Subject: Bug 12438 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_3-branch Changes by: paolo@gcc.gnu.org 2004-01-19 00:12:55 Modified files: libstdc++-v3 : ChangeLog libstdc++-v3/include/bits: locale_classes.h locale_facets.tcc libstdc++-v3/src: locale.cc localename.cc Log message: 2004-01-19 Paolo Carlini <pcarlini@suse.de> PR libstdc++/12352 PR libstdc++/12438 * include/bits/locale_classes.h (locale::locale(const locale&, _Facet*)): Don't leak memory on exception. * include/bits/locale_facets.tcc (locale::combine(const locale&)): Likewise. * src/locale.cc (locale::locale(const char*)): Likewise. * src/localename.cc (locale::_Impl::~_Impl(), locale::_Impl::_Impl(const _Impl&, size_t), locale::_Impl::_Impl(const char*, size_t)): Likewise. (locale::_Impl::_M_replace_categories(const _Impl*, category): Tweak. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.1464.2.165&r2=1.1464.2.166 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/locale_classes.h.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.1.2.3&r2=1.1.2.4 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/locale_facets.tcc.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.82.4.14&r2=1.82.4.15 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/src/locale.cc.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.72.2.4&r2=1.72.2.5 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/src/localename.cc.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.33.2.4&r2=1.33.2.5