public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/28277] __builtin_alloca with no limit in libstdc++
       [not found] <bug-28277-4@http.gcc.gnu.org/bugzilla/>
@ 2024-03-20  6:16 ` pinskia at gcc dot gnu.org
  2024-03-20 11:21 ` redi at gcc dot gnu.org
  2024-03-20 12:07 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 24+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-20  6:16 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=28277

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |NEW
   Last reconfirmed|2006-07-05 23:00:09         |2024-3-19
           Assignee|paolo.carlini at oracle dot com    |unassigned at gcc dot gnu.org

--- Comment #20 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
here is the current list as far as I can tell:
config/locale/dragonfly/codecvt_members.cc
config/locale/gnu/codecvt_members.cc
config/locale/gnu/messages_members.cc

include/bits/fstream.tcc
include/bits/locale_facets.tcc (some there are ok as the values are actually
constant)
include/bits/locale_facets_nonio.tcc
include/ext/codecvt_specializations.h (BOM case)
include/ext/string_conversions.h
include/std/format (non-char type formating and localization)
src/c++11/functexcept.cc (__throw_out_of_range_fmt)
src/c++11/snprintf_lite.cc (__throw_insufficient_space)

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug libstdc++/28277] __builtin_alloca with no limit in libstdc++
       [not found] <bug-28277-4@http.gcc.gnu.org/bugzilla/>
  2024-03-20  6:16 ` [Bug libstdc++/28277] __builtin_alloca with no limit in libstdc++ pinskia at gcc dot gnu.org
@ 2024-03-20 11:21 ` redi at gcc dot gnu.org
  2024-03-20 12:07 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 24+ messages in thread
From: redi at gcc dot gnu.org @ 2024-03-20 11:21 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=28277

--- Comment #21 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #20)
> here is the current list as far as I can tell:
> config/locale/dragonfly/codecvt_members.cc
> config/locale/gnu/codecvt_members.cc
> config/locale/gnu/messages_members.cc

See above.

> include/bits/fstream.tcc

This is potentially unbounded. A malicious user could use filebuf::setbuf to
give the filebuf a huge buffer, and imbue a custom codecvt facet with a large
do_max_length(). Then the alloca would use buflen * maxlen. That could even
overflow. In practice the maximum size will be BUFSZ*4 or so.

> include/bits/locale_facets.tcc (some there are ok as the values are actually
> constant)

maximum alloca for the formatted integer is sizeof(wchar_t) * 5 * sizeof(long
long) + 1
but then we allocate io.width() * sizeof(wchar_t) which could be set to
something huge by a silly user. We also do three alloca calls in the same
function.

For a formatted float it's numeric_limits<long double>::digits10 * 3 for the
first alloca, but we use alloca several times, and the max depends on
io.precision() and io.width() so we might need a large buffer.

These need some sanity checks, and use the heap as a fallback. See PR 87228 for
that.

> include/bits/locale_facets_nonio.tcc

These are all fixed size and small.

> include/ext/codecvt_specializations.h (BOM case)

