aMule Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're back! (IN POG FORM)

Author Topic: Fix: crash on amuled when starting up kademlia  (Read 2457 times)

xor

  • Approved Newbie
  • *
  • Karma: 4
  • Offline Offline
  • Posts: 11
Fix: crash on amuled when starting up kademlia
« on: November 18, 2007, 02:31:53 PM »

Hi.

This is a bug I've found in amuled that is yet not solved (at least for amule-cvs-20071112). It happens when launching amuled and it starts kademlia. I've debugged amuled with gdb and found the problem in SafeFile.cpp, CFileDataIO::ReadTag, line 456:

        } catch (...) {
                printf("Invalid Kad tag; type=0x%02x name=0x%02x\n",
                      type, ((const char *)unicode2char(name))[0]);
                delete retVal;
                throw;
        }

The problem is that sometimes unicode2char returns NULL, and so trying to access character at pos.
  • triggers an exception. I patched it as follows:


        } catch (...) {
               //  Do not try to print first byte of name, unicode2char sometimes returns NULL
                printf("Invalid Kad tag; type=0x%02x\n", type);   
                printf("Invalid Kad tag; name=%s\n", ((const char *)unicode2char(name)));
                delete retVal;
                throw;
        }
       
This is the backtrace of the error:

----------------------------=| BACKTRACE FOLLOWS: |=----------------------------
Current version is: aMuled CVS using  v2.8.6 (Snapshot: Mon Nov 12 07:01:55 CET 2007)
Running on: Linux 2.4.27 i686

[2] CamuleApp::OnFatalException() in amule.cpp:1294
[3] wxFatalSignalHandler in /home/jordi/mldonkey/amule/wxgtk-2.8.6/lib/libwx_baseu-2.8.so.0[0x4019b5e8]
[4] ?? in /lib/libpthread.so.0 [0x4002d825]
[5] ?? in /lib/libc.so.6 [0x4031d678]
[6] Kademlia::CIndexed::ReadFile() in Indexed.cpp:137
[7] Kademlia::CIndexed::CIndexed() in Indexed.cpp:80
[8] Kademlia::CKademlia::Start(Kademlia::CPrefs*) in Kademlia.cpp:107
[9] Kademlia::CKademlia::Start() in Kademlia.cpp:80
[10] CamuleApp::StartKad() in amule.cpp:2144
[11] CamuleApp::OnInit() in amule.cpp:815
[12] CamuleDaemonApp::OnInit() in amuled.cpp:439
[13] wxAppConsole::CallOnInit() in app.h:76
[14] wxEntry(int&, wchar_t**) in /home/jordi/mldonkey/amule/wxgtk-2.8.6/lib/libwx_baseu-2.8.so.0[0x40124f50]
[15] wxEntry(int&, char**) in /home/jordi/mldonkey/amule/wxgtk-2.8.6/lib/libwx_baseu-2.8.so.0[0x40125050]
[16] main in amuled.cpp:101
[17] __libc_start_main in /lib/libc.so.6[0x40309e36]
[18] _start in start.S:105
Logged

phoenix

  • Evil respawning bird from aMule Dev Team
  • Developer
  • Hero Member
  • *****
  • Karma: 44
  • Offline Offline
  • Posts: 2503
  • The last shadow you'll ever see
Re: Fix: crash on amuled when starting up kademlia
« Reply #1 on: November 18, 2007, 03:37:17 PM »

Great job!

Your patch is committed, will be in tomorrow CVS tarball.

Thank you very much!

Cheers!
Logged

skolnick

  • Global Moderator
  • Hero Member
  • *****
  • Karma: 24
  • Offline Offline
  • Posts: 1188
  • CentOS 6 User
Re: Fix: crash on amuled when starting up kademlia
« Reply #2 on: November 18, 2007, 08:15:28 PM »

However, I think the first question is why does this log appear? it happens to me all the time when using amule monolithic, but I can't understand why. It appears in the log as soon as I try to connect to kad.

Regards.
Logged