[jira] [Updated] (STDCXX-1058) std::basic_ios::copyfmt() with registered callback (via std::ios_base::register_callback()) run-time SIGABRT

2012-02-05 Thread Farid Zaripov (Updated) (JIRA)

 [ 
https://issues.apache.org/jira/browse/STDCXX-1058?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Farid Zaripov updated STDCXX-1058:
--

Description: 
A stream with a registered callback via register_callback() SIGABRTs at 
run-time:

{code}
#include iostream
#include fstream

int x;

void testfun (std::ios_base::event ev, std::ios_base iosobj, int index)
{
  x = index;

  switch (ev)
  {
case std::ios_base::copyfmt_event:
  std::cerr  copyfmt_event  std::endl; break;
case std::ios_base::imbue_event:
  std::cerr  imbue_event  std::endl; break;
case std::ios_base::erase_event:
  std::cerr  erase_event  std::endl; break;
default:
  std::cerr  unknown  std::endl; break;
  }
}

int main ()
{
  std::fstream f0;
  std::fstream f1;
  int i = 101;

  std::ios_base::event_callback e1 = testfun;
  f0.register_callback (e1, i);

  x = 0;
  f0.imbue (std::cerr.getloc());
  if (x != i)
std::cerr  x: expected   i   got   x  std::endl;

  x = 0;
  f0.copyfmt (f1);
  if (x != i)
std::cerr  x: expected   i   got   x  std::endl;

  return 0;
}
{code}

Output from GCC 4.5.0:
{noformat}
[steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/fstream.copyfmt][02/05/2012
 0:32:42][1340] ./test-gcc 
imbue_event
erase_event
{noformat}

Output from Sun C++ 12.2 with stlport4:
{noformat}
[steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/fstream.copyfmt][02/05/2012
 0:32:44][1341] ./test-ss12-stlport 
imbue_event
erase_event
copyfmt_event
erase_event
{noformat}

Output from Sun C++ 12.2 with our stdcxx (patched):
{noformat}
[steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/fstream.copyfmt][02/05/2012
 0:32:58][1342] ./test-ss12-stdcxx 
imbue_event
erase_event
{noformat}

Output from Pathscale 4.0.12.1 (which didn't patch stdcxx):
{noformat}
[steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/fstream.copyfmt][02/05/2012
 0:33:03][1343] ./test-pathscale 
imbue_event
erase_event
*** glibc detected *** ./test-pathscale: double free or corruption (fasttop): 
0x 0605480 ***
=== Backtrace: =
/lib64/libc.so.6(+0x73286)[0x7f78cbb7f286]
/lib64/libc.so.6(cfree+0x6c)[0x7f78cbb8402c]
/opt/pathscale/ekopath-4.0.12.1/lib/4.0.12.1/x8664/64/libcxxrt.so(_ZdlPv+0xd)[0x
 f78cc097d63]
/opt/pathscale/ekopath-4.0.12.1/lib/4.0.12.1/x8664/64/libstl.so(_ZNSt8ios_base11
 C_usr_data10_C_deallocEPS0_+0x2d)[0x7f78cc300b5b]
=== Memory map: 
0040-00404000 r-xp  103:00 9582413   
/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/fstream.copyfmt/test-pathscale
00603000-00604000 r--p 3000 103:00 9582413   
/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/fstream.copyfmt/test-pathscale
00604000-00605000 rw-p 4000 103:00 9582413   
/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/fstream.copyfmt/test-pathscale
00605000-00626000 rw-p  00:00 0  [heap]

[ ... ]
{noformat}

I no longer have an unpatched stdcxx handy for the Sun C++ compilers available
to reproduce the defect with the Sun C++ compiler.

Defect is in file src/iostore.cpp, starting at line 275:

_C_usr-_C_iarray, _C_usr-_C_parray and _C_usr-_C_cbarray
are not set to NULL after deletion:

{code}
_TRY {
if (_C_usr) {
// fire erase events (27.4.4.2, p17) - may throw
if (_C_usr-_C_fire)
(this-*_C_usr-_C_fire)(erase_event, true /* reentrant */);

// delete existing arrays, if any; _C_usr will only be deleted
// if `rhs' contains no user data (see below)
operator delete (_C_usr-_C_iarray);
_C_usr-_C_iarray = 0UL; // - !!
operator delete (_C_usr-_C_parray);
_C_usr-_C_parray = 0UL; // - !!
operator delete (_C_usr-_C_cbarray);
_C_usr-_C_cbarray = 0UL; // - !!
}
{code}

Patch for 4.2.1 to follow shortly.


  was:
A stream with a registered callback via register_callback() SIGABRTs at 
run-time:

#include iostream
#include fstream

int x;

void testfun (std::ios_base::event ev, std::ios_base iosobj, int index)
{
  x = index;

  switch (ev)
  {
case std::ios_base::copyfmt_event:
  std::cerr  copyfmt_event  std::endl; break;
case std::ios_base::imbue_event:
  std::cerr  imbue_event  std::endl; break;
case std::ios_base::erase_event:
  std::cerr  erase_event  std::endl; break;
default:
  std::cerr  unknown  std::endl; break;
  }
}

int main ()
{
  std::fstream f0;
  std::fstream f1;
  int i = 101;

  std::ios_base::event_callback e1 = testfun;
  f0.register_callback (e1, i);

  x = 0;
  f0.imbue (std::cerr.getloc());
  if (x != i)
std::cerr  x: expected   i   got   x  std::endl;

  x = 0;
  f0.copyfmt (f1);
  if (x != i)
std::cerr  x: expected   i   

[jira] [Issue Comment Edited] (STDCXX-1058) std::basic_ios::copyfmt() with registered callback (via std::ios_base::register_callback()) run-time SIGABRT

2012-02-05 Thread Farid Zaripov (Issue Comment Edited) (JIRA)

[ 
https://issues.apache.org/jira/browse/STDCXX-1058?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13200704#comment-13200704
 ] 

Farid Zaripov edited comment on STDCXX-1058 at 2/5/12 9:46 AM:
---

Fixed formatting using tags from 
[here|https://issues.apache.org/jira/secure/WikiRendererHelpAction.jspa?section=all].

  was (Author: farid):
Fixed formatting using {code} and {noformat} tags.
  
 std::basic_ios::copyfmt() with registered callback (via 
 std::ios_base::register_callback()) run-time SIGABRT 
 ---

 Key: STDCXX-1058
 URL: https://issues.apache.org/jira/browse/STDCXX-1058
 Project: C++ Standard Library
  Issue Type: Bug
  Components: 27. Input/Output
Affects Versions: 4.2.1, 4.2.x, 4.3.x, 5.0.0
 Environment: Solaris 10 and 11, Red Hat Linux, OpenSuSE Linux
 Sun C++ Compilers 12.1, 12.2, 12.3
 Defect is independent of platform or compiler.
Reporter: Stefan Teleman
  Labels: crash, segmenation_fault
 Fix For: 4.2.x, 4.3.x, 5.0.0

 Attachments: test.cc


 A stream with a registered callback via register_callback() SIGABRTs at 
 run-time:
 {code}
 #include iostream
 #include fstream
 int x;
 void testfun (std::ios_base::event ev, std::ios_base iosobj, int index)
 {
   x = index;
   switch (ev)
   {
 case std::ios_base::copyfmt_event:
   std::cerr  copyfmt_event  std::endl; break;
 case std::ios_base::imbue_event:
   std::cerr  imbue_event  std::endl; break;
 case std::ios_base::erase_event:
   std::cerr  erase_event  std::endl; break;
 default:
   std::cerr  unknown  std::endl; break;
   }
 }
 int main ()
 {
   std::fstream f0;
   std::fstream f1;
   int i = 101;
   std::ios_base::event_callback e1 = testfun;
   f0.register_callback (e1, i);
   x = 0;
   f0.imbue (std::cerr.getloc());
   if (x != i)
 std::cerr  x: expected   i   got   x  std::endl;
   x = 0;
   f0.copyfmt (f1);
   if (x != i)
 std::cerr  x: expected   i   got   x  std::endl;
   return 0;
 }
 {code}
 Output from GCC 4.5.0:
 {noformat}
 [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/fstream.copyfmt][02/05/2012
  0:32:42][1340] ./test-gcc 
 imbue_event
 erase_event
 {noformat}
 Output from Sun C++ 12.2 with stlport4:
 {noformat}
 [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/fstream.copyfmt][02/05/2012
  0:32:44][1341] ./test-ss12-stlport 
 imbue_event
 erase_event
 copyfmt_event
 erase_event
 {noformat}
 Output from Sun C++ 12.2 with our stdcxx (patched):
 {noformat}
 [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/fstream.copyfmt][02/05/2012
  0:32:58][1342] ./test-ss12-stdcxx 
 imbue_event
 erase_event
 {noformat}
 Output from Pathscale 4.0.12.1 (which didn't patch stdcxx):
 {noformat}
 [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/fstream.copyfmt][02/05/2012
  0:33:03][1343] ./test-pathscale 
 imbue_event
 erase_event
 *** glibc detected *** ./test-pathscale: double free or corruption (fasttop): 
 0x 0605480 ***
 === Backtrace: =
 /lib64/libc.so.6(+0x73286)[0x7f78cbb7f286]
 /lib64/libc.so.6(cfree+0x6c)[0x7f78cbb8402c]
 /opt/pathscale/ekopath-4.0.12.1/lib/4.0.12.1/x8664/64/libcxxrt.so(_ZdlPv+0xd)[0x
  f78cc097d63]
 /opt/pathscale/ekopath-4.0.12.1/lib/4.0.12.1/x8664/64/libstl.so(_ZNSt8ios_base11
  C_usr_data10_C_deallocEPS0_+0x2d)[0x7f78cc300b5b]
 === Memory map: 
 0040-00404000 r-xp  103:00 9582413   
 /src/steleman/programming/stdcxx-ss122/bugfixes-sunw/fstream.copyfmt/test-pathscale
 00603000-00604000 r--p 3000 103:00 9582413   
 /src/steleman/programming/stdcxx-ss122/bugfixes-sunw/fstream.copyfmt/test-pathscale
 00604000-00605000 rw-p 4000 103:00 9582413   
 /src/steleman/programming/stdcxx-ss122/bugfixes-sunw/fstream.copyfmt/test-pathscale
 00605000-00626000 rw-p  00:00 0  
 [heap]
 [ ... ]
 {noformat}
 I no longer have an unpatched stdcxx handy for the Sun C++ compilers available
 to reproduce the defect with the Sun C++ compiler.
 Defect is in file src/iostore.cpp, starting at line 275:
 _C_usr-_C_iarray, _C_usr-_C_parray and _C_usr-_C_cbarray
 are not set to NULL after deletion:
 {code}
 _TRY {
 if (_C_usr) {
 // fire erase events (27.4.4.2, p17) - may throw
 if (_C_usr-_C_fire)
 (this-*_C_usr-_C_fire)(erase_event, true /* reentrant */);
 // delete existing arrays, if any; _C_usr will only be deleted
 // if `rhs' contains no user data (see below)
 operator delete 

[jira] [Updated] (STDCXX-1059) std::ios_base::setf() and std::ios_base::unsetf() do not set/clear the format flags correctly

2012-02-05 Thread Stefan Teleman (Updated) (JIRA)

 [ 
https://issues.apache.org/jira/browse/STDCXX-1059?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Stefan Teleman updated STDCXX-1059:
---

Description: 
std::ios_base::setf (fmtflags fl) and std::ios_base::unsetf (fmtflags fl)
do not set or clear the format flags correctly:

{code:title=test.cc|borderStyle=solid}
#include ios
#include iostream
#include fstream

int main()
{
std::fstream strm;
std::ios_base::fmtflags fl;
int ret = 0;

fl = std::ios_base::dec;
strm.unsetf(fl);

fl = std::ios_base::hex;

strm.setf(fl);
strm.unsetf(fl);

if (strm.flags()  fl)
{
std::cerr  failure to clear hex flags  std::endl;
++ret;
}

return ret;
}
{code}

1. Output from GCC 4.5.0:
{noformat}
[steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/fmtflags][02/05/2012
 15:19:37][1957] ./test-gcc 
[steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/fmtflags][02/05/2012
 15:20:02][1958] echo $status
0
{noformat}

2. Output from Sun C++ 12.2 with stlport:
{noformat}
[steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/fmtflags][02/05/2012
 15:20:24][1959] ./test-ss122-stlport 
[steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/fmtflags][02/05/2012
 15:21:08][1960] echo $status
0
{noformat}

3. Output rom Sun C++ 12.2 with our patched stdcxx:
{noformat}
[steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/fmtflags][02/05/2012
 15:21:09][1961] ./test-ss122-stdcxx 
[steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/fmtflags][02/05/2012
 15:21:44][1962] echo $status
0
{noformat}

4. Output from Pathscale 4.0.12.1 (which did not patch stdcxx):
{noformat}
[steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/fmtflags][02/05/2012
 15:21:46][1963] ./test-pathscale 
failure to clear hex flags
[steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/fmtflags][02/05/2012
 15:22:48][1964] echo $status
1
{noformat}

Simplified test case identifying the problem:
{code:title=flags.cc|borderStyle=solid}

#include iostream
#include ios

class BadTest
{
public:
BadTest() : _flags(0) { }
~BadTest() { }

unsigned int flags() const { return _flags; }
unsigned int flags (unsigned int f)
{
unsigned int ret = _flags;
_flags |= f;
return ret;
}
unsigned int setf (unsigned int f) { return flags (flags() | f); }
void unsetf (unsigned int f) { flags (flags()  ~f); }

private:
unsigned int _flags;
};

class GoodTest
{
public:
GoodTest() : _flags(0) { }
~GoodTest() { }

unsigned int flags() const { return _flags; }
unsigned int flags (unsigned int f)
{
unsigned int ret = _flags;
_flags |= f;
return ret;
}
unsigned int setf (unsigned int f)
{
unsigned int ret = _flags;
_flags |= f;
return ret;
}
void unsetf (unsigned int f) { _flags = ~f; }

private:
unsigned int _flags;
};

int main()
{
BadTest bt;
std::ios_base::fmtflags fl;

std::cerr  * BadTest *  std::endl;
std::cerr  default flags:   bt.flags()  std::endl;

fl = std::ios_base::dec;

bt.setf(fl);
std::cerr  flags:   bt.flags()  std::endl;

bt.unsetf(fl);
std::cerr  flags:   bt.flags()  std::endl;

fl = std::ios_base::hex;

bt.setf(fl);
std::cerr  flags:   bt.flags()  std::endl;

bt.unsetf(fl);
std::cerr  flags:   bt.flags()  std::endl;

std::cerr  std::endl;

GoodTest gt;
std::cerr  * GoodTest *  std::endl;
std::cerr  default flags:   gt.flags()  std::endl;

fl = std::ios_base::dec;

gt.setf(fl);
std::cerr  flags:   gt.flags()  std::endl;

gt.unsetf(fl);
std::cerr  flags:   gt.flags()  std::endl;

fl = std::ios_base::hex;

gt.setf(fl);
std::cerr  flags:   gt.flags()  std::endl;

gt.unsetf(fl);
std::cerr  flags:   gt.flags()  std::endl;

return 0;
}
{code}

1. Output from GCC 4.5.0:
{noformat}
[steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/fmtflags][02/05/2012
 15:27:01][1968] ./flags-gcc 
* BadTest *
default flags: 0
flags: 2
flags: 2
flags: 10
flags: 10

* GoodTest *
default flags: 0
flags: 2
flags: 0
flags: 8
flags: 0
{noformat}

2. Output from Sun C++ 12.2 with stlport:
{noformat}
[steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/fmtflags][02/05/2012
 15:27:05][1969] ./flags-ss122-stlport 
* BadTest *
default flags: 0
flags: 8
flags: 8
flags: 24
flags: 24

* GoodTest *
default flags: 0
flags: 8
flags: 0
flags: 16
flags: 0
{noformat}

3. Output from Sun C++ 12.2. with our patched stdcxx:
{noformat}
[steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/fmtflags][02/05/2012
 15:27:12][1970] ./flags-ss122-stdcxx 
* 

[jira] [Updated] (STDCXX-1059) std::ios_base::setf() and std::ios_base::unsetf() do not set/clear the format flags correctly

2012-02-05 Thread Stefan Teleman (Updated) (JIRA)

 [ 
https://issues.apache.org/jira/browse/STDCXX-1059?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Stefan Teleman updated STDCXX-1059:
---

Attachment: flags.cc

 std::ios_base::setf() and std::ios_base::unsetf() do not set/clear the format 
 flags correctly
 -

 Key: STDCXX-1059
 URL: https://issues.apache.org/jira/browse/STDCXX-1059
 Project: C++ Standard Library
  Issue Type: Bug
  Components: 27. Input/Output
Affects Versions: 4.2.1, 4.2.x, 4.3.x, 5.0.0
 Environment: Solaris 10 and 11
 Red Hat Linux, OpenSuSE Linux
 Sun C++ Compilers 12.1, 12.2, 12.3
 Defect is independent of platform and/or compiler
Reporter: Stefan Teleman
  Labels: conformance, runtime, standards
 Fix For: 4.2.2, 4.2.x, 4.3.x, 5.0.0

 Attachments: flags.cc, test.cc


 std::ios_base::setf (fmtflags fl) and std::ios_base::unsetf (fmtflags fl)
 do not set or clear the format flags correctly:
 {code:title=test.cc|borderStyle=solid}
 #include ios
 #include iostream
 #include fstream
 int main()
 {
 std::fstream strm;
 std::ios_base::fmtflags fl;
 int ret = 0;
 fl = std::ios_base::dec;
 strm.unsetf(fl);
 fl = std::ios_base::hex;
 strm.setf(fl);
 strm.unsetf(fl);
 if (strm.flags()  fl)
 {
 std::cerr  failure to clear hex flags  std::endl;
 ++ret;
 }
 return ret;
 }
 {code}
 1. Output from GCC 4.5.0:
 {noformat}
 [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/fmtflags][02/05/2012
  15:19:37][1957] ./test-gcc 
 [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/fmtflags][02/05/2012
  15:20:02][1958] echo $status
 0
 {noformat}
 2. Output from Sun C++ 12.2 with stlport:
 {noformat}
 [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/fmtflags][02/05/2012
  15:20:24][1959] ./test-ss122-stlport 
 [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/fmtflags][02/05/2012
  15:21:08][1960] echo $status
 0
 {noformat}
 3. Output rom Sun C++ 12.2 with our patched stdcxx:
 {noformat}
 [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/fmtflags][02/05/2012
  15:21:09][1961] ./test-ss122-stdcxx 
 [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/fmtflags][02/05/2012
  15:21:44][1962] echo $status
 0
 {noformat}
 4. Output from Pathscale 4.0.12.1 (which did not patch stdcxx):
 {noformat}
 [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/fmtflags][02/05/2012
  15:21:46][1963] ./test-pathscale 
 failure to clear hex flags
 [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/fmtflags][02/05/2012
  15:22:48][1964] echo $status
 1
 {noformat}
 Simplified test case identifying the problem:
 {code:title=flags.cc|borderStyle=solid}
 #include iostream
 #include ios
 class BadTest
 {
 public:
 BadTest() : _flags(0) { }
 ~BadTest() { }
 unsigned int flags() const { return _flags; }
 unsigned int flags (unsigned int f)
 {
 unsigned int ret = _flags;
 _flags |= f;
 return ret;
 }
 unsigned int setf (unsigned int f) { return flags (flags() | f); }
 void unsetf (unsigned int f) { flags (flags()  ~f); }
 private:
 unsigned int _flags;
 };
 class GoodTest
 {
 public:
 GoodTest() : _flags(0) { }
 ~GoodTest() { }
 unsigned int flags() const { return _flags; }
 unsigned int flags (unsigned int f)
 {
 unsigned int ret = _flags;
 _flags |= f;
 return ret;
 }
 unsigned int setf (unsigned int f)
 {
 unsigned int ret = _flags;
 _flags |= f;
 return ret;
 }
 void unsetf (unsigned int f) { _flags = ~f; }
 private:
 unsigned int _flags;
 };
 int main()
 {
 BadTest bt;
 std::ios_base::fmtflags fl;
 std::cerr  * BadTest *  std::endl;
 std::cerr  default flags:   bt.flags()  std::endl;
 fl = std::ios_base::dec;
 bt.setf(fl);
 std::cerr  flags:   bt.flags()  std::endl;
 bt.unsetf(fl);
 std::cerr  flags:   bt.flags()  std::endl;
 fl = std::ios_base::hex;
 bt.setf(fl);
 std::cerr  flags:   bt.flags()  std::endl;
 bt.unsetf(fl);
 std::cerr  flags:   bt.flags()  std::endl;
 std::cerr  std::endl;
 GoodTest gt;
 std::cerr  * GoodTest *  std::endl;
 std::cerr  default flags:   gt.flags()  std::endl;
 fl = std::ios_base::dec;
 gt.setf(fl);
 std::cerr  flags:   gt.flags()  std::endl;
 gt.unsetf(fl);
 std::cerr  flags:   gt.flags()  std::endl;
 fl = std::ios_base::hex;
 gt.setf(fl);
 std::cerr  flags:   gt.flags()  std::endl;
 gt.unsetf(fl);
 std::cerr  flags:   gt.flags()  std::endl;
 

[jira] [Updated] (STDCXX-1060) std::basic_string::append(char*, pos) SIGSEGV for pos == std::string::npos

2012-02-05 Thread Stefan Teleman (Updated) (JIRA)

 [ 
https://issues.apache.org/jira/browse/STDCXX-1060?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Stefan Teleman updated STDCXX-1060:
---

Patch Info: Patch Available

 std::basic_string::append(char*, pos) SIGSEGV for pos == std::string::npos
 --

 Key: STDCXX-1060
 URL: https://issues.apache.org/jira/browse/STDCXX-1060
 Project: C++ Standard Library
  Issue Type: Bug
  Components: 21. Strings
Affects Versions: 4.2.1, 4.2.x, 4.3.x, 5.0.0
 Environment: Solaris 10 and 11
 Red Hat Linux, OpenSuSE Linux
 Sun C++ Compiler 12.1, 12.2, 12.3
 Defect is independent of platform/compiler
Reporter: Stefan Teleman
  Labels: conformance, segmenation_fault, standards
 Fix For: 4.2.2, 4.2.x, 4.3.x, 5.0.0

 Attachments: stdcxx-1060.patch, test.cc


 std::basic_string::append(char*, pos) SIGSEGV for pos == std::string::npos:
 {code:title=test.cc|borderStyle=solid}
 #include iostream
 #include string
 #include stdexcept
 int main()
 {
 const char* c = hello;
 std::string s(5, '*');
 std::string t;
 int ret;
 try
 {
 t = s.append(c, std::string::npos);
 }
 catch (std::length_error e)
 {
 ret = 0;
 }
 catch ( ... )
 {
 std::cerr  wrong exception was thrown!  std::endl;
 ret = 1;
 }
 std::cerr  t:   t.c_str()  std::endl;
 std::cerr  s:   s.c_str()  std::endl;
 return ret;
 }
 {code}
 1. Output from GCC 4.5.0:
 {noformat}
 [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889785][02/05/2012
  21:56:30][2023] ./test-gcc 
 t: 
 s: *
 [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889785][02/05/2012
  22:04:45][2024] echo $status
 0
 {noformat}
 2. Output from Sun C++ 12.2 with stlport:
 {noformat}
 [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889785][02/05/2012
  22:04:47][2025] ./test-ss122-stlport 
 t: 
 s: *
 [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889785][02/05/2012
  22:04:53][2026] echo $status
 0
 {noformat}
 3. Output from Sun C++ 12.2 with our patched stdcxx:
 {noformat}
 [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889785][02/05/2012
  22:04:55][2027] ./test-ss122-stdcxx 
 t: 
 s: *
 [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889785][02/05/2012
  22:05:00][2028] echo $status
 0
 {noformat}
 4. Output from Pathscale 4.0.12.1 (which did not patch stdcxx):
 {noformat}
 [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889785][02/05/2012
  22:05:02][2029] ./test-pathscale 
 Segmentation fault (core dumped)
 [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889785][02/05/2012
  22:05:08][2030] echo $status
 139
 {noformat}
 Defect is in file include/string, line 874.
 Patch for stdcxx 4.2.1 to follow shortly.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira