Bug 189863

Summary: Possible memory leak in asDeviceInterface()
Product: [Frameworks and Libraries] solid Reporter: Mark Kretschmann <kretschmann>
Component: libsolid-frontendAssignee: Kevin Ottens <ervin>
Status: RESOLVED NOT A BUG    
Severity: normal CC: amarok-bugs-dist, lfranchi
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In:

Description Mark Kretschmann 2009-04-17 11:10:35 UTC
I've just been running a Valgrind memcheck session with memory leak checking on Amarok, and stumbled upon something that looks like a potential leak in Solid. 

However, I must admit that I'm unsure if I am interpreting this correctly, maybe it's really a bug in Amarok. 

KDE version: 4.2.2


Anyway, here's the log, please let me know what you think:


==12028== 2,832 bytes in 117 blocks are possibly lost in loss record 749 of 5,066
==12028==    at 0x4025D2E: malloc (vg_replace_malloc.c:207)
==12028==    by 0x54A80BC: qMalloc(unsigned) (in /usr/lib/libQtCore.so.4.5.0)
==12028==    by 0x54E09DB: QMapData::node_create(QMapData::Node**, int) (in /usr/lib/libQtCore.so.4.5.0)
==12028==    by 0x645F020: (within /usr/lib/libsolid.so.4.2.0)
==12028==    by 0x6478F59: (within /usr/lib/libsolid.so.4.2.0)
==12028==    by 0x64789E1: (within /usr/lib/libsolid.so.4.2.0)
==12028==    by 0x6476683: (within /usr/lib/libsolid.so.4.2.0)
==12028==    by 0x6473C0B: (within /usr/lib/libsolid.so.4.2.0)
==12028==    by 0x64408E6: Solid::Device::asDeviceInterface(Solid::DeviceInterface::Type const&) const (in /usr/lib/libsolid.so.4.2.0)
==12028==    by 0x12A36149: Solid::StorageAccess const* Solid::Device::as<Solid::StorageAccess>() const (device.h:237)
==12028==    by 0x12A34AB9: MassStorageDeviceHandlerFactory::createHandler(Solid::Device const&, QString const&) const (MassStorageDeviceHandler.cpp:132)
==12028==    by 0x46B54B6: MountPointManager::createHandlerFromDevice(Solid::Device const&, QString const&) (MountPointManager.cpp:521)
==12028==    by 0x46B7423: MountPointManager::init() (MountPointManager.cpp:138)
==12028==    by 0x46B7C6C: MountPointManager::MountPointManager() (MountPointManager.cpp:80)
==12028==    by 0x46B7CFA: MountPointManager::instance() (MountPointManager.cpp:54)
==12028==    by 0xFB91902: ScanManager::getDirsToScan() (ScanManager.cpp:383)
==12028==    by 0xFB93305: ScanManager::startIncrementalScan() (ScanManager.cpp:156)
==12028==    by 0xFBA075F: SqlCollection::startIncrementalScan() (SqlCollection.cpp:117)
==12028==    by 0x4593B5C: CollectionManager::checkCollectionChanges() (CollectionManager.cpp:182)
==12028==    by 0x462C74D: App::continueInit() (App.cpp:627)
==12028==    by 0x462F2F1: App::App() (App.cpp:200)
==12028==    by 0x804BDB4: main (main.cpp:126)
Comment 1 Pino Toscano 2009-04-17 13:14:25 UTC
(In reply to comment #0)
> Anyway, here's the log, please let me know what you think:

That you miss the debug package for kdelibs...
Comment 2 Mark Kretschmann 2009-04-17 13:16:19 UTC
@Pino: Yeah, sorry about that. I thought you might have an idea anyway.
Comment 3 Leo Franchi 2009-04-17 14:00:12 UTC
here's my valgrind output for the same solid codepaths, with debug:

==5378== 
==5378== 2,592 bytes in 64 blocks are possibly lost in loss record 854 of 3,514
==5378==    at 0x4C24CFE: malloc (vg_replace_malloc.c:207)
==5378==    by 0x706FDFC: QMapData::node_create(QMapData::Node**, int) (qmap.cpp:108)
==5378==    by 0xAD6D85D: QMap<QString, QVariant>::node_create(QMapData*, QMapData::Node**, QString const&, QVariant const&) (in /usr/kde/live/lib64/libsolid.so.4.3.0)
==5378==    by 0xAD86F42: QMap<QString, QVariant>::operator[](QString const&) (in /usr/kde/live/lib64/libsolid.so.4.3.0)
==5378==    by 0xAD8661B: Solid::Backends::Hal::HalDevice::property(QString const&) const (in /usr/kde/live/lib64/libsolid.so.4.3.0)
==5378==    by 0xAD9313B: Solid::Backends::Hal::Volume::fsType() const (in /usr/kde/live/lib64/libsolid.so.4.3.0)
==5378==    by 0xAD56C88: Solid::StorageVolume::fsType() const (in /usr/kde/live/lib64/libsolid.so.4.3.0)
==5378==    by 0x2396FED7: MassStorageDeviceHandlerFactory::canHandle(Solid::Device const&) const (MassStorageDeviceHandler.cpp:111)
==5378==    by 0x57B36B2: MountPointManager::createHandlerFromDevice(Solid::Device const&, QString const&) (MountPointManager.cpp:518)
==5378==    by 0x57B5492: MountPointManager::init() (MountPointManager.cpp:138)
==5378==    by 0x57B5C57: MountPointManager::MountPointManager() (MountPointManager.cpp:80)
==5378==    by 0x57B5CCD: MountPointManager::instance() (MountPointManager.cpp:54)
==5378==    by 0x1FC278BC: Meta::SqlTrack::SqlTrack(SqlCollection*, QStringList const&) (SqlMeta.cpp:294)
==5378==    by 0x1FC2833E: Meta::SqlTrack::getTrackFromUid(QString const&, SqlCollection*) (SqlMeta.cpp:281)
==5378==    by 0x1FC18EB9: SqlRegistry::getTrackFromUid(QString const&) (SqlRegistry.cpp:103)
==5378==    by 0x1FC09126: SqlCollection::trackForUrl(KUrl const&) (SqlCollection.cpp:198)
==5378==    by 0x56A5CFC: CollectionManager::trackForUrl(KUrl const&) (CollectionManager.cpp:366)
==5378==    by 0x568C615: Meta::XSPFPlaylist::tracks() (XSPFPlaylist.cpp:168)
==5378==    by 0x55FC915: Playlist::Model::Model() (PlaylistModel.cpp:96)
==5378==    by 0x55FCE80: Playlist::Model::instance() (PlaylistModel.cpp:59)
==5378==    by 0x55FCEA8: The::playlistModel() (PlaylistModel.cpp:930)
==5378==    by 0x571168B: StatusBar::StatusBar(QWidget*) (StatusBar.cpp:93)
==5378==    by 0x574C3DD: MainWindow::MainWindow() (MainWindow.cpp:135)
==5378==    by 0x5733E83: App::continueInit() (App.cpp:594)
==5378==    by 0x5736912: App::App() (App.cpp:200)
==5378==    by 0x403771: main (main.cpp:126)
==5378==
Comment 4 Kevin Ottens 2009-07-07 13:16:13 UTC
Looks like a false positive or a problem in Qt as what we manipulate in the method is completely value based (just checked). On my tests it doesn't seem to show up though.

Closing for now. Feel free to check if it's still existing (since Qt got fixes) and if yes a test case would be excellent.