[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:
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!Qt Code:
for(int i=0; i<max_value; i++){a[i]=***;} //int a[10] is a arraryTo copy to clipboard, switch view to plain text mode
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!
Bookmarks