Weird Crash Error

This is a discussion on Weird Crash Error within the C++ Programming forums, part of the General Programming Boards category; So I'm using QT and basically making a full size OpenGL widget. I'm getting this weird ass error when I ...

  1. #1
    Registered User
    Join Date
    Aug 2010
    Location
    Rochester, NY
    Posts
    196

    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.

    Header:
    Code:
    #ifndefCONTENT_H
    #defineCONTENT_H
    
    #include<QGLWidget>
    #include<QTime>
    
    //classQTime;
    //classQTimer;
    
    classContent:publicQGLWidget
    {
        Q_OBJECT
    public:
        Content(QWidget*);
        ~Content();
    
    protected:
        void initializeGL();
        void resizeGL(int width, int height);
        void paintGL();
        void mousePressEvent(QMouseEvent *event);
        void mouseMoveEvent(QMouseEvent *event);
        void wheelEvent(QWheelEvent *event);
        void keyPressEvent(QKeyEvent *event);
        void Paint();
    
    private:
        void InitSceneSetup();
        QTime start_time;
        //QTime curr_time;
        GLfloat x_location;
        //GLfloat waste;
        //float waste2;
        //double space_waster;
        GLfloat y_location;
        //QTime last_time;
        //QTimer refresh_timer;
        bool first_paint;
        bool scene_dirty;
    
    publicslots:
        void timeout();
    
    };
    #endif //CONTENT_H
    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.

    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!
    Versions:
    - 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

    NOTE:
    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.
    Last edited by Syndacate; 12-18-2011 at 10:09 PM.

  2. #2
    Registered User
    Join Date
    Apr 2006
    Posts
    2,025
    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.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

  3. #3
    Registered User
    Join Date
    Jun 2005
    Posts
    6,261
    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.
    Right 98% of the time, and don't care about the other 3%.

  4. #4
    Registered User
    Join Date
    Aug 2010
    Location
    Rochester, NY
    Posts
    196
    Quote Originally Posted by King Mir View Post
    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.
    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.

    Thanks. I'll come back later today or tomorrow and let you know if it's working sound now .

    Quote Originally Posted by grumpy View Post
    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.
    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 .

    Think the cleaning step before building is fixing it. I'll check back later and confirm, for now, bike ride :-D

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Weird crash error I can't figure out
    By Jesse20ghet in forum C++ Programming
    Replies: 3
    Last Post: 10-11-2011, 05:40 PM
  2. crash error
    By morrissey999 in forum C Programming
    Replies: 6
    Last Post: 04-30-2011, 01:55 PM
  3. weird error
    By ExDHaos in forum C++ Programming
    Replies: 4
    Last Post: 05-16-2009, 05:49 PM
  4. Weird Error. Please Help.
    By RP319 in forum C++ Programming
    Replies: 2
    Last Post: 02-19-2006, 08:33 PM
  5. Weird IE error
    By Ravage in forum Tech Board
    Replies: 16
    Last Post: 03-31-2003, 10:46 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21