Results 1 to 10 of 10

Thread: Application throws exceptions without debugger attached

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2012
    Posts
    8
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Application throws exceptions without debugger attached

    I recently started using Qt and up until now everything's ran very smooth. When I choose to debug my application from within Qt Creator (in either release or debug configuration), it runs just fine without any exceptions. When I only run my debug build of the application, I get no exceptions as well. Then, for some odd reason when I choose to run my release build of the application I get exceptions within my code, but I'm not understanding why I would get the exceptions only without the debugger attached, and without any #ifdef directives. When I run it and manually attach the debugger I have the same issue, yet directly debugging from within Qt Creator works.

    I'm debugging on Windows 7, and my .pro file is as follows:

    Qt Code:
    1. #-------------------------------------------------
    2. #
    3. # Project created by QtCreator 2011-12-30T11:32:37
    4. #
    5. #-------------------------------------------------
    6.  
    7. QT += core gui
    8.  
    9. TARGET = Up
    10. TEMPLATE = app
    11.  
    12.  
    13. SOURCES += main.cpp\
    14. MainForm.cpp \
    15. AboutForm.cpp
    16.  
    17. HEADERS += MainForm.h \
    18. AboutForm.h
    19.  
    20. FORMS += MainForm.ui \
    21. AboutForm.ui
    22.  
    23.  
    24. QMAKE_CFLAGS_RELEASE += -Zi
    25. QMAKE_CXXFLAGS_RELEASE += -Zi -g
    26. QMAKE_LFLAGS_RELEASE += /DEBUG /OPT:REF
    27.  
    28.  
    29. win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../FATX-build-release/release/ -lFATX
    30. else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../FATX-build-debug/debug/ -lFATX
    31. else:unix:!symbian: LIBS += -L$$PWD/../FATX-build-debug/ -lFATX
    32.  
    33. release{
    34. INCLUDEPATH += $$PWD/../FATX-build-release/release
    35. DEPENDPATH += $$PWD/../FATX-build-release/release
    36. }
    37. debug{
    38. INCLUDEPATH += $$PWD/../FATX-build-debug/debug
    39. DEPENDPATH += $$PWD/../FATX-build-debug/debug
    40. }
    41.  
    42. win32:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../FATX-build-release/release/FATX.lib
    43. else:win32:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../FATX-build-debug/debug/FATX.lib
    44. else:unix:!symbian: PRE_TARGETDEPS += $$PWD/../FATX-build-debug/debug/libFATX.a
    45.  
    46. RESOURCES += \
    47. MainForm.qrc
    To copy to clipboard, switch view to plain text mode 

    Any help at all is greatly appreciated! Thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Application throws exceptions without debugger attached

    What "exceptions" exactly do you mean? Do you just want to say that your program crashes?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jan 2012
    Posts
    8
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Application throws exceptions without debugger attached

    Quote Originally Posted by wysota View Post
    What "exceptions" exactly do you mean? Do you just want to say that your program crashes?
    Yes, sorry. I said "exceptions" because at one line I'll have an exception (e.g. what appears to be double freeing an array but isn't), comment that out get another exception that shouldn't happen. Basically random behavior which causes my application to crash, yes.

    I also forgot to say in the OP, but I'm compiling with MSVCC

  4. #4
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Application throws exceptions without debugger attached

    I think you should be showing the code around your exceptions, the exact error messages, and not your pro file.

    When you run with a debugger, there is probably additional memory fencing, and it sounds like this is helping your bug(s) not be seen. From what you have sound, it sounds like your crash is repeatable, so that points to something that is NOT random.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  5. #5
    Join Date
    Jan 2012
    Posts
    8
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Application throws exceptions without debugger attached

    Quote Originally Posted by amleto View Post
    I think you should be showing the code around your exceptions, the exact error messages, and not your pro file.

    When you run with a debugger, there is probably additional memory fencing, and it sounds like this is helping your bug(s) not be seen. From what you have sound, it sounds like your crash is repeatable, so that points to something that is NOT random.
    Well, here's the call stack: http://nvsx.net/i/5a304.png

    Code it breaks at:

    Qt Code:
    1. Volume* SysExt = new Volume();
    2. Volume* SysAux = new Volume();
    3. Volume* Cache = new Volume();
    4. Volume* Data = new Volume();
    5.  
    6. {snip}
    7.  
    8. if (DeviceStream->ReadUInt32() == Magic)
    9. {
    10. ValidVolumes.push_back(SysExt);
    11. ValidVolumes.push_back(SysAux);
    12. ValidVolumes.push_back(Cache);
    13. ValidVolumes.push_back(Data);
    14. }
    15. else
    16. {
    17. Cache->Size = UsbSizes::CacheNoSystem;
    18. ValidVolumes.push_back(Cache);
    19. ValidVolumes.push_back(Data);
    20. } // when it breaks, it breaks at this line
    To copy to clipboard, switch view to plain text mode 

    My structs:
    Qt Code:
    1. struct Volume
    2. {
    3. string Name;
    4. unsigned int Magic; // Partition magic
    5. unsigned int SerialNumber; // Partition serial number
    6. unsigned int SectorsPerCluster; // Number of sectors per cluster
    7. unsigned int RootDirectoryCluster; // The cluster in which the root directory is located
    8. UINT64 DataStart;
    9. unsigned int Clusters; // Total number of clusters in the partition
    10. BYTE EntrySize; // Size of a chainmap entry
    11. UINT64 Offset; // Offset of the partition
    12. UINT64 Size; // Size of the partition
    13. UINT64 AllocationTableSize;
    14. UINT64 ClusterSize;
    15. unsigned int FatEntryShift;
    16. Folder *Root;
    17. };
    18.  
    19. struct Folder
    20. {
    21. std::vector<UINT32> ClusterChain;
    22. Dirent Dirent;
    23. std::vector<Folder*> CachedFolders;
    24. std::vector<File*> CachedFiles;
    25. bool FatxEntriesRead;
    26. std::string FullPath;
    27. Folder* Parent;
    28. Volume* Volume;
    29. };
    30.  
    31. struct File
    32. {
    33. std::vector<UINT32> ClusterChain;
    34. Dirent Dirent;
    35. std::string FullPath;
    36. Folder* Parent;
    37. };
    To copy to clipboard, switch view to plain text mode 

    Edit: forgot about the exception
    (ad4.c50): Access violation - code c0000005 (first chance)
    s
    sException at 0x77da2073, code: 0xc0000005: write access violation at: 0x1, flags=0x0 in ntdll!RtlpLowFragHeapFree
    First chance exceptions are reported before any exception handling.
    This exception may be expected and handled.
    eax=27a83a05 ebx=0e1c0f1b ecx=0b081bff edx=00000b08 esi=017adf8e edi=0e1c0000
    eip=77da2073 esp=0012cc28 ebp=0012cc5c iopl=0 nv up ei pl nz na pe nc
    cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00010206
    ntdll!RtlpLowFragHeapFree+0xc5:
    77da2073 8930 mov dword ptr [eax],esi ds:0023:27a83a05=????????
    Last edited by landr0id; 10th January 2012 at 19:56.

  6. #6
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Application throws exceptions without debugger attached

    does your software take up a lot of memory?

    do you use malloc/free and new delete?

    how do you use those pointers in the struct? how do you clean up? where is ownership?
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Application throws exceptions without debugger attached

    Write access violation usually means you have an uninitialized pointer somewhere that you are trying to access.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #8
    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: Application throws exceptions without debugger attached

    ... and if it is actually breaking in the code you displayed then I'd be looking closely at the value and validity of the "Cache" pointer used on line 17.

  9. #9
    Join Date
    Jan 2012
    Posts
    8
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Application throws exceptions without debugger attached

    Quote Originally Posted by amleto View Post
    does your software take up a lot of memory?

    do you use malloc/free and new delete?

    how do you use those pointers in the struct? how do you clean up? where is ownership?
    No, not very much memory at all. I use new and delete, yes. The pointers in the struct aren't used in the scope in which the exception is thrown -- all I do is initialize (as shown at the top of my code), then where I inserted {snip} is code where I set some of the non-pointer fields in the Volume structure (Name, Offset, Size, etc.). Ownership is within the class that this function is called and cleanup is done when the class which created the structs is closed.

    Quote Originally Posted by wysota View Post
    Write access violation usually means you have an uninitialized pointer somewhere that you are trying to access.
    That's just it though -- I'm not even referencing anything illegally. If you look at the call stack I posted above, it breaks on vector::_Insert_n, but the vector in which I add the items in that scope isn't even of that element type (vector type = Volume, vector type which causes the exception to be thrown: File*)

    Quote Originally Posted by ChrisW67 View Post
    ... and if it is actually breaking in the code you displayed then I'd be looking closely at the value and validity of the "Cache" pointer used on line 17.
    It breaks upon exiting the scope (or after adding the element to the vector, the line is misleading). The "Cache" pointer is valid.


    Like I said, everything runs fine except when manually debugging (run>attach debugger) under release configuration. What could be causing this to happen under that condition, but not when choosing to debug straight out of Qt creator?

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Application throws exceptions without debugger attached

    Unless some destructor of yours causes something to insert something else to the vector, I wouldn't trust the call stack. It could be you are trying to free an already freed region of memory or something like that. Maybe in debug mode the compiler resets the pointer to zero, causing the other free to simply ignore it. These are just guesses though. You could try just recompiling the whole project to see if the problem goes away, sometimes the (incremental?) linker messes things up.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 4
    Last Post: 27th June 2021, 02:23
  2. Replies: 4
    Last Post: 7th December 2011, 09:20
  3. getting attached curve to a plot
    By corrado1972 in forum Qwt
    Replies: 2
    Last Post: 22nd June 2011, 09:35
  4. Replies: 5
    Last Post: 19th March 2011, 05:09
  5. Replies: 2
    Last Post: 26th March 2009, 08:43

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.