when V-pointer becomes NULL

Discussion in 'C++' started by Jaydeep Chovatia, Jul 18, 2013.

  1. Hi,

    In my application object's v-pointer becomes NULL under load. I have Base class - Derive class type of hierarchy with pure virtual functions and my constructor/destructor are inline. I have checked Derive class member variables and they are fine (i.e. obj was not deleted anytime) only v-ptr is NULL.

    Can somebody please point me in which all situations v-pointer become NULL?

    I've already checked following links and none of them help:
    http://stackoverflow.com/questions/3966039/why-does-my-c-object-loses-its-vptr
    http://stackoverflow.com/questions/992786/vftptr-is-null


    -jaydeep
    Jaydeep Chovatia, Jul 18, 2013
    #1
    1. Advertising

  2. On Thursday, 18 July 2013 12:59:04 UTC-7, Paavo Helde wrote:
    > Jaydeep Chovatia <> wrote in
    >
    > news::
    >
    >
    >
    > > Hi,

    >
    > >

    >
    > > In my application object's v-pointer becomes NULL under load. I have

    >
    > > Base class - Derive class type of hierarchy with pure virtual

    >
    > > functions and my constructor/destructor are inline. I have checked

    >
    > > Derive class member variables and they are fine (i.e. obj was not

    >
    > > deleted anytime) only v-ptr is NULL.

    >
    >
    >
    > Put a data breakpoint on the v-ptr in the debugger and you can easily catch
    >
    > the moment when it turns NULL.
    >
    >
    >
    > Cheers
    >
    > Paavo


    Hi Paavo,

    Thanks for prompt response.
    Problem with setting watchpoint is this problem occurs under load (not functionally), and under load v-ptr is keep changing so I cannot set specific watchpoint.

    -jaydeep
    Jaydeep Chovatia, Jul 18, 2013
    #2
    1. Advertising

  3. On Thursday, 18 July 2013 14:03:58 UTC-7, Paavo Helde wrote:
    > Jaydeep Chovatia <> wrote in
    >
    > news::
    >
    >
    >
    > > On Thursday, 18 July 2013 12:59:04 UTC-7, Paavo Helde wrote:

    >
    > >> Jaydeep Chovatia <> wrote in

    >
    > >>

    >
    > >> news::

    >
    > >>

    >
    > >>

    >
    > >>

    >
    > >> > Hi,

    >
    > >>

    >
    > >> >

    >
    > >>

    >
    > >> > In my application object's v-pointer becomes NULL under load. I

    >
    > >> > have

    >
    > >>

    >
    > >> > Base class - Derive class type of hierarchy with pure virtual

    >
    > >>

    >
    > >> > functions and my constructor/destructor are inline. I have checked

    >
    > >>

    >
    > >> > Derive class member variables and they are fine (i.e. obj was not

    >
    > >>

    >
    > >> > deleted anytime) only v-ptr is NULL.

    >
    > >>

    >
    > >>

    >
    > >>

    >
    > >> Put a data breakpoint on the v-ptr in the debugger and you can easily

    >
    > >> catch

    >
    > >>

    >
    > >> the moment when it turns NULL.

    >
    > >>

    >
    > >>

    >
    > >>

    >
    > >> Cheers

    >
    > >>

    >
    > >> Paavo

    >
    > >

    >
    > > Hi Paavo,

    >
    > >

    >
    > > Thanks for prompt response.

    >
    > > Problem with setting watchpoint is this problem occurs under load (not

    >
    > > functionally), and under load v-ptr is keep changing so I cannot set

    >
    > > specific watchpoint.

    >
    >
    >
    > Not sure what you mean by "under load" and "not functionally". Do you
    >
    > want to say the problem appears only randomly? Sounds like some kind of
    >
    > memory corruption, in this case the simplest remedy might be to run the
    >
    > program under some memory checker like valgrind.
    >
    >
    >
    > hth
    >
    > Paavo


    Hi Paavo,

    Yes problem occurs randomly, i will run it under valgrind and then see how it goes.
    Thanks for your help.

    -jaydeep
    Jaydeep Chovatia, Jul 18, 2013
    #3
  4. On 7/18/2013 5:06 PM, Jaydeep Chovatia wrote:
    > On Thursday, 18 July 2013 14:03:58 UTC-7, Paavo Helde wrote:
    >> [...]

    >
    > Yes problem occurs randomly, i will run it under valgrind and then see how it goes.


    The most common IME reason for this was writing beyond array bounds. If
    valgrind can tell you when you cross boundaries of dynamically or
    automatically allocated memory, great. If not, bisection method should
    do it, which means you need to find a test case in which it happens *all
    the time*, and then manual checking of that pointer (offset 0 from the
    object address, I suppose) should tell you approximately when it
    happens. Not an easy task in your case, AIUI. All memory errors are
    tricky...

    If your problem is due to mishandling of dynamic memory (like deleting a
    previously deleted pointer, for instance), sometimes it helps to get a
    dynamic memory management library (like SmartHeap, for instance). Not
    sure if those still exist, though... :-/

    V
    --
    I do not respond to top-posted replies, please don't ask
    Victor Bazarov, Jul 18, 2013
    #4
  5. Jaydeep Chovatia

    Jorgen Grahn Guest

    On Thu, 2013-07-18, Paavo Helde wrote:
    > Jaydeep Chovatia <> wrote in

    ....
    >> Problem with setting watchpoint is this problem occurs under load (not
    >> functionally), and under load v-ptr is keep changing so I cannot set
    >> specific watchpoint.

    >
    > Not sure what you mean by "under load" and "not functionally".


    Where I work, those two terms comes from testing.

    If the system was e.g. a web server, a functional testing test case
    would send a specific GET request and check that the response is the
    expected one, and that a specific log message is generated.

    A load test could e.g. send a mix of different requests at 1000 Hz for
    an hour.

    > Do you want to say the problem appears only randomly?


    It could be that[1] but load tests tend also to be the only ones to
    reveal concurrency problems, broken handling of overload and so on
    (including the one you mentioned, memory corruption).

    /Jorgen

    [1] Whatever "randomly" means. We tend to use it for events we don't
    understand yet: a crash which happens every Friday at noon will
    look random until we see the pattern.

    --
    // Jorgen Grahn <grahn@ Oo o. . .
    \X/ snipabacken.se> O o .
    Jorgen Grahn, Jul 19, 2013
    #5
    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. TN Bella
    Replies:
    1
    Views:
    1,482
    TN Bella
    Jul 1, 2004
  2. Replies:
    9
    Views:
    942
    Juha Nieminen
    Aug 22, 2007
  3. aneuryzma
    Replies:
    3
    Views:
    694
    Jim Langston
    Jun 16, 2008
  4. Stef Mientki

    and becomes or and or becomes and

    Stef Mientki, May 22, 2011, in forum: Python
    Replies:
    9
    Views:
    301
    Chris Angelico
    May 28, 2011
  5. Christopher
    Replies:
    4
    Views:
    431
    Ruben Safir
    Jul 9, 2011
Loading...

Share This Page