Segmentation fault in stl_list.h

Discussion in 'C++' started by tikcireviva, Sep 26, 2006.

  1. tikcireviva

    tikcireviva Guest

    Hi Guys,

    I am not sure what's wrong with my program. When I ran it under the
    GDB, it shows the following messages , which said that the issue is
    from stl_list.h. Does anyone know what's happening in here?

    Program received signal SIGSEGV, Segmentation fault.
    [Switching to Thread 1540594608 (LWP 1661)]
    dist_obj::insert_list (this=0x82d3980, priority=23704) at
    stl_list.h:116
    116 { _M_node = _M_node->_M_next; }

    In my dist_obj::insert_list() , it just insert an character array into
    the list, and on the other thread, it gets a copy of the entire list,
    then clear the list, and do some manipulation.

    I also though about that if this is because of lack of memory on my
    machine. I ain't sure how to check that though.

    I am using GCC 3.3.3. on my FC2 machine.

    Can any one please give me a helping hand? Sorry for any inconvenience.

    Best wishes,

    Kit
     
    tikcireviva, Sep 26, 2006
    #1
    1. Advertising

  2. tikcireviva wrote:
    > I am not sure what's wrong with my program.


    We're not sure either. You can see it. We cannot.

    > When I ran it under the
    > GDB, it shows the following messages , which said that the issue is
    > from stl_list.h. Does anyone know what's happening in here?
    >
    > Program received signal SIGSEGV, Segmentation fault.
    > [Switching to Thread 1540594608 (LWP 1661)]
    > dist_obj::insert_list (this=0x82d3980, priority=23704) at
    > stl_list.h:116
    > 116 { _M_node = _M_node->_M_next; }


    Most likely either 'this' or 'this->_M_node' is an invalid pointer.

    > In my dist_obj::insert_list() , it just insert an character array into


    How is that character array created? Is it dynamic? Is it automatic?

    > the list, and on the other thread, it gets a copy of the entire list,
    > then clear the list, and do some manipulation.


    Threading is off-topic, unfortunately. C++ assumes a single thread,
    a single process, on a single processor machine. All definitions in
    the language are based on that.

    It is quite possible, though, that your problem is not related to
    threading. Does it happen if you don't use threads? Have you actually
    tried your algorithm synchronously before you introduced threads?

    > I also though about that if this is because of lack of memory on my
    > machine. I ain't sure how to check that though.


    Change the test case to something smaller (if possible). Watch the
    memory consumption of your process. Run it under 'valgrind' or some
    other memory debugging tool. But don't spend too much time on it,
    unless you actually work with rather large datasets. Most likely
    your problem is elsewhere.

    > I am using GCC 3.3.3. on my FC2 machine.


    That's irrelevant, most often. We here discuss the language, not the
    environment in which it's used.

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
     
    Victor Bazarov, Sep 26, 2006
    #2
    1. Advertising

  3. tikcireviva

    tikcireviva Guest

    Hi Victor,

    I am sorry to wrongly post this message in this news group.

    Finally, I got the solution.
    I've changed my stl::list from
    list<pair<char *,size_t> >
    to
    list<pair<char *,size_t> *>
    The char buffer that I've put into the pair<char*,size_t> is usually
    1~2kbytes. The frequency of doing a push_back() operation is around
    3000 times/sec.

    Still, I don't have strong evidence why after I've changed the
    pair<char*,size_t> to a pointer, everything will work. Actually I do
    want to drill down into the problem, may you please suggest me which
    news group I should goto?

    I am so sorry for any inconvenience again.

    Best regards,

    Kit.



    Victor Bazarov 寫é“:

    > tikcireviva wrote:
    > > I am not sure what's wrong with my program.

    >
    > We're not sure either. You can see it. We cannot.
    >
    > > When I ran it under the
    > > GDB, it shows the following messages , which said that the issue is
    > > from stl_list.h. Does anyone know what's happening in here?
    > >
    > > Program received signal SIGSEGV, Segmentation fault.
    > > [Switching to Thread 1540594608 (LWP 1661)]
    > > dist_obj::insert_list (this=0x82d3980, priority=23704) at
    > > stl_list.h:116
    > > 116 { _M_node = _M_node->_M_next; }

    >
    > Most likely either 'this' or 'this->_M_node' is an invalid pointer.
    >
    > > In my dist_obj::insert_list() , it just insert an character array into

    >
    > How is that character array created? Is it dynamic? Is it automatic?
    >
    > > the list, and on the other thread, it gets a copy of the entire list,
    > > then clear the list, and do some manipulation.

    >
    > Threading is off-topic, unfortunately. C++ assumes a single thread,
    > a single process, on a single processor machine. All definitions in
    > the language are based on that.
    >
    > It is quite possible, though, that your problem is not related to
    > threading. Does it happen if you don't use threads? Have you actually
    > tried your algorithm synchronously before you introduced threads?
    >
    > > I also though about that if this is because of lack of memory on my
    > > machine. I ain't sure how to check that though.

    >
    > Change the test case to something smaller (if possible). Watch the
    > memory consumption of your process. Run it under 'valgrind' or some
    > other memory debugging tool. But don't spend too much time on it,
    > unless you actually work with rather large datasets. Most likely
    > your problem is elsewhere.
    >
    > > I am using GCC 3.3.3. on my FC2 machine.

    >
    > That's irrelevant, most often. We here discuss the language, not the
    > environment in which it's used.
    >
    > V
    > --
    > Please remove capital 'A's when replying by e-mail
    > I do not respond to top-posted replies, please don't ask
     
    tikcireviva, Sep 27, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alex Hunsley
    Replies:
    17
    Views:
    871
  2. Pud
    Replies:
    0
    Views:
    578
  3. Replies:
    0
    Views:
    532
  4. Ivan Vecerina
    Replies:
    0
    Views:
    488
    Ivan Vecerina
    Jun 29, 2003
  5. fimarn
    Replies:
    5
    Views:
    524
    James Kanze
    Jul 20, 2007
Loading...

Share This Page