Results 1 to 4 of 4

Thread: Qt application crashing - Heap errors?

  1. #1
    Join Date
    Aug 2010
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Qt application crashing - Heap errors?

    Hi

    I am busy with my 2nd year computer science project, but I have run into some issues. The problems start when I use QFileDialog, as shown below:


    Qt Code:
    1. QString fileName = QFileDialog::getOpenFileName(parentWidget(), tr("Open File"),
    2. ".",tr("DEM Files (*.map *.dem *.bmp);;All Files(*)"),0,QFileDialog::DontUseNativeDialog);
    To copy to clipboard, switch view to plain text mode 

    I get the following message in my Application output window

    Lowest section in C:\PROGRA~1\COMMON~1\MICROS~1\OFFICE14\Cultures\OF FICE.ODF is .text at 10001000
    Lowest section in C:\PROGRA~1\MICROS~3\Office14\1033\GrooveIntlResou rce.dll is .text at 10001000

    I am not to sure if I should worry about this or why it is happening.

    the next error I get is:
    HEAP[Terrain_Generator.exe]:
    Invalid address specified to RtlFreeHeap( 003E0000, 0C1121C8 )

    which causes my program to crash. It Happens when I return the stat variable, see code below.

    My analysis method that causes the crash
    Qt Code:
    1. TerrainStats* TerrainAnalyser::analyseTerrain(const HeightMap &map, int sweeps, int radius){
    2. Levels = sweeps;
    3.  
    4. if (sweeps < 0)
    5. sweeps = -sweeps;
    6.  
    7. GaussKernel Akern = makeBlurKernel(radius);
    8. HeightMap tmp(map);
    9. HeightMap tmp2(map);
    10. TerrainStats* stats = new TerrainStats(sweeps);
    11.  
    12. for (int cnt = 0; cnt < sweeps; cnt++){
    13. tmp = GaussianBlur(tmp,Akern);
    14. tmp2 = (tmp2 - tmp);
    15. populateStats(tmp2,stats->levelStats[cnt],cnt);
    16. tmp2 = tmp;
    17. }
    18.  
    19. return stats; //<- This is what causes the problem
    20. }
    To copy to clipboard, switch view to plain text mode 

    I tried a simpler example but it doesn't crash, so it must be something stupid that I am overlooking. I have spent 2 days trying to find it but with no success.

    I call the method as follows

    Qt Code:
    1. TerrainStats *stats = TAnalyser->analyseTerrain((*current),6,32);
    2. populateTable((*stats));
    To copy to clipboard, switch view to plain text mode 

    Thanks in advance
    Last edited by System123; 23rd August 2010 at 12:24. Reason: missing [code] tags

  2. #2
    Join Date
    Dec 2007
    Posts
    27
    Thanks
    1
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt application crashing - Heap errors?

    the posted code looks ok. When you leave the method with
    Qt Code:
    1. return stats;
    To copy to clipboard, switch view to plain text mode 
    the local variables will be cleaned up. Is it possible that the crash was caused in destruction of the objects from type HeightMap or GaussKernel. Do you have a stacktrace or a debugger output?

  3. The following user says thank you to yakin for this useful post:

    System123 (23rd August 2010)

  4. #3
    Join Date
    Aug 2010
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt application crashing - Heap errors?

    Thanks

    You are correct, it is my delete[] statements that are causing the errors, but I don't know why because I am quite sure I implemented them correctly. All my Heighmap and GaussKernel structs can only be created using the constructor.

    I have reprogrammed the way somethings work, but I am still getting the same problems.

    here is the stack trace from Qt Creator

    Qt Code:
    1. 0 ntdll!RtlQueryEnvironmentVariable_U C:\Windows\system32\ntdll.dll 0
    2. 1 ntdll!RtlAreBitsClear C:\Windows\system32\ntdll.dll 0
    3. 2 ntdll!RtlAreBitsClear C:\Windows\system32\ntdll.dll 0
    4. 3 ntdll!RtlUnicodeStringToOemString C:\Windows\system32\ntdll.dll 0
    5. 4 ntdll!RtlpSetUserPreferredUILanguages C:\Windows\system32\ntdll.dll 0
    6. 5 ntdll!RtlTraceDatabaseValidate C:\Windows\system32\ntdll.dll 0
    7. 6 ntdll!RtlUnicodeStringToOemString C:\Windows\system32\ntdll.dll 0
    8. 7 msvcrt!malloc C:\Windows\system32\msvcrt.dll 0
    9. 8 operator new 0
    10. 9 operator new[] 0
    11. 10 HeightMap::HeightMap Types.cpp 29
    12. 11 TerrainAnalyser::analyseTerrain terrainanalyser.cpp 97
    13. 12 GUI::openFile GUI.cpp 160
    14. 13 GUI::qt_metacall moc_GUI.cpp 71
    15. 14 QMetaObject::activate qobject.cpp 3104
    16. 15 QMetaObject::activate qobject.cpp 3198
    17. 16 QAction::triggered moc_qaction.cpp 236
    18. 17 QAction::activate qaction.cpp 1160
    19. 18 QMenuPrivate::activateCausedStack qmenu.cpp 967
    20. 19 QMenuPrivate::activateAction qmenu.cpp 1060
    21. 20 QMenu::mouseReleaseEvent qmenu.cpp 2254
    22. ... <More>
    To copy to clipboard, switch view to plain text mode 

    Attatched is the debugger output. Debugger Output.pdf
    If anyone would like to look at the code e-mail me and I will send the full code to you, I don't want to attach it because it is a current project.

    Thanks

  5. #4
    Join Date
    Aug 2010
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default [RESOLVED] Qt application crashing - Heap errors?

    Thanks for the help, it was a stupid problem of me not editing using the correct variable when in the array, so the array index was negative.

Similar Threads

  1. Application crashing
    By addu in forum Qt Programming
    Replies: 9
    Last Post: 22nd May 2009, 10:37
  2. Application crashing on setting Model in QComboBox.
    By kaushal_gaurav in forum Qt Programming
    Replies: 6
    Last Post: 13th February 2009, 18:20
  3. Replies: 4
    Last Post: 1st December 2008, 11:13
  4. application freezes without crashing (and closing)
    By nass in forum Qt Programming
    Replies: 15
    Last Post: 25th September 2007, 11:21
  5. Application is Crashing
    By shyam prasad in forum Qt Programming
    Replies: 1
    Last Post: 9th January 2007, 17:04

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.