Weird Crash Error
So I'm using QT and basically making a full size OpenGL widget.
I'm getting this weird ass error when I right click or expand the screen (I think it's happening when it has to redraw). I don't believe this is an OpenGL or QT issue, or if it is I don't think it's a bug per-se, more-so something I'm missing..
For now I just got the framework finished using GLUT/OpenGL on Linux, but I'd like to get this version working as it promotes a lot more extensibility , IMO.
The lines in red is where it gets interesting. A QTime is just a class that contains a time value, it has a default c'tor.
void resizeGL(int width, int height);
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void wheelEvent(QWheelEvent *event);
void keyPressEvent(QKeyEvent *event);
If I COMMENT 'start_time', it will work flawlessly, as expected. If I uncomment it (note, it's not being referenced anywhere, simply uncommented), I get a crash upon right click, or if I expand the window the widget also doesn't resize (but doesn't crash until I right click).
If I UNCOMMENT 'start_time' AND I uncomment 'waste' - it ACTS AS IT SHOULD. Uncommenting 'waste2' makes it crash again.
These variables are NOT getting referenced anywhere, I can comment/uncomment them at will. Some makes it crash, some makes it run fine. I feel there's a memory alignment issue here...or some idiosyncrasy of C++ that I'm not thinking of/don't know about.
If I run it with the debugger, it WORKS FINE.
Any help is greatly appreciated. Thanks!
- IDE = QT Creator v2.0.1
- QT = v4.7.0 (32 bit)
- qmake = v2.01a (qmake is the QT makefile generator)
- mingw32-make = v3.81 (i386-pc-mingw32)
- g++ (GCC) = v4.4.0
I am doing this for a school project. QT, C++, OpenGL are NOT target requirements of this course, the course is an animation techniques course, and is technology agnostic.
If you choose to take any work here (not sure why you would), I am EXPLICITLY NOT giving permission for it to be used in an academic setting without explicit acceptance from the professor. Feel free to take it for your own personal uses, though.
Make sure you properly clean and rebuild the entire project. Some make file generators don't properly make source files recompile when included headers are changed, leading to different class member offsets being linked for the same class.
If you have done a proper clean and build, and the symptoms still persist, it is probable that some code in your program (somewhere) is molesting a pointer and overwriting an area of memory it shouldn't (dereferencing NULL, falling off the end of an array, etc etc).
One common symptom of pointer molestation is that some seemingly irrelevant code change (for example, introducing a variable that is never used) makes a problem go away. The reason is that pointer molestations overwrite an area of memory that they shouldn't. Adding variables causes a change in layout of memory used by a program, and can therefore change what happens when memory is overwritten.
Gah, I think that was it. I added a clean step to my build and it's running fine now, I think. Probably an old version of window.o (didn't post that here), though it really doesn't reference anything in the class with the header shown above..well, wait, it does make it...yeaa, that could definitely cause some problems with what it thinks the size should be and what the size actually is.
Originally Posted by King Mir
Thanks. I'll come back later today or tomorrow and let you know if it's working sound now :).
Yeah, things are pretty much up in there air when you fiddle with pointers like that. I am not, though, I'm only using them like they should be used, IMO...though obviously that doesn't necessarily mean it's bug-free. I think the program currently falls into the first category of: "There are two ways to keep your program bug free. Either make it so simple that it obviously has no deficiencies, or make it complex enough that there are no obvious deficiencies." - haha :).
Originally Posted by grumpy
Think the cleaning step before building is fixing it. I'll check back later and confirm, for now, bike ride :-D