public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/24555]  New: Sending output to cout stream sporadically causes segfault
@ 2005-10-27  7:45 springmalnachlinks at yahoo dot de
  2005-10-27  7:46 ` [Bug c++/24555] " springmalnachlinks at yahoo dot de
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: springmalnachlinks at yahoo dot de @ 2005-10-27  7:45 UTC (permalink / raw)
  To: gcc-bugs

Used g++ 4.0.2 with accompanying libstdc++ 4.0.2 under SuSE Linux 10 64-bit and
Ubuntu Linux 5.10 32-bit. Using both 64-bit g++ with and without -m32 switch,
as well as 32-bit g++, cout << occasionally produces a segfault which could not
be reproduced under 3.3.5 or various flavors of 3.4. Downgrading to gcc, g++,
cpp and libcstd++ 3.4 under Ubuntu 5.10 solved the problem, under SuSE 10 this
is more difficult.

In the following code, cout produces a segfault in the second do-while loop but
not in the first, although structurally the two are identical:

        do
        {
                os_clear_screen();
                display_message();
                cout << endl << _BOARDSIZESELECT;
                getline(cin,boardsize_entry_string,'\n');
                check_boardsize();
        } while ((boardsize<3)||(boardsize>8));

        do
        {
                os_clear_screen();
                display_message();
                cout << endl << _PLAYERCOUNTSELECT;
                getline(cin,playercount_entry_string,'\n');
                check_playercount();
        } while ((playercount<1)||(playercount>2));

Replacing cout << with calls to printf seems to solve the problem, but passing
variables of type string to printf requires more effort and more time.


-- 
           Summary: Sending output to cout stream sporadically causes
                    segfault
           Product: gcc
           Version: 4.0.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: springmalnachlinks at yahoo dot de
 GCC build triplet: amd64-pc-linux & i686-pc-linux
  GCC host triplet: amd64-pc-linux & i686-pc-linux
GCC target triplet: amd64-pc-linux & i686-pc-linux


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


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

* [Bug c++/24555] Sending output to cout stream sporadically causes segfault
  2005-10-27  7:45 [Bug c++/24555] New: Sending output to cout stream sporadically causes segfault springmalnachlinks at yahoo dot de
@ 2005-10-27  7:46 ` springmalnachlinks at yahoo dot de
  2005-10-30 13:02 ` pcarlini at suse dot de
  2005-10-30 13:39 ` pcarlini at suse dot de
  2 siblings, 0 replies; 4+ messages in thread
From: springmalnachlinks at yahoo dot de @ 2005-10-27  7:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from springmalnachlinks at yahoo dot de  2005-10-27 07:46 -------
Created an attachment (id=10068)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=10068&action=view)
Tic-Tac-Toe game, which produces the segfault under certain build envs


-- 


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


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

* [Bug c++/24555] Sending output to cout stream sporadically causes segfault
  2005-10-27  7:45 [Bug c++/24555] New: Sending output to cout stream sporadically causes segfault springmalnachlinks at yahoo dot de
  2005-10-27  7:46 ` [Bug c++/24555] " springmalnachlinks at yahoo dot de
@ 2005-10-30 13:02 ` pcarlini at suse dot de
  2005-10-30 13:39 ` pcarlini at suse dot de
  2 siblings, 0 replies; 4+ messages in thread
From: pcarlini at suse dot de @ 2005-10-30 13:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pcarlini at suse dot de  2005-10-30 13:02 -------
This is not a libstdc++-v3 problem. What happens on 4_0-branch is that among
the global strings declared in language.cc and initialized in define_strings(),
when init_game() returns only the first five are ok, the remaining ones are
broken (_M_p = 0x0). Mainline (essentially same basic_string) is ok.


-- 

pcarlini at suse dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|libstdc++                   |c++


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


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

* [Bug c++/24555] Sending output to cout stream sporadically causes segfault
  2005-10-27  7:45 [Bug c++/24555] New: Sending output to cout stream sporadically causes segfault springmalnachlinks at yahoo dot de
  2005-10-27  7:46 ` [Bug c++/24555] " springmalnachlinks at yahoo dot de
  2005-10-30 13:02 ` pcarlini at suse dot de
@ 2005-10-30 13:39 ` pcarlini at suse dot de
  2 siblings, 0 replies; 4+ messages in thread
From: pcarlini at suse dot de @ 2005-10-30 13:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pcarlini at suse dot de  2005-10-30 13:39 -------
I'm closing the PR as invalid: there is a nasty bug in the code: the loop in
init_game() runs up to 8 instead of the correct 7, thus probably overwriting
memory allocated to the strings.


-- 

pcarlini at suse dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


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

end of thread, other threads:[~2005-10-30 13:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-27  7:45 [Bug c++/24555] New: Sending output to cout stream sporadically causes segfault springmalnachlinks at yahoo dot de
2005-10-27  7:46 ` [Bug c++/24555] " springmalnachlinks at yahoo dot de
2005-10-30 13:02 ` pcarlini at suse dot de
2005-10-30 13:39 ` pcarlini at suse dot de

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).