Depends on the size of the input being converted, which could be large. This is
unsafe (but I don't think anybody uses this extension).

> include/ext/string_conversions.h

The worst case is std::to_wstring(long double) which uses:

sizeof(wchar_t) * (__numeric_traits<long double>::__max_exponent10 + 20)

So maximum 4 * (4932 + 20) == 19808
That's too big.

> include/std/format (non-char type formating and localization)

Tightly bounded to 2 * ndigits * sizeof(wchar_t) + prefix_len
The worst case is something like std::format("{:#0b}", LLONG_MIN) where the
alloca will be for 2 * 64 * 4 + 3 which is only 515 bytes.

> src/c++11/functexcept.cc (__throw_out_of_range_fmt)

strlen(fmt) + 512, where fmt is ~40 bytes. Users could call that function
themselves, but then that's their problem. It's an internal impl detail, and
our uses are safe.

> src/c++11/snprintf_lite.cc (__throw_insufficient_space)

Another internal impl detail, but this one is not even visible to users. No
declaration in headers, not exported from the shared lib. This one uses alloca
for the same size as __throw_out_of_range_fmt + 104 bytes, but we've already
done the first alloca, so it's (strlen(fmt) + 512) * 2 + 104.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug libstdc++/28277] __builtin_alloca with no limit in libstdc++
       [not found] <bug-28277-4@http.gcc.gnu.org/bugzilla/>
  2024-03-20  6:16 ` [Bug libstdc++/28277] __builtin_alloca with no limit in libstdc++ pinskia at gcc dot gnu.org
  2024-03-20 11:21 ` redi at gcc dot gnu.org
@ 2024-03-20 12:07 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 24+ messages in thread
From: redi at gcc dot gnu.org @ 2024-03-20 12:07 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=28277

--- Comment #22 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #21)
> (In reply to Andrew Pinski from comment #20)
> > src/c++11/snprintf_lite.cc (__throw_insufficient_space)
> 
> Another internal impl detail, but this one is not even visible to users. No
> declaration in headers, not exported from the shared lib. This one uses
> alloca for the same size as __throw_out_of_range_fmt + 104 bytes, but we've
> already done the first alloca, so it's (strlen(fmt) + 512) * 2 + 104.

There's also __concat_size_t in that file, but it only uses alloca for
3*sizeof(size_t), and that is unnecessary and should be replaced with
std::to_chars.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug libstdc++/28277] __builtin_alloca with no limit in libstdc++
  2006-07-05 20:57 [Bug libstdc++/28277] New: " mec at google dot com
                   ` (18 preceding siblings ...)
  2007-04-10 10:39 ` paolo at gcc dot gnu dot org
@ 2007-04-12 23:07 ` paolo at gcc dot gnu dot org
  19 siblings, 0 replies; 24+ messages in thread
From: paolo at gcc dot gnu dot org @ 2007-04-12 23:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #17 from paolo at gcc dot gnu dot org  2007-04-13 00:06 -------
Subject: Bug 28277

Author: paolo
Date: Fri Apr 13 00:06:37 2007
New Revision: 123770

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=123770
Log:
2007-04-12  Paolo Carlini  <pcarlini@suse.de>

        PR libstdc++/28277 (partial: vstring bits)
        * include/bits/ostream_insert.h: New.
        * include/Makefile.am: Add.
        * include/ext/vstring.h (operator<<(basic_ostream<>&,
        const __versa_string<>&): Forward to __ostream_insert.
        * include/bits/basic_string.h (operator<<(basic_ostream<>&,
        const string<>&)): Likewise.
        * include/std/std_ostream.h (operator<<(basic_ostream<>&, _CharT),
        operator<<(basic_ostream<char,>&, char), operator<<(basic_ostream<>&,
        const _CharT*), operator<<(basic_ostream<char,>&, const char*)):
        Likewise.
        * include/ext/vstring.tcc (operator<<(basic_ostream<>&,
        const __versa_string<>&)): Remove.
        (class basic_ostream): Remove friend declarations.
        (basic_ostream<>::_M_write(char_type, streamsize),
        _M_insert(const char_type*, streamsize)): Remove.
        * include/bits/ostream.tcc (_M_insert(const char_type*, streamsize)):
        Remove definition.
        (operator<<(basic_ostream<>&, const char*)): Use __ostream_insert.
        * include/ext/vstring_util.h: Include <bits/ostream_insert.h>.
        * include/std/std_string.h: Likewise.
        * config/abi/pre/gnu.ver: Adjust.
        * src/ostream-inst.cc: Add __ostream_insert instantiations.
        * include/Makefile.in: Rebuild.
        * testsuite/ext/vstring/inserters_extractors/char/28277.cc: New.
        * testsuite/ext/vstring/inserters_extractors/wchar_t/28277.cc: New.

Added:
    branches/gcc-4_2-branch/libstdc++-v3/include/bits/ostream_insert.h
   
branches/gcc-4_2-branch/libstdc++-v3/testsuite/ext/vstring/inserters_extractors/
   
branches/gcc-4_2-branch/libstdc++-v3/testsuite/ext/vstring/inserters_extractors/char/
   
branches/gcc-4_2-branch/libstdc++-v3/testsuite/ext/vstring/inserters_extractors/char/28277.cc
   
branches/gcc-4_2-branch/libstdc++-v3/testsuite/ext/vstring/inserters_extractors/wchar_t/
   
branches/gcc-4_2-branch/libstdc++-v3/testsuite/ext/vstring/inserters_extractors/wchar_t/28277.cc
Modified:
    branches/gcc-4_2-branch/libstdc++-v3/ChangeLog
    branches/gcc-4_2-branch/libstdc++-v3/config/abi/pre/gnu.ver
    branches/gcc-4_2-branch/libstdc++-v3/include/Makefile.am
    branches/gcc-4_2-branch/libstdc++-v3/include/Makefile.in
    branches/gcc-4_2-branch/libstdc++-v3/include/bits/basic_string.h
    branches/gcc-4_2-branch/libstdc++-v3/include/bits/ostream.tcc
    branches/gcc-4_2-branch/libstdc++-v3/include/ext/vstring.h
    branches/gcc-4_2-branch/libstdc++-v3/include/ext/vstring.tcc
    branches/gcc-4_2-branch/libstdc++-v3/include/ext/vstring_util.h
    branches/gcc-4_2-branch/libstdc++-v3/include/std/std_ostream.h
    branches/gcc-4_2-branch/libstdc++-v3/include/std/std_string.h
    branches/gcc-4_2-branch/libstdc++-v3/src/ostream-inst.cc


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28277


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug libstdc++/28277] __builtin_alloca with no limit in libstdc++
  2006-07-05 20:57 [Bug libstdc++/28277] New: " mec at google dot com
                   ` (17 preceding siblings ...)
  2007-04-09 21:36 ` pcarlini at suse dot de
@ 2007-04-10 10:39 ` paolo at gcc dot gnu dot org
  2007-04-12 23:07 ` paolo at gcc dot gnu dot org
  19 siblings, 0 replies; 24+ messages in thread
From: paolo at gcc dot gnu dot org @ 2007-04-10 10:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #16 from paolo at gcc dot gnu dot org  2007-04-10 11:39 -------
Subject: Bug 28277

Author: paolo
Date: Tue Apr 10 11:38:50 2007
New Revision: 123692

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=123692
Log:
2007-04-10  Paolo Carlini  <pcarlini@suse.de>

        PR libstdc++/28277 (partial: vstring bits)
        * include/bits/ostream_insert.h: New.
        * include/Makefile.am: Add.
        * include/ext/vstring.h (operator<<(basic_ostream<>&,
        const __versa_string<>&): Forward to __ostream_insert.
        * include/bits/basic_string.h (operator<<(basic_ostream<>&,
        const string<>&)): Likewise.
        * include/std/ostream (operator<<(basic_ostream<>&, _CharT),
        operator<<(basic_ostream<char,>&, char), operator<<(basic_ostream<>&,
        const _CharT*), operator<<(basic_ostream<char,>&, const char*)):
        Likewise.
        * include/ext/vstring.tcc (operator<<(basic_ostream<>&,
        const __versa_string<>&)): Remove.
        (class basic_ostream): Remove friend declarations.
        (basic_ostream<>::_M_write(char_type, streamsize),
        _M_insert(const char_type*, streamsize)): Remove.
        * include/bits/ostream.tcc (_M_insert(const char_type*, streamsize)):
        Remove definition.
        (operator<<(basic_ostream<>&, const char*)): Use __ostream_insert.
        * config/abi/pre/gnu.ver: Adjust.
        * src/ostream-inst.cc: Add __ostream_insert instantiations.
        * include/bits/locale_facets.h (__pad<>::_S_pad): Remove __num
        parameter.
        * include/bits/locale_facets.tcc (__pad<>::_S_pad): Adjust.
        (num_put<>::_M_pad(_CharT, streamsize, ios_base&, _CharT*,
        const _CharT*, int&)): Likewise.
        * include/Makefile.in: Rebuild.
        * testsuite/ext/vstring/inserters_extractors/char/28277.cc: New.
        * testsuite/ext/vstring/inserters_extractors/wchar_t/28277.cc: New.

        * include/ext/vstring_util.h: Do not include the whole <locale>.
        * include/ext/vstring.tcc (operator>>(basic_istream<>&,
        __versa_string<>&, getline(basic_istream<>&, __versa_string<>&,
        _CharT)): Tweak to refer to ios_base as a base of istream; do not
        refer to non-standard types of istream.
        * include/bits/istream.tcc (operator>>(basic_istream<>&, _CharT*),
        ws(basic_istream<>&)): Do not refer to non-standard types of istream.
        * include/std/bitset (operator>>(std::basic_istream<>&, bitset<>&)):
        Avoid using basic_streambuf<>*.

        * include/bits/istream.tcc (operator>>(basic_istream<>&,
        basic_string<>&), getline(basic_istream<>&, basic_string<>&, _CharT)):
        Move...
        * include/bits/basic_string.tcc: ... here; tweak to refer to ios_base
        as a base of istream; do not refer to non-standard types of istream.
        * include/std/string: Tweak includes.

        * include/ext/type_traits.h (__is_null_pointer): Add.
        * include/ext/rc_string_base.h: Use it.
        * include/ext/sso_string_base.h: Likewise.
        * include/bits/basic_string.tcc (__is_null_pointer): Remove, use
        the above.
        * include/ext/vstring_util.h (__vstring_utility<>::_S_is_null_pointer):
        Remove.

Added:
    trunk/libstdc++-v3/include/bits/ostream_insert.h
    trunk/libstdc++-v3/testsuite/ext/vstring/inserters_extractors/
    trunk/libstdc++-v3/testsuite/ext/vstring/inserters_extractors/char/
    trunk/libstdc++-v3/testsuite/ext/vstring/inserters_extractors/char/28277.cc
    trunk/libstdc++-v3/testsuite/ext/vstring/inserters_extractors/wchar_t/
   
trunk/libstdc++-v3/testsuite/ext/vstring/inserters_extractors/wchar_t/28277.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/config/abi/pre/gnu.ver
    trunk/libstdc++-v3/include/Makefile.am
    trunk/libstdc++-v3/include/Makefile.in
    trunk/libstdc++-v3/include/bits/basic_string.h
    trunk/libstdc++-v3/include/bits/basic_string.tcc
    trunk/libstdc++-v3/include/bits/istream.tcc
    trunk/libstdc++-v3/include/bits/locale_facets.h
    trunk/libstdc++-v3/include/bits/locale_facets.tcc
    trunk/libstdc++-v3/include/bits/ostream.tcc
    trunk/libstdc++-v3/include/ext/rc_string_base.h
    trunk/libstdc++-v3/include/ext/sso_string_base.h
    trunk/libstdc++-v3/include/ext/type_traits.h
    trunk/libstdc++-v3/include/ext/vstring.h
    trunk/libstdc++-v3/include/ext/vstring.tcc
    trunk/libstdc++-v3/include/ext/vstring_util.h
    trunk/libstdc++-v3/include/std/bitset
    trunk/libstdc++-v3/include/std/ostream
    trunk/libstdc++-v3/include/std/string
    trunk/libstdc++-v3/src/ostream-inst.cc


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28277


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug libstdc++/28277] __builtin_alloca with no limit in libstdc++
  2006-07-05 20:57 [Bug libstdc++/28277] New: " mec at google dot com
                   ` (16 preceding siblings ...)
  2006-10-13  9:00 ` paolo at gcc dot gnu dot org
@ 2007-04-09 21:36 ` pcarlini at suse dot de
  2007-04-10 10:39 ` paolo at gcc dot gnu dot org
  2007-04-12 23:07 ` paolo at gcc dot gnu dot org
  19 siblings, 0 replies; 24+ messages in thread
From: pcarlini at suse dot de @ 2007-04-09 21:36 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #15 from pcarlini at suse dot de  2007-04-09 22:35 -------
Doesn't really block this one.


-- 

pcarlini at suse dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|29236                       |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28277


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug libstdc++/28277] __builtin_alloca with no limit in libstdc++
  2006-07-05 20:57 [Bug libstdc++/28277] New: " mec at google dot com
                   ` (15 preceding siblings ...)
  2006-10-09 18:04 ` paolo at gcc dot gnu dot org
