strange runtime error - I need help debuginng

Discussion in 'C++' started by r.z., Dec 18, 2006.

  1. r.z.

    r.z. Guest

    My program behaves very strange. I keep getting the following error:
    'The instruction at "some address" referenced memory at "some address". The
    memory could not be written"'
    The program consists of:
    int main( int argc, char* argv[] )
    {
    //here is some third party function that configures graphic environment
    {
    app my_app; //this is local so that I'm sure it's destroyed before
    next step
    }
    //here is some third party function that cleans graphic environment
    return 0;
    }
    But when, instead of my_app object, I put there all of its data members (app
    class has no constructor or destructor), it gives me no error!! I don't know
    what to do. I don't know how to debug in Visual Studio and I don't know how
    wheteher it would help me understand what's going on since my program relies
    on some third party dll.
     
    r.z., Dec 18, 2006
    #1
    1. Advertising

  2. r.z.

    r.z. Guest

    I commented out the third party functions and now I'm sure this error is
    caused by this local object. But when I put there its data members instead
    it gives me no error!!
     
    r.z., Dec 18, 2006
    #2
    1. Advertising

  3. r.z.

    Salt_Peter Guest

    r.z. wrote:
    > My program behaves very strange. I keep getting the following error:
    > 'The instruction at "some address" referenced memory at "some address". The
    > memory could not be written"'
    > The program consists of:
    > int main( int argc, char* argv[] )
    > {
    > //here is some third party function that configures graphic environment
    > {
    > app my_app; //this is local so that I'm sure it's destroyed before
    > next step
    > }
    > //here is some third party function that cleans graphic environment
    > return 0;
    > }
    > But when, instead of my_app object, I put there all of its data members (app
    > class has no constructor or destructor), it gives me no error!! I don't know
    > what to do. I don't know how to debug in Visual Studio and I don't know how
    > wheteher it would help me understand what's going on since my program relies
    > on some third party dll.


    If your app class/struct didn't have a constructor or a destructor,
    your program would not be compileable, let alone run. The error above
    depicts trying to write to read-only memory. I can think of 10 or more
    ways i could purposefully generate such an error. We could be here
    until Christmas( year 2050 ) discussing what hypothetically might, or
    might not be happening.
    Notice: C++ programmers are notoriously pathetic at guessing.

    I'ld suggest trying over at a newsgroup that deals with Visual Studio
    and/or whatever proprietary GUI library you are using.

    Consult this list of possible newsgroups:
    [5.9] Which newsgroup should I post my questions?
    http://www.parashift.com/c -faq-lite/how-to-post.html
     
    Salt_Peter, Dec 18, 2006
    #3
  4. r.z.

    John Carson Guest

    "r.z." <> wrote in message
    news:em5dea$mc6$
    > I commented out the third party functions and now I'm sure this error
    > is caused by this local object. But when I put there its data members
    > instead it gives me no error!!


    You have two options: learn how to debug or post code here that is
    compileable and allows us to reproduce the error.

    Debugging this shouldn't be hard. Just hit F5 for starters (assuming you
    have a debug build). With luck, this will take you to the line with the
    error.

    If the line with the error is in some library rather than your code, and you
    are confident that the problem is in your code, then open the Call Stack
    window (you should find it in the menus under Debug->Windows). Do this with
    the Debugger still running. In the call stack, double click on the highest
    line that is in your own code. The problem should be near this line.


    --
    John Carson
     
    John Carson, Dec 18, 2006
    #4
  5. r.z.

    John Carson Guest

    "r.z." <> wrote in message
    news:em5dea$mc6$
    > I commented out the third party functions and now I'm sure this error
    > is caused by this local object. But when I put there its data members
    > instead it gives me no error!!


    I didn't realise what newsgroup I was in when replying.

    You should ask questions like this in

    microsoft.public.vc.language
    or
    microsoft.public.vc.ide_general
    or
    comp.os.ms-windows.programmer.win32


    --
    John Carson
     
    John Carson, Dec 18, 2006
    #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. Kevin Farless
    Replies:
    13
    Views:
    15,241
    chesterchass
    Oct 3, 2007
  2. David
    Replies:
    2
    Views:
    825
    VisionSet
    Sep 29, 2003
  3. cppaddict
    Replies:
    7
    Views:
    368
    cppaddict
    Jul 14, 2004
  4. Hal Vaughan
    Replies:
    11
    Views:
    1,140
    Gordon Beaton
    May 22, 2006
  5. Oliver Wong
    Replies:
    11
    Views:
    1,014
Loading...

Share This Page