Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Core dumping at push_back for a vector (On Linux and HP)

Reply
Thread Tools

Core dumping at push_back for a vector (On Linux and HP)

 
 
Ganesh Gella
Guest
Posts: n/a
 
      07-12-2003
Hi All,

I am using g++ on Linux, and my code has lot of vectors each stores a
particualr type of structure. (Structure internally had some vectors).

When I am trying to push_back an element to a one of the vectors in
the parent strutcure, it always core dumps on Linux and HP. On Solaris
the same code is working fine without any problem.

My code is actually an API, and this problem is seen only by few
callers and not by everybody on linux/HP.

Here is the stack trace of core dump, can some of you help me out
here..

#0 0x080ff6bd in basic_string<char, string_char_traits<char>,
__default_alloc_template<true, 0> >::Rep::grab (this=0x3f0dca1e)
at /usr/include/g++-3/std/bastring.h:75
75 charT* grab () { if (selfish) return clone (); ++ref;
return data (); }
(gdb) where
#0 0x080ff6bd in basic_string<char, string_char_traits<char>,
__default_alloc_template<true, 0> >::Rep::grab (this=0x3f0dca1e)
at /usr/include/g++-3/std/bastring.h:75
#1 0x080fe985 in basic_string<char, string_char_traits<char>,
__default_alloc_template<true, 0> >::basic_string (this=0x828ab24,
str=@0xbfffedbc)
at /usr/include/g++-3/std/bastring.h:177
#2 0x0810670e in ImageData::ImageData (this=0x828ab18,
_ctor_arg=@0xbfffedb0)
at /usr/include/g++-3/stl_construct.h:48
#3 0x080ffc8b in void construct<ImageData, ImageData> (__p=0x828ab18,
__value=@0xbfffedb0) at /usr/include/g++-3/stl_construct.h:48
#4 0x080ffda2 in vector<ImageData, allocator<ImageData>
>::_M_insert_aux (

this=0xbfffee58, __position=0x0, __x=@0xbfffedb0)
at /usr/include/g++-3/stl_vector.h:604
#5 0x080febab in vector<ImageData, allocator<ImageData> >:ush_back
(
this=0xbfffee58, __x=@0xbfffedb0) at
/usr/include/g++-3/stl_vector.h:325
#6 0x0809072b in PickListReports::makeModel (this=0x82927a
at picklistreports.cpp:820
#7 0x08080f3b in vreport (robotNum=0x0, vaultName=0x828e028 "V1",
profileName=0x0, sessionid=1, reportid=-1, reportFormat=0,
distInfo=0x0,
argInfo=0x0) at vreport.cpp:350
#8 0x0807fb1f in vreport (robot=0x0, vault=0x828e028 "V1",
profile=0x0,
sessionid=1) at vreport.cpp:71
#9 0x08071f28 in DoReport (rptcmd=0xbffffa79 "picking_library",
sessionId=1,
reportFileName=0x0) at reports.cpp:85
#10 0x08079873 in new_main (argC=9, argV=0xbffff914) at vltrun.cpp:431
#11 0x080794e8 in main (argC=9, argV=0xbffff914) at vltrun.cpp:342
#12 0x410b8507 in __libc_start_main (main=0x80794d4 <main>, argc=9,
ubp_av=0xbffff914, init=0x804fd28 <_init>, fini=0x812be24 <_fini>,
rtld_fini=0x4000dc14 <_dl_fini>, stack_end=0xbffff90c)
at ../sysdeps/generic/libc-start.c:129

#6 is the place where I am using push_back.

I tried using stlport instead of g++'s STL but no use it core dumps
at the same place always.

Your help is highly appreciated in this regard.

Thanks
Ganesh.
 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      07-12-2003
"Ganesh Gella" <> wrote...
> I am using g++ on Linux, and my code has lot of vectors each stores a
> particualr type of structure. (Structure internally had some vectors).
>
> When I am trying to push_back an element to a one of the vectors in
> the parent strutcure, it always core dumps on Linux and HP. On Solaris
> the same code is working fine without any problem.
>
> My code is actually an API, and this problem is seen only by few
> callers and not by everybody on linux/HP.
>
> Here is the stack trace of core dump, can some of you help me out
> here..
> [...]


Don't post this OS- and compiler-specific rubbish. Post code.

> I tried using stlport instead of g++'s STL but no use it core dumps
> at the same place always.


I can't see any "place". Neither can I see any "particular
structure". Post code.

Victor


 
Reply With Quote
 
 
 
 
Stephen Howe
Guest
Posts: n/a
 
      07-13-2003
> I tried using stlport instead of g++'s STL but no use it core dumps
> at the same place always.
>
> Your help is highly appreciated in this regard.


Then post code not meaningless crap.