@ 2006-10-13  9:00 ` paolo at gcc dot gnu dot org
  2007-04-09 21:36 ` pcarlini at suse dot de
                   ` (2 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: paolo at gcc dot gnu dot org @ 2006-10-13  9:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #14 from paolo at gcc dot gnu dot org  2006-10-13 09:00 -------
Subject: Bug 28277

Author: paolo
Date: Fri Oct 13 09:00:31 2006
New Revision: 117689

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117689
Log:
2006-10-13  Paolo Carlini  <pcarlini@suse.de>

        PR libstdc++/28277 (partial: ostream bits 2)
        * include/std/std_ostream.h (basic_ostream<>::_M_insert(const
        char_type*, streamsize)): New.
        (basic_ostream<>::_M_write(char_type, streamsize)): Likewise.
        (operator<<(basic_ostream<>&, _CharT), operator<<(basic_ostream<>&,
        char), operator<<(basic_ostream<>&, const _CharT*),
        operator<<(basic_ostream<>&, const char*)): Use the latter.
        * include/bits/ostream.tcc (basic_ostream<>::_M_insert(const
        char_type*, streamsize)): Define.
        (operator<<(basic_ostream<>&, const char*)): Use the latter.
        (operator<<(basic_ostream<>&, _CharT), operator<<(basic_ostream<>&,
        char), operator<<(basic_ostream<>&, const _CharT*),
        operator<<(basic_ostream<>&, const char*),
        operator<<(basic_ostream<>&, const basic_string<>&)): Remove.
        * include/bits/basic_string.h (operator<<(basic_ostream<>&,
        const basic_string<>&)): Use the latter, implement DR 586.
        * config/abi/pre/gnu.ver: Adjust, export the new _M_insert.
        * docs/html/ext/howto.html: Add an entry for DR 586.
        * testsuite/21_strings/basic_string/inserters_extractors/char/
        28277.cc: New.
        * testsuite/21_strings/basic_string/inserters_extractors/wchar_t/
        28277.cc: Likewise.
        * testsuite/27_io/basic_ostream/inserters_character/char/
        28277-3.cc: Likewise.
        * testsuite/27_io/basic_ostream/inserters_character/char/
        28277-4.cc: Likewise.
        * testsuite/27_io/basic_ostream/inserters_character/wchar_t/
        28277-2.cc: Likewise.
        * testsuite/27_io/basic_ostream/inserters_character/wchar_t/
        28277-3.cc: Likewise.
        * testsuite/27_io/basic_ostream/inserters_character/wchar_t/
        28277-4.cc: Likewise.


Added:
   
trunk/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/28277.cc
   
trunk/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/28277.cc
   
trunk/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/28277-3.cc
   
trunk/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/28277-4.cc
   
trunk/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/wchar_t/28277-2.cc
   
trunk/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/wchar_t/28277-3.cc
   
trunk/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/wchar_t/28277-4.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/config/abi/pre/gnu.ver
    trunk/libstdc++-v3/docs/html/ext/howto.html
    trunk/libstdc++-v3/include/bits/basic_string.h
    trunk/libstdc++-v3/include/bits/ostream.tcc
    trunk/libstdc++-v3/include/std/std_ostream.h


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28277


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug libstdc++/28277] __builtin_alloca with no limit in libstdc++
  2006-07-05 20:57 [Bug libstdc++/28277] New: " mec at google dot com
                   ` (14 preceding siblings ...)
  2006-10-09 10:50 ` paolo at gcc dot gnu dot org
@ 2006-10-09 18:04 ` paolo at gcc dot gnu dot org
  2006-10-13  9:00 ` paolo at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: paolo at gcc dot gnu dot org @ 2006-10-09 18:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #13 from paolo at gcc dot gnu dot org  2006-10-09 18:04 -------
Subject: Bug 28277

Author: paolo
Date: Mon Oct  9 18:04:18 2006
New Revision: 117581

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117581
Log:
2006-10-09  Paolo Carlini  <pcarlini@suse.de>

        PR libstdc++/28277 (partial: __add_grouping)
        * include/bits/locale_facets.tcc (__add_grouping<>(_CharT*, _CharT,
        const char*, size_t, const _CharT*, const _CharT*)): Rewrite in
        non-recursive form.

Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/bits/locale_facets.tcc


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28277


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug libstdc++/28277] __builtin_alloca with no limit in libstdc++
  2006-07-05 20:57 [Bug libstdc++/28277] New: " mec at google dot com
                   ` (13 preceding siblings ...)
  2006-10-08  1:13 ` paolo at gcc dot gnu dot org
@ 2006-10-09 10:50 ` paolo at gcc dot gnu dot org
  2006-10-09 18:04 ` paolo at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: paolo at gcc dot gnu dot org @ 2006-10-09 10:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from paolo at gcc dot gnu dot org  2006-10-09 10:50 -------
Subject: Bug 28277

Author: paolo
Date: Mon Oct  9 10:49:50 2006
New Revision: 117571

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117571
Log:
2006-10-09  Paolo Carlini  <pcarlini@suse.de>

        PR libstdc++/28277 (partial: money_put bits)
        * include/bits/locale_facets.tcc (money_put<>::_M_insert(iter_type,
        ios_base&, char_type, const string_type&)): Avoid __builtin_alloca
        with no limit, do the work in place.

        * include/bits/locale_facets.tcc (money_put<>::do_put(iter_type,
        bool, ios_base&, char_type, long double)): Avoid unnecessary
        __builtin_alloca, do the work in place.

Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/bits/locale_facets.tcc


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28277


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug libstdc++/28277] __builtin_alloca with no limit in libstdc++
  2006-07-05 20:57 [Bug libstdc++/28277] New: " mec at google dot com
                   ` (12 preceding siblings ...)
  2006-07-16 15:39 ` paolo at gcc dot gnu dot org
@ 2006-10-08  1:13 ` paolo at gcc dot gnu dot org
  2006-10-09 10:50 ` paolo at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: paolo at gcc dot gnu dot org @ 2006-10-08  1:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from paolo at gcc dot gnu dot org  2006-10-08 01:13 -------
Subject: Bug 28277

Author: paolo
Date: Sun Oct  8 01:13:03 2006
New Revision: 117549

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117549
Log:
2006-10-07  Paolo Carlini  <pcarlini@suse.de>

        PR libstdc++/28277 (partial: money_get bits)
        * include/bits/locale_facets.tcc (money_get<>::do_get(iter_type,
        iter_type, bool, ios_base&, ios_base::iostate&, string_type&)):
        Avoid __builtin_alloca with no limit, do the work in place.

Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/bits/locale_facets.tcc


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28277


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug libstdc++/28277] __builtin_alloca with no limit in libstdc++
  2006-07-05 20:57 [Bug libstdc++/28277] New: " mec at google dot com
                   ` (11 preceding siblings ...)
  2006-07-15 20:31 ` paolo at gcc dot gnu dot org
@ 2006-07-16 15:39 ` paolo at gcc dot gnu dot org
  2006-10-08  1:13 ` paolo at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: paolo at gcc dot gnu dot org @ 2006-07-16 15:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from paolo at gcc dot gnu dot org  2006-07-16 15:39 -------
Subject: Bug 28277

Author: paolo
Date: Sun Jul 16 15:38:59 2006
New Revision: 115501

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=115501
Log:
2006-07-16  Paolo Carlini  <pcarlini@suse.de>

        PR libstdc++/28277 (partial: valarray bits)
        * include/std/std_valarray.h (valarray<>::shift(int),
        valarray<>::cshift(int)): Avoid __builtin_alloca with no limit,
        do the work in place.
        * testsuite/26_numerics/valarray/28277.cc: New.

Added:
    trunk/libstdc++-v3/testsuite/26_numerics/valarray/28277.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/std/std_valarray.h


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28277


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug libstdc++/28277] __builtin_alloca with no limit in libstdc++
  2006-07-05 20:57 [Bug libstdc++/28277] New: " mec at google dot com
                   ` (10 preceding siblings ...)
  2006-07-11 11:22 ` paolo at gcc dot gnu dot org
@ 2006-07-15 20:31 ` paolo at gcc dot gnu dot org
  2006-07-16 15:39 ` paolo at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: paolo at gcc dot gnu dot org @ 2006-07-15 20:31 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from paolo at gcc dot gnu dot org  2006-07-15 20:30 -------
Subject: Bug 28277

Author: paolo
Date: Sat Jul 15 20:30:50 2006
New Revision: 115485

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=115485
Log:
2006-07-15  Paolo Carlini  <pcarlini@suse.de>

        PR libstdc++/28277 (partial: ostream bits 1)
        * include/bits/ostream.tcc (operator<<(basic_ostream<_CharT>&,
        const char*)): Avoid __builtin_alloca with no limit in the
        widening.
        * testsuite/27_io/basic_ostream/inserters_character/wchar_t/
        28277-1.cc: New.


Added:
   
trunk/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/wchar_t/28277-1.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/bits/ostream.tcc


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28277


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug libstdc++/28277] __builtin_alloca with no limit in libstdc++
  2006-07-05 20:57 [Bug libstdc++/28277] New: " mec at google dot com
                   ` (9 preceding siblings ...)
  2006-07-08  9:45 ` pcarlini at suse dot de
@ 2006-07-11 11:22 ` paolo at gcc dot gnu dot org
  2006-07-15 20:31 ` paolo at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: paolo at gcc dot gnu dot org @ 2006-07-11 11:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from paolo at gcc dot gnu dot org  2006-07-11 11:21 -------
Subject: Bug 28277

Author: paolo
Date: Tue Jul 11 11:21:38 2006
New Revision: 115332

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=115332
Log:
2006-07-11  Paolo Carlini  <pcarlini@suse.de>

        PR libstdc++/28277 (partial: collate bits)
        * include/bits/locale_facets.tcc (collate<>::do_transform(
        const _CharT*, const _CharT*)): Avoid __builtin_alloca with no
        limit; also avoid multiple calls (in a loop).
        * testsuite/22_locale/collate/transform/char/28277.cc: New.
        * testsuite/22_locale/collate/transform/wchar_t/28277.cc: Likewise.

Added:
    trunk/libstdc++-v3/testsuite/22_locale/collate/transform/char/28277.cc
    trunk/libstdc++-v3/testsuite/22_locale/collate/transform/wchar_t/28277.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/bits/locale_facets.tcc


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28277


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug libstdc++/28277] __builtin_alloca with no limit in libstdc++
  2006-07-05 20:57 [Bug libstdc++/28277] New: " mec at google dot com
                   ` (8 preceding siblings ...)
  2006-07-05 23:17 ` pcarlini at suse dot de
@ 2006-07-08  9:45 ` pcarlini at suse dot de
  2006-07-11 11:22 ` paolo at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: pcarlini at suse dot de @ 2006-07-08  9:45 UTC (permalink / raw)
  To: gcc-bugs



-- 

pcarlini at suse dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |pcarlini at suse dot de
                   |dot org                     |
             Status|NEW                         |ASSIGNED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28277


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug libstdc++/28277] __builtin_alloca with no limit in libstdc++
  2006-07-05 20:57 [Bug libstdc++/28277] New: " mec at google dot com
                   ` (7 preceding siblings ...)
  2006-07-05 23:00 ` pcarlini at suse dot de
@ 2006-07-05 23:17 ` pcarlini at suse dot de
  2006-07-08  9:45 ` pcarlini at suse dot de
                   ` (10 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: pcarlini at suse dot de @ 2006-07-05 23:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from pcarlini at suse dot de  2006-07-05 23:17 -------
Humm, at least the various instances of the problem related to padding seem
simple to fix, by just doing the I/O as part of the padding itself - it's *the
last* stage of the processing anyway...


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28277


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug libstdc++/28277] __builtin_alloca with no limit in libstdc++
  2006-07-05 20:57 [Bug libstdc++/28277] New: " mec at google dot com
                   ` (6 preceding siblings ...)
  2006-07-05 23:00 ` pcarlini at suse dot de
