public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/13858] New: Bad error handling in basic_filebuf::imbue
@ 2004-01-25 17:39 peturr02 at ru dot is
  2004-01-25 17:39 ` [Bug libstdc++/13858] " peturr02 at ru dot is
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: peturr02 at ru dot is @ 2004-01-25 17:39 UTC (permalink / raw)
  To: gcc-bugs

basic_filebuf::imbue currently calls _M_terminate_output() (which calls
overflow()) like this:

                    }
                }
              else if (_M_writing && (__testvalid = _M_terminate_output()))
                _M_set_buffer(-1);
            }
        }

      if (__testvalid)
        _M_codecvt = _M_codecvt_tmp;
    }

There are two problems with this:
1) Failures in overflow() are not reported;
2) If overflow() fails, _M_codecvt is not updated. After imbue returns,
pubimbue assigns __loc to _M_buf_locale, which may cause the facet pointed
to by _M_codecvt to be deleted, leaving _M_codecvt as a dangling pointer.

Both problems can probably be solved by throwing an exception if overflow()
fails.

-- 
           Summary: Bad error handling in basic_filebuf::imbue
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: peturr02 at ru dot is
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

* [Bug libstdc++/13858] Bad error handling in basic_filebuf::imbue
  2004-01-25 17:39 [Bug libstdc++/13858] New: Bad error handling in basic_filebuf::imbue peturr02 at ru dot is
@ 2004-01-25 17:39 ` peturr02 at ru dot is
  2004-01-25 17:40 ` peturr02 at ru dot is
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: peturr02 at ru dot is @ 2004-01-25 17:39 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From peturr02 at ru dot is  2004-01-25 17:39 -------
Created an attachment (id=5573)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=5573&action=view)
Test case for char


-- 


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


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

* [Bug libstdc++/13858] Bad error handling in basic_filebuf::imbue
  2004-01-25 17:39 [Bug libstdc++/13858] New: Bad error handling in basic_filebuf::imbue peturr02 at ru dot is
  2004-01-25 17:39 ` [Bug libstdc++/13858] " peturr02 at ru dot is
@ 2004-01-25 17:40 ` peturr02 at ru dot is
  2004-01-25 17:46 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: peturr02 at ru dot is @ 2004-01-25 17:40 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From peturr02 at ru dot is  2004-01-25 17:40 -------
Created an attachment (id=5574)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=5574&action=view)
Test case for wchar_t


-- 


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


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

* [Bug libstdc++/13858] Bad error handling in basic_filebuf::imbue
  2004-01-25 17:39 [Bug libstdc++/13858] New: Bad error handling in basic_filebuf::imbue peturr02 at ru dot is
  2004-01-25 17:39 ` [Bug libstdc++/13858] " peturr02 at ru dot is
  2004-01-25 17:40 ` peturr02 at ru dot is
@ 2004-01-25 17:46 ` pinskia at gcc dot gnu dot org
  2004-01-25 17:53 ` pcarlini at suse dot de
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-01-25 17:46 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-01-25 17:46 -------
Confirmed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-01-25 17:46:52
               date|                            |


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


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

* [Bug libstdc++/13858] Bad error handling in basic_filebuf::imbue
  2004-01-25 17:39 [Bug libstdc++/13858] New: Bad error handling in basic_filebuf::imbue peturr02 at ru dot is
                   ` (2 preceding siblings ...)
  2004-01-25 17:46 ` pinskia at gcc dot gnu dot org
@ 2004-01-25 17:53 ` pcarlini at suse dot de
  2004-02-14 19:04 ` cvs-commit at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pcarlini at suse dot de @ 2004-01-25 17:53 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pcarlini at suse dot de  2004-01-25 17:53 -------
One more reason to have exception thrown by overflow similarly to what
already happens for underflow! (indeed, this kind of work was already in my
todo list, but it's nice to have some good testcases!)

-- 
           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=13858


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

* [Bug libstdc++/13858] Bad error handling in basic_filebuf::imbue
  2004-01-25 17:39 [Bug libstdc++/13858] New: Bad error handling in basic_filebuf::imbue peturr02 at ru dot is
                   ` (3 preceding siblings ...)
  2004-01-25 17:53 ` pcarlini at suse dot de
@ 2004-02-14 19:04 ` cvs-commit at gcc dot gnu dot org
  2004-02-14 19:45 ` cvs-commit at gcc dot gnu dot org
  2004-02-14 19:52 ` pcarlini at suse dot de
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-02-14 19:04 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-02-14 19:04 -------
Subject: Bug 13858

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	paolo@gcc.gnu.org	2004-02-14 19:04:01

Modified files:
	libstdc++-v3   : ChangeLog 
	libstdc++-v3/include/bits: fstream.tcc 
	libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char: 
	                                                          9182-2.cc 
	libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/wchar_t: 3.cc 
	libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/wchar_t: 1.cc 
	libstdc++-v3/testsuite/27_io/basic_filebuf/sync/char: 9182-1.cc 
Added files:
	libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char: 
	                                                          13858.cc 
	libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t: 
	                                                             13858.cc 

