Results 1 to 8 of 8

Thread: a strange crash

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    Join Date
    Mar 2016
    Posts
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default [solved]Re: a strange crash

    [solved] Cheers, my problem has been solved, at least, it looks so currently
    What I would like to share including:
    (1). the reason caused program crash was that I used an uninitialized variable (int max_value) as the bound in a loop:
    Qt Code:
    1. for(int i=0; i<max_value; i++){a[i]=***;} //int a[10] is a arrary
    To copy to clipboard, switch view to plain text mode 
    so the above loop statement might lead to an illegal usage of memory especially when the value of "max_value" initialized by windows 8 system is very big!
    I found the value of max_value initialized by windows 8 is 14339584, and lead to the crash as a result.

    (2). On how to debug. I tried to figure out the problem in the Qt debugger mode (GDB) but the program never crash as I said at the beginning. Maybe in the environment set by the debugger gave a reasonable value to "max_value", I didn't check. My method which helped me figure out the problem successfully here was the oldest one: print everywhere. Of course, it is unnecessary to print everywhere if you know you code very well, just print at some key points in the flow chart of your code. Find the possible codes where the bug is then continue to print in that area. Honestly, it took me only 2 minutes to find out and fix the bug which confused me at least for 2 whole working days. Programmers should calm down and think.

    (3). Another interesting thing is that when the program crash Qt reported: "quit with code -1073741819", and I found many people were asking and discussing on the "-1073741819 code". Maybe what I posted here helps.

    (4). [ask]. I still want to know on how to generate a core dump like file in windows and how to use it to debug? should gdb still work? Anyway, powerful debug tools are still desired to find the location quickly!

    Quote Originally Posted by anda_skoa View Post
    You don't need to run it in the debugger, when it crashed it should still be debuggable.
    I think on Windows you get a dialog asking if you want to Retry and that starts the debugger or maybe that is compiler specific and a MinGW built program also creates a core dump like on other operating systems.

    Cheers,
    _
    Last edited by hxf@dlut.edu.cn; 8th March 2016 at 13:07.

Similar Threads

  1. Replies: 0
    Last Post: 3rd November 2015, 17:58
  2. Strange QHash crash
    By t_3 in forum Qt Programming
    Replies: 2
    Last Post: 16th December 2013, 19:28
  3. Replies: 3
    Last Post: 12th May 2011, 17:45
  4. Crash gracefully? No crash!
    By lni in forum Qt Programming
    Replies: 0
    Last Post: 7th July 2010, 03:59
  5. !!!A Strange Crash
    By hhf in forum Qt Programming
    Replies: 12
    Last Post: 10th March 2010, 12:45

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
  •  
Qt is a trademark of The Qt Company.