@ 2006-07-05 23:00 ` pcarlini at suse dot de
  2006-07-05 23:17 ` pcarlini at suse dot de
                   ` (11 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: pcarlini at suse dot de @ 2006-07-05 23:00 UTC (permalink / raw)
  To: gcc-bugs



-- 

pcarlini at suse dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|pcarlini at suse dot de     |unassigned at gcc dot gnu
                   |                            |dot org
             Status|ASSIGNED                    |NEW


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28277


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug libstdc++/28277] __builtin_alloca with no limit in libstdc++
  2006-07-05 20:57 [Bug libstdc++/28277] New: " mec at google dot com
                   ` (5 preceding siblings ...)
  2006-07-05 22:48 ` pcarlini at suse dot de
@ 2006-07-05 23:00 ` pcarlini at suse dot de
  2006-07-05 23:00 ` pcarlini at suse dot de
                   ` (12 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: pcarlini at suse dot de @ 2006-07-05 23:00 UTC (permalink / raw)
  To: gcc-bugs



-- 

pcarlini at suse dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |pcarlini at suse dot de
                   |dot org                     |
           Severity|normal                      |enhancement
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2006-07-05 23:00:09
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28277


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug libstdc++/28277] __builtin_alloca with no limit in libstdc++
  2006-07-05 20:57 [Bug libstdc++/28277] New: " mec at google dot com
                   ` (4 preceding siblings ...)
  2006-07-05 22:43 ` mec at google dot com
