crash in libkccdb, reason found

Alexander Neundorf neundorf at kde.org
Sat Jun 19 21:11:50 BST 2004


Hi,

the following code crashes (with Pantera - Reinventing The Steel):

      KCDDB::Config cddbConfig;
      cddbConfig.load();
      KCDDB::Client cddbClient(cddbConfig);
      cddbClient.setBlockingMode(true);
      KCDDB::TrackOffsetList list;
      for (unsigned int i=0; i<m_diskInfo->tracks.count()-1; i++)
         list<<m_diskInfo->tracks[i];
      list<<0;
      list<<m_diskInfo->tracks[m_diskInfo->tracks.count()-1];
     KCDDB::CDDB::Result r = cddbClient.lookup(list);
      KCDDB::CDInfoList response = cddbClient.lookupResponse();
      KCDDB::CDInfoList::ConstIterator it = response.begin();
      if (it!= response.end())
      {
         KCDDB::CDInfo cdi(*it);
         m_diskPage->m_diskTitle->setText(i18n("<b>Audio CD: %1 - %2
(%3)</b>").arg(cdi.artist).arg(cdi.title).arg(cdi.year));
         int i=0;
         for (QListViewItem *track=m_diskPage->m_dvdLv->firstChild();
track!=0; track=track->nextSibling())
         {
            track->setText(1,cdi.trackInfoList[i].title);
            i++;
         }
      }

It crashes in the dtor of the KCDDB::Config object.
The reason is (probably) the following code:

 Client::Client(const Config & config) : QObject(),
    cdInfoLookup(0),
    cdInfoSubmit(0)
  {
    d = new Private;
    d->config = config;   //// this line
  }

I didn't find an implementation neither of an operator= nor of a copy ctor for 
Config, ConfigBase or KConfigSkeleton. So it seems the default copy ctor is 
used. This can't be a good thing since KConfigSkeleton has a private 
d-pointer. So in the dtor of the with operator= copied Config object this 
d-pointer will probably be deleted a second time -> crash.

What's the right way to fix this ?
-making the copy ctor in KConfigSkeleton private
-insert a #warning in the Client(const Config&) ctor
-something else which actually fixes the problem

Bye
Alex
-- 
Work: alexander.neundorf at jenoptik.com - http://www.jenoptik-los.de
Home: neundorf at kde.org                - http://www.kde.org
      alex at neundorf.net               - http://www.neundorf.net



More information about the kde-multimedia mailing list