public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/59974] New: ostream crashes on large numbers under Windows
@ 2014-01-28 23:28 steve at sk2 dot org
  2014-01-28 23:29 ` [Bug libstdc++/59974] " steve at sk2 dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: steve at sk2 dot org @ 2014-01-28 23:28 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 59974
           Summary: ostream crashes on large numbers under Windows
           Product: gcc
           Version: 4.6.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: steve at sk2 dot org

Created attachment 31972
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31972&action=edit
Test case

This is forwarded from http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=736946
and courtesy of Jeff Epler.

The attached program crashes when built with x86_64-w64-mingw32-g++ or
i686-w64-mingw32-g++.

The underlying cause is an assumption that snprintf never returns -1.  In fact,
on Windows, the platform snprintf returns -1 when the buffer is not big
enough, which leads to (A) calling alloca(-1) and (B) calling std::widen
with fin < st, either one of which is probably enough to lead to a
crash.

The patch shown below fixes several locations in libstdc++ where a
negative return value from snprintf was not properly handled.

The bug was filed against gcc 4.6.3 but it also applies to 4.8.2 and the
current 4.9 snapshot in Debian (20140122).

Note that the mingw-w64 can mask this bug by providing its own vsnprintf
implementation when building libstdc++.

Regards,

Stephen


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

end of thread, other threads:[~2023-06-09 11:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-28 23:28 [Bug libstdc++/59974] New: ostream crashes on large numbers under Windows steve at sk2 dot org
2014-01-28 23:29 ` [Bug libstdc++/59974] " steve at sk2 dot org
2014-01-28 23:33 ` pinskia at gcc dot gnu.org
2014-01-28 23:36 ` steve at sk2 dot org
2023-06-09  1:52 ` 10walls at gmail dot com
2023-06-09  9:45 ` redi at gcc dot gnu.org
2023-06-09 11:18 ` steve at sk2 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).