@ 2006-07-05 22:48 ` pcarlini at suse dot de
  2006-07-05 23:00 ` pcarlini at suse dot de
                   ` (13 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: pcarlini at suse dot de @ 2006-07-05 22:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pcarlini at suse dot de  2006-07-05 22:48 -------
(In reply to comment #5)
> The threads point is just a basic stack size issue: threads on linux have a
> fixed size which is often smaller than the main stack size limit.

Ok then.

> With an output width of 60 million, it's easy to see a failure, even on a main
> stack.
> 
> hollerith:~/exp-string-width$ ulimit -Ss
> 8192
> hollerith:~/exp-string-width$ /home/mec/gcc-4.2-20060624/install/bin/g++ z1.cc
> hollerith:~/exp-string-width$ a.out > /dev/null
> Segmentation fault

Note, in general, I guess we are often going to fail anyway (at least for some
of the pointed out uses) only, throwing a bad_alloc exception instead of
seg-faulting, I hope that is acceptable...


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28277


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug libstdc++/28277] __builtin_alloca with no limit in libstdc++
  2006-07-05 20:57 [Bug libstdc++/28277] New: " mec at google dot com
                   ` (3 preceding siblings ...)
  2006-07-05 22:32 ` pcarlini at suse dot de
@ 2006-07-05 22:43 ` mec at google dot com
  2006-07-05 22:48 ` pcarlini at suse dot de
                   ` (14 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: mec at google dot com @ 2006-07-05 22:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from mec at google dot com  2006-07-05 22:43 -------
The threads point is just a basic stack size issue: threads on linux have a
fixed size which is often smaller than the main stack size limit.

With an output width of 60 million, it's easy to see a failure, even on a main
stack.

hollerith:~/exp-string-width$ ulimit -Ss
8192
hollerith:~/exp-string-width$ /home/mec/gcc-4.2-20060624/install/bin/g++ z1.cc
hollerith:~/exp-string-width$ a.out > /dev/null
Segmentation fault

I agree, this would be best fixed, carefully, in mainline, and then flow into
releases in the fullness of time.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28277


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug libstdc++/28277] __builtin_alloca with no limit in libstdc++
  2006-07-05 20:57 [Bug libstdc++/28277] New: " mec at google dot com
                   ` (2 preceding siblings ...)
  2006-07-05 22:27 ` pinskia at physics dot uc dot edu