Log message:
	2004-02-14  Paolo Carlini  <pcarlini@suse.de>
	
	PR libstdc++/13858
	* include/bits/fstream.tcc (basic_filebuf<>::_M_convert_to_external):
	In case of conversion errors, throw ios_failure; simplify.
	* testsuite/27_io/basic_filebuf/overflow/char/13858.cc: New.
	* testsuite/27_io/basic_filebuf/overflow/wchar_t/13858.cc: Ditto.
	* testsuite/27_io/basic_filebuf/overflow/char/9182-2.cc: Tweak,
	previously we didn't throw in case of conversion errors, instead
	just returned eof().
	* testsuite/27_io/basic_filebuf/seekoff/wchar_t/3.cc: Ditto.
	* testsuite/27_io/basic_filebuf/seekpos/wchar_t/1.cc: Ditto.
	* testsuite/27_io/basic_filebuf/sync/char/9182-1.cc: Ditto.
	
	* include/bits/fstream.tcc (basic_filebuf<>::overflow):
	Trivial simplification of a conditional.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/ChangeLog.diff?cvsroot=gcc&r1=1.2329&r2=1.2330
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/fstream.tcc.diff?cvsroot=gcc&r1=1.119&r2=1.120
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/13858.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/9182-2.cc.diff?cvsroot=gcc&r1=1.2&r2=1.3
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/13858.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/wchar_t/3.cc.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/wchar_t/1.cc.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/basic_filebuf/sync/char/9182-1.cc.diff?cvsroot=gcc&r1=1.2&r2=1.3



-- 


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


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

* [Bug libstdc++/13858] Bad error handling in basic_filebuf::imbue
  2004-01-25 17:39 [Bug libstdc++/13858] New: Bad error handling in basic_filebuf::imbue peturr02 at ru dot is
                   ` (4 preceding siblings ...)
  2004-02-14 19:04 ` cvs-commit at gcc dot gnu dot org
@ 2004-02-14 19:45 ` cvs-commit at gcc dot gnu dot org
  2004-02-14 19:52 ` pcarlini at suse dot de
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-02-14 19:45 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-02-14 19:45 -------
Subject: Bug 13858

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	paolo@gcc.gnu.org	2004-02-14 19:45:34

Modified files:
	libstdc++-v3   : ChangeLog 
	libstdc++-v3/include/bits: fstream.tcc 
	libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char: 
	                                                          9182-2.cc 
	libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/wchar_t: 3.cc 
	libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/wchar_t: 1.cc 
	libstdc++-v3/testsuite/27_io/basic_filebuf/sync/char: 9182-1.cc 
Added files:
	libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char: 
	                                                          13858.cc 
	libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t: 
	                                                             13858.cc 

Log message:
	2004-02-14  Paolo Carlini  <pcarlini@suse.de>
	
	PR libstdc++/13858
	* include/bits/fstream.tcc (basic_filebuf<>::_M_convert_to_external):
	In case of conversion errors, throw ios_failure; simplify.
	* testsuite/27_io/basic_filebuf/overflow/char/13858.cc: New.
	* testsuite/27_io/basic_filebuf/overflow/wchar_t/13858.cc: Ditto.
	* testsuite/27_io/basic_filebuf/overflow/char/9182-2.cc: Tweak,
	previously we didn't throw in case of conversion errors, instead
	just returned eof().
	* testsuite/27_io/basic_filebuf/seekoff/wchar_t/3.cc: Ditto.
	* testsuite/27_io/basic_filebuf/seekpos/wchar_t/1.cc: Ditto.
	* testsuite/27_io/basic_filebuf/sync/char/9182-1.cc: Ditto.
	
	* include/bits/fstream.tcc (basic_filebuf<>::overflow):
	Trivial simplification of a conditional.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.2224.2.34&r2=1.2224.2.35
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/fstream.tcc.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.116.4.2&r2=1.116.4.3
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/13858.cc.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/9182-2.cc.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.2&r2=1.2.12.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/13858.cc.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/wchar_t/3.cc.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.1&r2=1.1.12.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/wchar_t/1.cc.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.1&r2=1.1.12.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/basic_filebuf/sync/char/9182-1.cc.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.2&r2=1.2.12.1



-- 


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


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

* [Bug libstdc++/13858] Bad error handling in basic_filebuf::imbue
  2004-01-25 17:39 [Bug libstdc++/13858] New: Bad error handling in basic_filebuf::imbue peturr02 at ru dot is
                   ` (5 preceding siblings ...)
  2004-02-14 19:45 ` cvs-commit at gcc dot gnu dot org
@ 2004-02-14 19:52 ` pcarlini at suse dot de
  6 siblings, 0 replies; 8+ messages in thread
From: pcarlini at suse dot de @ 2004-02-14 19:52 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pcarlini at suse dot de  2004-02-14 19:52 -------
Fixed for 3.4.0.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |3.4.0


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


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

end of thread, other threads:[~2004-02-14 19:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-25 17:39 [Bug libstdc++/13858] New: Bad error handling in basic_filebuf::imbue peturr02 at ru dot is
2004-01-25 17:39 ` [Bug libstdc++/13858] " peturr02 at ru dot is
2004-01-25 17:40 ` peturr02 at ru dot is
2004-01-25 17:46 ` pinskia at gcc dot gnu dot org
2004-01-25 17:53 ` pcarlini at suse dot de
2004-02-14 19:04 ` cvs-commit at gcc dot gnu dot org
2004-02-14 19:45 ` cvs-commit at gcc dot gnu dot org
2004-02-14 19:52 ` 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).