Results 1 to 8 of 8

Thread: generic catch-all error during runtime

  1. #1
    Join Date
    Apr 2010
    Location
    Singapore
    Posts
    156
    Thanks
    47
    Qt products
    Qt4
    Platforms
    Windows

    Question generic catch-all error during runtime

    I am getting runtime error as in attachment.
    Code :
    Qt Code:
    1. QDoubleSpinBox *AspinBox,*BspinBox,*CspinBox,*DspinBox;
    2. func( float&,float&,float&,float&);
    3. float a,b,c,d;
    4.  
    5. AspinBox= new QDoubleSpinBox;
    6. BspinBox= new QDoubleSpinBox;
    7. CspinBox= new QDoubleSpinBox;
    8. DspinBox= new QDoubleSpinBox;
    9.  
    10. a = AspinBox->cleanText().toFloat();
    11. b = BspinBox->cleanText().toFloat();
    12. c = CspinBox->cleanText().toFloat();
    13. d = DspinBox->cleanText().toFloat();
    14.  
    15. QString strA = QString::number( a );
    16. QMessageBox::about(this,tr("ED apical trim in mm #"),strA ); //value read back is correct
    17. func(a, b, c, d); //I guess this function is causing error
    To copy to clipboard, switch view to plain text mode 


    Error in attachment is read as :
    Application.exe has encountered a problem and needs to close. We are sorry for the inconvenience.
    If you were in the middle of something, the information you were working on might be lost.

    Please tell Microsoft about this problem.
    We have created an error report that you can send to us. We will treat this report as confidential and anonymous. To see what data this error report contains, click here.
    Attached Files Attached Files

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: generic catch-all error during runtime

    run the code in a debugger, and you will not have to guess which lines crashes.
    if func() is crashing, please show us the implementation of func().
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Apr 2010
    Location
    Singapore
    Posts
    156
    Thanks
    47
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: generic catch-all error during runtime

    When debugging , line #17 is found to be causing the crash.

    Code :
    Qt Code:
    1. bool func( float& floatA, float& floatB, float& floatC, float& floatD )
    2. {
    3. return inst->func(floatA, floatB, floatC, floatD );
    4. }
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Dec 2009
    Posts
    128
    Thanks
    7
    Thanked 14 Times in 14 Posts
    Platforms
    Unix/X11 Windows

    Default Re: generic catch-all error during runtime

    inst is NULL or dirty probably, put a breakpoint in func() and check this pointer value in debugger. What type is it ? Where do you initialize inst ?

  5. #5
    Join Date
    Apr 2010
    Location
    Singapore
    Posts
    156
    Thanks
    47
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: generic catch-all error during runtime

    Quote Originally Posted by totem View Post
    inst is NULL or dirty probably, put a breakpoint in func() and check this pointer value in debugger. What type is it ? Where do you initialize inst ?
    Value in debugger is 8b.
    func() is of boolean type.
    inst is initialized in .cpp file in .dll project.

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: generic catch-all error during runtime

    "8b" as a pointer looks suspect. Is it "8b" immediately after it is allocated? Are you sure this is not an error return code rather than a pointer?

  7. #7
    Join Date
    Apr 2010
    Location
    Singapore
    Posts
    156
    Thanks
    47
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: generic catch-all error during runtime

    Quote Originally Posted by ChrisW67 View Post
    "8b" as a pointer looks suspect. Is it "8b" immediately after it is allocated? Are you sure this is not an error return code rather than a pointer?
    Yes, '8b' is the value immediately after it is allocated. It may be an error return code.How do i confirm this?
    When the program exits, there is a message in debugger which is read as:
    exit code message Code:
    1. -Program exited with exit code exit-code="030000000015".
    To copy to clipboard, switch view to plain text mode 
    Last edited by babygal; 23rd June 2010 at 08:16.

  8. #8
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: generic catch-all error during runtime

    inst is initialized in .cpp file in .dll project.
    How do you know that for sure?
    Put a break point in the DLL where inst gets initialized and see if it gets caught.

    Also initialize it to NULL when you start the application, so if the DLL does initialize it later, it will change from NULL.
    And where you call it, first test for NULL.

    If you put a break point on that call, some debuggers (like MSVS) will tell you if the pointer is dirty or not.
    So that is another check.
    Also, at some point you need to get the pointer from the DLL, put a break point there and see if it gets caught before you call the code you posted above.
    If not, 'inst' is not initialized.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. Runtime Error
    By zawal in forum Qwt
    Replies: 10
    Last Post: 1st August 2009, 11:46
  2. Runtime error
    By nina1983 in forum Qt Programming
    Replies: 2
    Last Post: 11th September 2008, 15:37
  3. QT 4.4 runtime error
    By Ricochet in forum Newbie
    Replies: 1
    Last Post: 5th May 2008, 18:50
  4. runtime error
    By mickey in forum General Programming
    Replies: 10
    Last Post: 12th December 2006, 20:10
  5. runtime error
    By mickey in forum General Programming
    Replies: 1
    Last Post: 11th June 2006, 13:38

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.