You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by Martin Sebor <se...@roguewave.com> on 2005/12/17 03:30:06 UTC

Re: problem with older Standard Library

Jeremy Dean wrote:
> I am working on RedHat 3.0 with the gcc 3.2.3 compiler and also the
> Rogue
> Wave 6 standard librarby version.  
>  
> I get a memory fault with the following testcase:

A stack trace would be helpful. But I wonder how you got the test
case to compile -- it contains a couple of errors:

> 
> #include <map>
> #include <string>
> #include <set>
> class MyClass
> {
>  public:
>   MyClass(const std::string& value_) 
>   : _value(value_) {}
>   string _value;
     ^^^^^^

This should be std::string.


> };  
> typedef std::set<MyClass*> MyClassSet;
> typedef std::map<std::string, MyClassSet> MyMap;
> static MyClassSet createSet()
> {
>   MyClassSet s;
>   s.insert(new MyClass("test"));
>   return s;
> }
> int main()
> {
>   MyMap m;
>   string key("key");
     ^^^^^^
Same here.

>   m.insert(MyMap::value_type(key, createSet()));
>   return 0; 
> }
> 
>  
> Any ideas what might be the problem?

I'm not sure. After fixing the two errors I compiled the test case
with SunPro 5.7 and ran it under dbx with memory checking enabled.
Below is the stack trace I got. I don't quite understand what's
going on there yet. Let me spend some time debugging it and get
back to you (in the meantime, you might want to do the same in
case you spot the cause of the problem before I do :)

Martin


$ dbx t
...
(dbx) check -all
access checking - ON
memuse checking - ON
(dbx) run
Running: t
(process id 6563)
Reading rtcapihook.so
Reading libdl.so.1
Reading rtcaudit.so
Reading libmapmalloc.so.1
Reading libgen.so.1
Reading libc_psr.so.1
Reading rtcboot.so
Reading librtc.so
RTC: Enabling Error Checking...
RTC: Running program...
Read from uninitialized (rui) on thread 1:
Attempting to read 3 bytes at address 0xffbff5f1
     which is 265 bytes above the current stack pointer
t@1 (l@1) stopped in 
std::pair<__rw::__rw_debug_iter<__rw::__rb_tree<MyClass*,MyClass*,__rw::__ident<MyClass*,MyClass*>,std::less<MyClass*>,std::allocator<MyClass*> 
 >,__rw::__rw_tree_iter<MyClass*,int,MyClass**,MyClass*&,__rw::__rw_rb_tree_node<std::allocator<MyClass*>,MyClass*,MyClass*,__rw::__ident<MyClass*,MyClass*> 
 > 
 >,__rw::__rw_tree_iter<MyClass*,int,MyClass**,MyClass*&,__rw::__rw_rb_tree_node<std::allocator<MyClass*>,MyClass*,MyClass*,__rw::__ident<MyClass*,MyClass*> 
 > > >,bool>::operator= at 0x000253bc
0x000253bc: operator=+0x0024:   ba,a     0x00058294     ! 0x58294

(dbx) where
current thread: t@1
=>[1] 
std::pair<__rw::__rw_debug_iter<__rw::__rb_tree<MyClass*,MyClass*,__rw::__ident<MyClass*,MyClass*>,std::less<MyClass*>,std::allocator<MyClass*> 
 >,__rw::__rw_tree_iter<MyClass*,int,MyClass**,MyClass*&,__rw::__rw_rb_tree_node<std::allocator<MyClass*>,MyClass*,MyClass*,__rw::__ident<MyClass*,MyClass*> 
 > 
 >,__rw::__rw_tree_iter<MyClass*,int,MyClass**,MyClass*&,__rw::__rw_rb_tree_node<std::allocator<MyClass*>,MyClass*,MyClass*,__rw::__ident<MyClass*,MyClass*> 
 > > >,bool>::operator=(0xffbff6ac, 0xffbff5e8, 0xffbff5df, 0x883f0, 
0xffbff7ac, 0x0), at 0x253bc
   [2] 
__rw::__rb_tree<MyClass*,MyClass*,__rw::__ident<MyClass*,MyClass*>,std::less<MyClass*>,std::allocator<MyClass*> 
 >::_C_insert(this = 0xffbff7b4, __v = 0x88690, __ret = STRUCT, __dup = 
false), line 309 in "_tree.cc"
   [3] 
__rw::__rb_tree<MyClass*,MyClass*,__rw::__ident<MyClass*,MyClass*>,std::less<MyClass*>,std::allocator<MyClass*> 
 >::insert(this = 0xffbff7b4, __val = 0x88690, __dup = false), line 608 
in "_tree.h"
   [4] std::set<MyClass*,std::less<MyClass*>,std::allocator<MyClass*> 
 >::insert(this = 0xffbff7b4, __x = 0x88690), line 174 in "set"
   [5] createSet(), line 17 in "t.cpp"
   [6] main(), line 24 in "t.cpp"