Your probably using vector incorrectly, we will never know until we see some
_complete_ _compilable_ code that illustrates the problem.

Stephen Howe


 
Reply With Quote
 
Ganesh Gella
Guest
Posts: n/a
 
      07-14-2003
"Stephen Howe" <> wrote in message news:<3f10a6bb$0$11375$ m>...
> > I tried using stlport instead of g++'s STL but no use it core dumps
> > at the same place always.
> >
> > Your help is highly appreciated in this regard.

>
> Then post code not meaningless crap.
>
> Your probably using vector incorrectly, we will never know until we see some
> _complete_ _compilable_ code that illustrates the problem.
>
> Stephen Howe


Okay, here is the code I am using

for (pImg=filteredList.begin(); pImg != filteredList.end(); ++pImg)
{
ImageData idata;
FRAG_vec::iterator pFrag;
for (pFrag=(pImg->frags).begin(); pFrag != (pImg->frags).end(); ++pF
rag)
{
idata.imageId = pImg->backupid;
idata.client = pImg->client;
idata.kbytes = pFrag->kilobytes;
idata.backedup_dt = pImg->backup_time ;
idata.fragNum = pFrag->fragment;

}
(mdata.imageList).push_back(idata);

Here I am getting core dump at push_back(idata).

Posted the stack trace in previous messages.

Thanks
Ganesh.
 
Reply With Quote
 
Victor Bazarov
Guest
Posts: n/a
 
      07-14-2003
"Ganesh Gella" <> wrote in message
news: om...
> "Stephen Howe" <> wrote in message

news:<3f10a6bb$0$11375$ m>...
> > > I tried using stlport instead of g++'s STL but no use it core dumps
> > > at the same place always.
> > >
> > > Your help is highly appreciated in this regard.

> >
> > Then post code not meaningless crap.
> >
> > Your probably using vector incorrectly, we will never know until we see

some
> > _complete_ _compilable_ code that illustrates the problem.
> >
> > Stephen Howe

>
> Okay, here is the code I am using
>
> for (pImg=filteredList.begin(); pImg != filteredList.end();

++pImg)
> {
> ImageData idata;
> FRAG_vec::iterator pFrag;
> for (pFrag=(pImg->frags).begin(); pFrag !=

(pImg->frags).end(); ++pF
> rag)
> {
> idata.imageId = pImg->backupid;
> idata.client = pImg->client;
> idata.kbytes = pFrag->kilobytes;
> idata.backedup_dt = pImg->backup_time ;
> idata.fragNum = pFrag->fragment;
>
> }
> (mdata.imageList).push_back(idata);
>
> Here I am getting core dump at push_back(idata).


The most probable situation is that your 'ImageData' has some
dynamic memory that you don't handle correctly. Find and read
about "The Rule Of Three".

Victor


 
Reply With Quote
 
John Harrison
Guest
Posts: n/a
 
      07-14-2003

"Ganesh Gella" <> wrote in message
news: om...
> "Stephen Howe" <> wrote in message

news:<3f10a6bb$0$11375$ m>...
> > > I tried using stlport instead of g++'s STL but no use it core dumps
> > > at the same place always.
> > >
> > > Your help is highly appreciated in this regard.

> >
> > Then post code not meaningless crap.
> >
> > Your probably using vector incorrectly, we will never know until we see

some
> > _complete_ _compilable_ code that illustrates the problem.
> >
> > Stephen Howe

>
> Okay, here is the code I am using
>
> for (pImg=filteredList.begin(); pImg != filteredList.end();

++pImg)
> {
> ImageData idata;
> FRAG_vec::iterator pFrag;
> for (pFrag=(pImg->frags).begin(); pFrag !=

(pImg->frags).end(); ++pF
> rag)
> {
> idata.imageId = pImg->backupid;
> idata.client = pImg->client;
> idata.kbytes = pFrag->kilobytes;
> idata.backedup_dt = pImg->backup_time ;
> idata.fragNum = pFrag->fragment;
>
> }
> (mdata.imageList).push_back(idata);
>
> Here I am getting core dump at push_back(idata).
>
> Posted the stack trace in previous messages.
>
> Thanks
> Ganesh.


Almost certainly your ImageData object does not have a valid copy
constructor.

john


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
core dump in std::list push_back Jaydeep Chovatia C++ 9 03-25-2011 10:09 AM
rdstate() is dumping core on Linux 2.6.x kernel lkpaturi C++ 0 10-08-2010 08:32 AM
std::vector and push_back() mlt C++ 2 03-09-2009 03:04 AM
Free memory allocate by a STL vector, vector of vector, map of vector Allerdyce.John@gmail.com C++ 8 02-18-2006 12:48 AM
push_back() and vector of classes - C++ newbie :) Avi Bercovich C++ 5 01-14-2004 02:42 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57