odd C++ crash question with streams

Discussion in 'C++' started by laniik, Apr 8, 2005.

  1. laniik

    laniik Guest

    Hi. What does it mean if my application is crashing on a cout<< line?
    specifically:

    cout<<"hello"<<endl

    does not crash it, but

    int i=0;
    cout<<"hello"<<i<<endl;

    does.

    the crash is:

    "unhandled exception at 0x00450460 in main.exe: 0xC0000005: Access
    violation reading location 0x00000000"

    Thanks!
    laniik, Apr 8, 2005
    #1
    1. Advertising

  2. laniik

    Artie Gold Guest

    laniik wrote:
    > Hi. What does it mean if my application is crashing on a cout<< line?
    > specifically:
    >
    > cout<<"hello"<<endl
    >
    > does not crash it, but
    >
    > int i=0;
    > cout<<"hello"<<i<<endl;
    >
    > does.
    >
    > the crash is:
    >
    > "unhandled exception at 0x00450460 in main.exe: 0xC0000005: Access
    > violation reading location 0x00000000"
    >
    > Thanks!
    >

    If you show us a minimal compilable program that exhibits this behavior,
    someone here might be able to help you. Absent that, there's absolutely
    no way to tell.

    Cheers,
    --ag

    --
    Artie Gold -- Austin, Texas
    http://it-matters.blogspot.com (new post 12/5)
    http://www.cafepress.com/goldsays
    Artie Gold, Apr 8, 2005
    #2
    1. Advertising

  3. laniik

    laniik Guest

    hmm, this is part of a larger program where its obviously somthing in
    the code executed before this that is causing the problem. however i
    cannot post the whole code, so i was hoping that someone might
    recognize this error as being caused by something in specific that i
    could look for in the code. but i agree, unless you've seen it before,
    its not much to go on.
    laniik, Apr 8, 2005
    #3
  4. laniik

    Evan Guest

    Are you dealing with pointers at all? Perhaps you have instead of i
    being an int it's an int*, and you're doing << *i? If so, look to be
    sure that i is properly initialized or set to whatever. It's trying to
    read something at address 0, which is a Bad Thing(TM).

    Other than that... I don't really have any idea.
    Evan, Apr 8, 2005
    #4
  5. laniik

    laniik Guest

    i looked around and found that stuff like this with streams can happen
    when the memory gets corrupted by accidental overwriting. this causes
    the streams to be unable to allocate memory for the int in that line.

    turns out i was writing a block of memory 2 bytes too large for the
    allocated space. of course, this couldnt give me some kind of error at
    that line, it has to manifest itself in some bizarre standard library
    call.

    hehe. i love c++

    thanks for the help!
    laniik, Apr 8, 2005
    #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. Raj Batra
    Replies:
    2
    Views:
    512
    Thomas Heller
    Sep 18, 2003
  2. ZER0K3WL

    Using mysqlclient library -- odd crash

    ZER0K3WL, Sep 30, 2004, in forum: C Programming
    Replies:
    2
    Views:
    269
    Peter Slootweg
    Oct 1, 2004
  3. B. Chernick
    Replies:
    1
    Views:
    324
    B. Chernick
    Dec 12, 2007
  4. Chris Bergstresser

    Odd PyQt4 crash on exit when importing on windows

    Chris Bergstresser, Apr 6, 2008, in forum: Python
    Replies:
    0
    Views:
    402
    Chris Bergstresser
    Apr 6, 2008
  5. msoulier

    odd crash in file upload via CGI

    msoulier, Jul 31, 2006, in forum: Perl Misc
    Replies:
    11
    Views:
    229
    msoulier
    Aug 2, 2006
Loading...

Share This Page