Results 1 to 7 of 7

Thread: program crashing randomly code -1073741819

  1. #1
    Join Date
    Nov 2009
    Location
    Laval, France
    Posts
    122
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default program crashing randomly code -1073741819

    Hello,
    I have written a Windows XP Qt app and it occasionally crashes when it tries to connect to Postgres.
    There are several ways it crashes, sometimes the main window closes and other times I get a more polite message box before it crashes.
    I tried putting in a trace with QMessageBox::information inside various parts of my
    "dbConnect()" function, but it has always worked when these have been enabled
    (to remove them I used
    #define TRACE()
    )
    I have never seen it crashing inside the deebugger either.
    I'm wondering about how to go about hunting for my bug.

    I've heard that there are programs like Rational Purify and Valgrind
    that could help me point to the error, but I'm running on a small budget.
    What do Qt developpers do, apart from looking at their code very carefully?

    By the way the last time it crashed it left an error code inside Qt Creator:
    -1073741819
    Last edited by feraudyh; 20th September 2010 at 16:41. Reason: better title

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: program crashing randomly code -1073741819

    That error corresponds to 0xc0000005 which is an access violation error.
    This means you try to access a section of the memory that is not available to you.
    This in turn happens when you use uninitialised pointers.

    These can easily be found by checking your code manually.
    If not, by running the code in a debugger.

    But since you mention possible other errors (no crashes?) the problem might be even worse.
    To give you more information, please provide a minimal compilable example demonstrating the errors.

  3. The following user says thank you to tbscope for this useful post:

    aya_lawliet (21st January 2011)

  4. #3
    Join Date
    Nov 2009
    Location
    Laval, France
    Posts
    122
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: program crashing randomly code -1073741819

    Thanks,
    The fact that it is an access violation error is very useful to me, at least I know that it's not an out of memory error.
    I suppose I can spend an evening looking at all pointers to see where they are initialised.
    The code is too big to post up here and it is written in my contract that I cannot show my code (in any substantial way).
    I had a lot of experience in plain old C a long time ago and knew that in a debugger some errors just went invisible.

    I wonder if it's of any use to initialise all pointers to NULL as soon as possible if you cant see where
    they are initialised.
    At least the app might crash sooner.

    I was also wondering: if I ported my app to Ubuntu then I might see the bug more easily.
    I might get a core dump for example.
    Last edited by feraudyh; 20th September 2010 at 20:03. Reason: more coherent answer, one more question

  5. #4
    Join Date
    Nov 2009
    Location
    Laval, France
    Posts
    122
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: program crashing randomly code -1073741819

    I've just had an idea as to why my program may be crashing, I'd like your opinions.
    I have a class called Parser. It has a constructor with a string argument and a parse method that returns a "geometry"(this is for a GIS app). The geometry is the result of parsing the string that is represented by the string. My class is allocated locally on the stack as in Parser p(myString) The parse() returns to a pointer member called m_geometry.
    This geometry is read by the app, but quite often (about 6 times) p goes out of scope, and yet the geometry is supposed to be still valid. I used new to create the geometry.
    Is there a risk that the geometry is no longer valid when p is no longer in scope?

  6. #5
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: program crashing randomly code -1073741819

    Quote Originally Posted by feraudyh View Post
    Is there a risk that the geometry is no longer valid when p is no longer in scope?
    It's most likely that the data gets corrupted (but it depends)

    If you copied only the pointer (and not the data that the pointer refer to) than this might be the reason for accessing memory you don't own and get "access violation error".

    If you didn't delete the pointer when it gets out of scope (in it's containing class destructor) then you will have a memory leak (in this case you shoudn't get "access violation error" since the memory is yours (but i call "bad practice" to use one pointer to allocate on heap and a copy of that pointer to delete the resource)

  7. #6
    Join Date
    Nov 2009
    Location
    Laval, France
    Posts
    122
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: program crashing randomly code -1073741819

    Thanks.
    I'll have a look.

  8. #7
    Join Date
    Nov 2009
    Location
    Laval, France
    Posts
    122
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: program crashing randomly code -1073741819

    OK I found a big error and it runs much better.
    It was a classic:
    I was doing a strcpy from a char * whose length was n bytes into a zone that had n characters allocated. Now I had not allocated for the extra character ascii 0 at the end.
    Must have been tired when I wrote that.

    I found my bug by inserting trace macros into the code defined as this
    #define TRACE(Fn) traceWrite(tr("MainWindow.cpp, Line %1").arg(__LINE__))
    traceWrite writes into a stream and flushes after every write.
    This means I could find the vicinity of the error quickly.

Similar Threads

  1. Qt 4.4 Linguish Crashing on XP?
    By DerSchoeneBahnhof in forum Qt Tools
    Replies: 0
    Last Post: 19th June 2008, 22:42
  2. Replies: 2
    Last Post: 20th September 2007, 19:37
  3. QMultiHash - crashing
    By steg90 in forum Qt Programming
    Replies: 16
    Last Post: 23rd May 2007, 13:18
  4. Application is Crashing
    By shyam prasad in forum Qt Programming
    Replies: 1
    Last Post: 9th January 2007, 17:04
  5. QTableWidget crashing
    By therealjag in forum Qt Programming
    Replies: 5
    Last Post: 19th April 2006, 16:30

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.