|
Home > Archive > Unix Programming > December 2005 > problem while running a STL CPP application Compiled using gcc in Solaris environment.
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
problem while running a STL CPP application Compiled using gcc in Solaris environment.
|
|
|
|
Hi,
I am facing a problem while running a STL CPP application ,Compiled
using gcc in Solaris environment.
Following is the code :
#include <set>
{
template <class SerImp>
class Services
{
public:
void Add(SerImp *TOSer)
{
if (TOSer)
m_list.insert(TOSer);
}
void Remove(SerImp *TOSer)
{
m_list.erase(TOSer);
}
protected:
typedef std::set<SerImp*> SerL;
typedef SerL::iterator SerIter;
SerL m_list;
};
Whenever I try to do "m_list.insert(TOSer)" the application is
giving Segmentation fault.
This is the call stack.
#0 0xfef64ac8 in std::_Rb_tree_decrement (__x=0xff35356c)
at /rsft/users/akankari/gcc-3.4.2/libstdc++-v3/src/tree.cc:94
#1 0xff2839a8 in std::_Rb_tree_iterator<R::BaseSerImp*>::operator--
(this=0xffbef3f0) at stl_tree.h:195
#2 0xff283434 in std::_Rb_tree<R::BaseSerImp*, R::BaseSerImp*,
std::_Identity<R::BaseSerImp*>, std::less<R::BaseSerImp*>,
std::allocator<R::BaseSerImp*> >::insert_unique (this=0xff353568,
__v=@0xffbef550) at stl_tree.h:877
#3 0xff282f08 in std::set<R::BaseSerImp*, std::less<R::BaseSerImp*>,
std::allocator<R::BaseSerImp*> >::insert (this=0xff353568,
__x=@0xffbef550) at stl_set.h:314
#4 0xff282bf0 in Services<R::BaseSerImp>::Add (this=0xff353568,
TOSer=0x246d8) at Services.h:48
Can anybody suggest what the reason for this Segmentation fault is? We
have to use any special switch while compiling this application because
the same application is working fine in windows?
Thanks,
Vinu
| |
| Maxim Yegorushkin 2005-12-28, 6:11 pm |
|
Vinu wrote:
[]
> Whenever I try to do "m_list.insert(TOSer)" the application is
> giving Segmentation fault.
>
> This is the call stack.
[]
> #3 0xff282f08 in std::set<R::BaseSerImp*, std::less<R::BaseSerImp*>,
> std::allocator<R::BaseSerImp*> >::insert (this=0xff353568,
> __x=@0xffbef550) at stl_set.h:314
>
>
> #4 0xff282bf0 in Services<R::BaseSerImp>::Add (this=0xff353568,
> TOSer=0x246d8) at Services.h:48
>
>
> Can anybody suggest what the reason for this Segmentation fault is? We
> have to use any special switch while compiling this application because
You might have overwritten a pointer to a Services object with rubbish.
I'm not familiar with Solaris, but on a 32-bit Linux user mode
processes can not access memory above 0xc0000000 and your this pointer
has value of 0xff353568. The screwed up pointer to the object might be
on the stack, and your windoze compiler may layout stack frames in a
different order so that the error went unnoticed before.
Just a wild guess.
|
|
|
|
|