@ 2006-07-05 22:32 ` pcarlini at suse dot de
  2006-07-05 22:43 ` mec at google dot com
                   ` (15 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: pcarlini at suse dot de @ 2006-07-05 22:32 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pcarlini at suse dot de  2006-07-05 22:32 -------
(In reply to comment #2)
> Sure, here is a test program for versa_string:

Ok, the stack thing is rather straightforward but of course we should first dig
the archives and find when and why, **a lot** of time ago, such uses have been
considered appropriate (the pattern in versa_string is just copied over from
completely similar patterns used elsewhere, obviously). I believe we can work
on it, *very* careful with memory leaks, most likely GCC 4.3 material. Please
explain in better detail the threads point, however.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28277


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug libstdc++/28277] __builtin_alloca with no limit in libstdc++
  2006-07-05 20:57 [Bug libstdc++/28277] New: " mec at google dot com
  2006-07-05 21:48 ` [Bug libstdc++/28277] " pcarlini at suse dot de
  2006-07-05 22:21 ` mec at google dot com
@ 2006-07-05 22:27 ` pinskia at physics dot uc dot edu
  2006-07-05 22:32 ` pcarlini at suse dot de
                   ` (16 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: pinskia at physics dot uc dot edu @ 2006-07-05 22:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at physics dot uc dot edu  2006-07-05 22:27 -------
Subject: Re:  __builtin_alloca with no limit in libstdc++

> 
> 
>   std::cout.width(60000000);
> This program allocates 60 million bytes on the stack in the last output
> statement.

You get what you deserve really.  If there are checks then it will be slow.

-- Pinski


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28277


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Bug libstdc++/28277] __builtin_alloca with no limit in libstdc++
  2006-07-05 22:21 ` mec at google dot com
@ 2006-07-05 22:27   ` Andrew Pinski
  0 siblings, 0 replies; 24+ messages in thread
