Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-27117

plugin memory leaks detected (including sql driver)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P4: Low
    • 5.1.0
    • 4.8.2
    • Core: Plugins
    • None
    • Window 7, Visual Studio Express 2010
    • 288d3aceee83192bb84d73c60268a18722488adf

    Description

      I got the same issue that the abandoned bug #12220.

      I found a memory leak with QtSql and the addDatabase function using the following code.

      main.cpp
      #include <QtGui/QApplication>
      #include <QtSql>
      
      #if defined(WIN32) && defined(_DEBUG)
      #define _CRTDBG_MAP_ALLOC
      #include <stdlib.h>
      #include <crtdbg.h>
      #define DEBUG_NEW new( _NORMAL_BLOCK, __FILE__, __LINE__ )
      #define new DEBUG_NEW
      #endif
      
      int main(int argc, char *argv[])
      {
      #if defined(_MSC_VER) && defined(_DEBUG)
      	_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
      #endif
      
      	QApplication a(argc, argv);
      
      	QSqlDatabase* pDB = NULL;
      	pDB = new QSqlDatabase(QSqlDatabase::addDatabase("QODBC", "newConnectionName"));
      	if(pDB){
      		delete pDB;
      		pDB = NULL;
      		QSqlDatabase::removeDatabase("newConnectionName");
      	}
      
      	return 0;
      }
      

      I also tried this code on Linux with Qt 4.7 and valgrind, but i don't detect memory leak, so i think it's a problem with the MSVC build.

      If i change QODBC with QSQLITE or QPSQL, i got the same issue.

      Here the output i got:

      'TestQt.exe': Loaded 'E:\DevelWin\Testing\TestQt\build\win32\Debug\TestQt.exe', Symbols loaded.
      'TestQt.exe': Loaded 'C:\Windows\System32\ntdll.dll', Cannot find or open the PDB file
      'TestQt.exe': Loaded 'C:\Windows\System32\kernel32.dll', Cannot find or open the PDB file
      'TestQt.exe': Loaded 'C:\Windows\System32\KernelBase.dll', Cannot find or open the PDB file
      'TestQt.exe': Loaded 'C:\Qt\4.8.2vs2010\bin\QtGuid4.dll', Symbols loaded.
      'TestQt.exe': Loaded 'C:\Windows\System32\gdi32.dll', Cannot find or open the PDB file
      'TestQt.exe': Loaded 'C:\Windows\System32\user32.dll', Cannot find or open the PDB file
      'TestQt.exe': Loaded 'C:\Windows\System32\lpk.dll', Cannot find or open the PDB file
      'TestQt.exe': Loaded 'C:\Windows\System32\usp10.dll', Cannot find or open the PDB file
      'TestQt.exe': Loaded 'C:\Windows\System32\msvcrt.dll', Cannot find or open the PDB file
      'TestQt.exe': Loaded 'C:\Windows\System32\comdlg32.dll', Cannot find or open the PDB file
      'TestQt.exe': Loaded 'C:\Windows\System32\shlwapi.dll', Cannot find or open the PDB file
      'TestQt.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.7601.17514_none_ec83dffa859149af\comctl32.dll', Cannot find or open the PDB file
      'TestQt.exe': Loaded 'C:\Windows\System32\advapi32.dll', Cannot find or open the PDB file
      'TestQt.exe': Loaded 'C:\Windows\System32\sechost.dll', Cannot find or open the PDB file
      'TestQt.exe': Loaded 'C:\Windows\System32\rpcrt4.dll', Cannot find or open the PDB file
      'TestQt.exe': Loaded 'C:\Windows\System32\shell32.dll', Cannot find or open the PDB file
      'TestQt.exe': Loaded 'C:\Windows\System32\oleaut32.dll', Cannot find or open the PDB file
      'TestQt.exe': Loaded 'C:\Windows\System32\ole32.dll', Cannot find or open the PDB file
      'TestQt.exe': Loaded 'C:\Windows\System32\imm32.dll', Cannot find or open the PDB file
      'TestQt.exe': Loaded 'C:\Windows\System32\msctf.dll', Cannot find or open the PDB file
      'TestQt.exe': Loaded 'C:\Windows\System32\winmm.dll', Cannot find or open the PDB file
      'TestQt.exe': Loaded 'C:\Windows\System32\winspool.drv', Cannot find or open the PDB file
      'TestQt.exe': Loaded 'C:\Qt\4.8.2vs2010\bin\QtCored4.dll', Symbols loaded.
      'TestQt.exe': Loaded 'C:\Windows\System32\ws2_32.dll', Cannot find or open the PDB file
      'TestQt.exe': Loaded 'C:\Windows\System32\nsi.dll', Cannot find or open the PDB file
      'TestQt.exe': Loaded 'C:\Windows\System32\msvcp100d.dll', Symbols loaded.
      'TestQt.exe': Loaded 'C:\Windows\System32\msvcr100d.dll', Symbols loaded.
      'TestQt.exe': Loaded 'C:\Qt\4.8.2vs2010\bin\QtSqld4.dll', Symbols loaded.
      'TestQt.exe': Loaded 'C:\Windows\System32\uxtheme.dll', Cannot find or open the PDB file
      'TestQt.exe': Loaded 'C:\Windows\System32\dwmapi.dll', Cannot find or open the PDB file
      'TestQt.exe': Loaded 'C:\Windows\System32\cryptbase.dll', Cannot find or open the PDB file
      'TestQt.exe': Loaded 'C:\Qt\4.8.2vs2010\plugins\sqldrivers\qsqlodbcd4.dll', Cannot find or open the PDB file
      'TestQt.exe': Loaded 'C:\Windows\System32\odbc32.dll', Cannot find or open the PDB file
      'TestQt.exe': Loaded 'C:\Windows\System32\odbcint.dll', Binary was not built with debug information.
      Detected memory leaks!
      Dumping objects ->
      {2861} normal block at 0x00DDDE00, 76 bytes long.
       Data: <d  ]           ]> 64 E2 98 5D 00 DD DD 00 00 00 00 00 FC B8 AE 5D 
      {2860} normal block at 0x00DDDD00, 12 bytes long.
       Data: <   `       `> E8 D7 1C 60 00 DE DD 00 D4 D7 1C 60 
      {2856} normal block at 0x00DDFE08, 128 bytes long.
       Data: <    6   3       > 01 00 00 00 36 00 00 00 33 00 00 00 1A FE DD 00 
      {2106} normal block at 0x00DDF4E8, 64 bytes long.
       Data: <                > 01 00 00 00 16 00 00 00 13 00 00 00 FA F4 DD 00 
      {2079} normal block at 0x00DDF420, 56 bytes long.
       Data: <   `           ]> 00 00 1B 60 D8 FB DD 00 08 FE DD 00 B4 B9 AE 5D 
      {2077} normal block at 0x00DDFBD8, 122 bytes long.
       Data: <    3   3       > 01 00 00 00 33 00 00 00 33 00 00 00 EA FB DD 00 
      {257} normal block at 0x00DD6E98, 40 bytes long.
       Data: <        @B      > 00 00 00 00 CC CD CD CD 40 42 0F 00 00 00 00 00 
      {256} normal block at 0x00DD6DE0, 120 bytes long.
       Data: < l ] m         ]> 9C 6C 99 5D 98 6D DD 00 00 00 00 00 FC B8 AE 5D 
      {255} normal block at 0x00DD6D98, 8 bytes long.
       Data: <\l ] m  > 5C 6C 99 5D E0 6D DD 00 
      {254} normal block at 0x00DD6D30, 40 bytes long.
       Data: <        @B      > 00 00 00 00 CC CD CD CD 40 42 0F 00 00 00 00 00 
      {253} normal block at 0x00DD6CB8, 60 bytes long.
       Data: <     m          > 01 00 00 00 98 6D DD 00 F0 08 00 00 00 CD CD CD 
      Object dump complete.
      The program '[796] TestQt.exe: Native' has exited with code 0 (0x0).
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            ebeuque Eric Beuque
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes