aMule Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're back! (IN POG FORM)

Author Topic: errors reported by valgrind  (Read 3119 times)

dmeyer0

  • Newbie
  • Karma: 0
  • Offline Offline
  • Posts: 2
errors reported by valgrind
« on: January 04, 2004, 02:07:07 AM »

I tried running valgrind against amule-1.2.3, and found a couple of worrisome things.

First, it's reporting that CUpDownClient::m_pszClientFilename is getting leaked.  I think that this should fix that:

[code:1]
--- BaseClient.cpp.orig   2004-01-03 15:49:49.000000000 -0500
+++ BaseClient.cpp   2004-01-03 15:45:27.000000000 -0500
@@ -203,6 +203,9 @@
    if (m_pszUsername) {
       delete[] m_pszUsername;
    }
+   if (m_pszClientFilename) {
+      delete[] m_pszClientFilename;
+   }
    //printf(>4...>);
    if (m_abyPartStatus) {
       delete[] m_abyPartStatus;
[/code:1]

but Aleric was worried that it was being deliberately leaked so that it could be put into pmyListCtrl in FileDetailDiagog.cpp.  If that's the case, someone _really_ owes us a comment.

The other problem reported was a used-after-deleted problem:

==31285== Invalid memory access of size 4
==31285==    at 0x80A966A: CDownloadQueue::ProcessLocalRequests() (DownloadQueue.cpp:978)
==31285==    by 0x80A76BA: CDownloadQueue::Process() (DownloadQueue.cpp:300)
==31285==    by 0x81B0EBE: TimerProc() (UploadQueue.cpp:659)
==31285==    by 0x81BCB64: CamuleDlg::OnUQTimer(wxTimerEvent&) (amuleDlg.cpp:312)
==31285==    Address 0x43FBB82C is 4 bytes inside a block of size 36 free'd
==31285==    at 0x4001DC3A: __builtin_delete (vg_replace_malloc.c:244)
==31285==    by 0x4001DC58: operator delete(void*) (vg_replace_malloc.c:253)
==31285==    by 0x806F6A3: CEMSocket::SendPacket(Packet*, bool, bool) (EMSocket.cpp:443)
==31285==    by 0x8177E53: CServerSocket::SendPacket(Packet*, bool, bool) (ServerSocket.cpp:580)

I think the problem is in these two lines:

  theApp.serverconnect->SendPacket(packet, true);
  theApp.uploadqueue->AddUpDataOverheadServer(packet->size);

SendPacket deletes the packet after it sends it, then AddUpDataOverheadServer gets passed packet->size.  Which can't be good.
Logged