From: Andrew Pinski @ 2006-07-05 22:27 UTC (permalink / raw)
  To: gcc-bugzilla; +Cc: gcc-bugs

> 
> 
>   std::cout.width(60000000);
> This program allocates 60 million bytes on the stack in the last output
> statement.

You get what you deserve really.  If there are checks then it will be slow.

-- Pinski


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug libstdc++/28277] __builtin_alloca with no limit in libstdc++
  2006-07-05 20:57 [Bug libstdc++/28277] New: " mec at google dot com
  2006-07-05 21:48 ` [Bug libstdc++/28277] " pcarlini at suse dot de
@ 2006-07-05 22:21 ` mec at google dot com
  2006-07-05 22:27   ` Andrew Pinski
  2006-07-05 22:27 ` pinskia at physics dot uc dot edu
                   ` (17 subsequent siblings)
  19 siblings, 1 reply; 24+ messages in thread
From: mec at google dot com @ 2006-07-05 22:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from mec at google dot com  2006-07-05 22:20 -------
Sure, here is a test program for versa_string:

// Copyright 2006, Google Inc.  All rights reserved.
// Author: mec@google.com  (Michael Chastain)
//
// Test operator<<(ostream&, const versa_string&)

#include <ext/vstring.h>
#include <iostream>

int main() {
  __gnu_cxx::__versa_string<
    char, std::char_traits<char>, std::allocator<char>
    > s("Hello world");
  std::cout << s << std::endl;
  std::cout.width(60);
  std::cout << s << std::endl;
  std::cout.width(6000);
  std::cout << s << std::endl;
  std::cout.width(60000000);
  std::cout << s << std::endl;
  return 0;
}

This program allocates 60 million bytes on the stack in the last output
statement.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28277


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Bug libstdc++/28277] __builtin_alloca with no limit in libstdc++
  2006-07-05 20:57 [Bug libstdc++/28277] New: " mec at google dot com
@ 2006-07-05 21:48 ` pcarlini at suse dot de
  2006-07-05 22:21 ` mec at google dot com
                   ` (18 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: pcarlini at suse dot de @ 2006-07-05 21:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pcarlini at suse dot de  2006-07-05 21:47 -------
(In reply to comment #0)
> These have data-dependent sizes with no obvious limit, which does not mix well
> with threads and small stacks.

I suppose you are going to provide additional details... 


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28277


^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2024-03-20 12:07 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-28277-4@http.gcc.gnu.org/bugzilla/>
2024-03-20  6:16 ` [Bug libstdc++/28277] __builtin_alloca with no limit in libstdc++ pinskia at gcc dot gnu.org
2024-03-20 11:21 ` redi at gcc dot gnu.org
2024-03-20 12:07 ` redi at gcc dot gnu.org
2006-07-05 20:57 [Bug libstdc++/28277] New: " mec at google dot com
2006-07-05 21:48 ` [Bug libstdc++/28277] " pcarlini at suse dot de
2006-07-05 22:21 ` mec at google dot com
2006-07-05 22:27   ` Andrew Pinski
2006-07-05 22:27 ` pinskia at physics dot uc dot edu
2006-07-05 22:32 ` pcarlini at suse dot de
2006-07-05 22:43 ` mec at google dot com
2006-07-05 22:48 ` pcarlini at suse dot de
2006-07-05 23:00 ` pcarlini at suse dot de
2006-07-05 23:00 ` pcarlini at suse dot de
2006-07-05 23:17 ` pcarlini at suse dot de
2006-07-08  9:45 ` pcarlini at suse dot de
2006-07-11 11:22 ` paolo at gcc dot gnu dot org
2006-07-15 20:31 ` paolo at gcc dot gnu dot org
2006-07-16 15:39 ` paolo at gcc dot gnu dot org
2006-10-08  1:13 ` paolo at gcc dot gnu dot org
2006-10-09 10:50 ` paolo at gcc dot gnu dot org
2006-10-09 18:04 ` paolo at gcc dot gnu dot org
2006-10-13  9:00 ` paolo at gcc dot gnu dot org
2007-04-09 21:36 ` pcarlini at suse dot de
2007-04-10 10:39 ` paolo at gcc dot gnu dot org
2007-04-12 23:07 ` paolo at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).