using a button slot start boostrap bitdht,but crashed. run bdexample no problem.
using the same bdboot.txt, using bitdht-0.2.
code:
void DhtDemo::onBootStrapDht()
{
bdNodeId ownId;
bdStdRandomNodeId(&ownId);
uint16_t port = 6775;
std::string appId = "aexId";
std::string bootstrapfile = "bdboot.txt";
qDebug()<<port<<QString((char*)ownId.data)<<QString(appId.c_str())<<QString(bootstrapfile.c_str());
BitDhtHandler dht(&ownId, port, appId, bootstrapfile);
}
backtrace:
gdb ./demo
GNU gdb (Gentoo 7.2 p1) 7.2
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.gentoo.org/>...
Reading symbols from /home/gzleo/kitphone-svn/bitdht/demo/demo...done.
(gdb) r
Starting program: /home/gzleo/kitphone-svn/bitdht/demo/demo
[Thread debugging using libthread_db enabled]
6775 "%alC]b±:3£rX¨C$" "aexId" "../example/bdboot.txt"
BitDhtHandler::BitDhtHandler()
Using Id: 25616c435d898c6205b13a3317a31d7258a84324
Using Bootstrap File: ../example/bdboot.txt
Converting OwnId to bdNodeId....
BitDhtHandler() startup ... creating UdpBitDht
bdThread::bdThread()
createThread() creating a bdThread
[New Thread 0x7fffe9714700 (LWP 10957)]
createThread() created Thread.mTid: 140737109903104
bdThread::bdThread()
bdthread_init()
bdNodeManager::bdNodeManager() ID: 25616c435d898c6205b13a3317a31d7258a84324
bdNodeManager::addCallback()
BitDhtHandler() starting threads and dht
createThread() creating a bdThread
[New Thread 0x7fffe8f13700 (LWP 10958)]
createThread() created Thread.mTid: 140737101510400
bdthread_init()
bdNodeManager::addPeer() Overloaded (doing Callback)
bdNodeManager::doNodeCallback() 672cc2c772b2d30f2ff1bcf3e5ff0743e9776236 ip:184.56.151.190:11951peerflags: 1
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffe8f13700 (LWP 10958)]
0x00007fff00000001 in ?? ()
(gdb) bt
#0 0x00007fff00000001 in ?? ()
#1 0x000000000040a377 in BdCallback::dhtNodeCallback(bdId const*, unsigned int) ()
#2 0x000000000041b556 in bdNodeManager::doNodeCallback (this=0x92dca0, id=0x7fffe8f12b10, peerflags=1)
at bitdht/bdmanager.cc:815
#3 0x000000000041b45c in bdNodeManager::addPeer (this=0x92dca0, id=0x7fffe8f12b10, peerflags=1)
at bitdht/bdmanager.cc:792
#4 0x000000000041421b in bdNode::msgin_pong (this=0x92dca0, id=0x7fffe8f12b10, transId=0x7fffe8f12bf0,
versionId=0x7fffe8f12ba0) at bitdht/bdnode.cc:1539
#5 0x0000000000413d7d in bdNode::recvPkt (this=0x92dca0,
msg=0x924780 "d1:rd2:id20:g,\302\307r\262\323\017/\361\274\363\345\377\aC\351wb62:ip4:\323f\225\026e1:t2:591:v4:UTb*1:y1:re\246", len=66, addr=...) at bitdht/bdnode.cc:1328
#6 0x00000000004117c5 in bdNode::iteration (this=0x92dca0) at bitdht/bdnode.cc:187
#7 0x000000000041a48f in bdNodeManager::iteration (this=0x92dca0) at bitdht/bdmanager.cc:373
#8 0x000000000040cb73 in UdpBitDht::run (this=0x91d180) at udp/udpbitdht.cc:211
#9 0x000000000041dfff in bdthread_init (p=0x91d190) at util/bdthreads.cc:57
#10 0x00007ffff63c5baa in start_thread () from /lib64/libpthread.so.0
#11 0x00007ffff5974e9d in clone () from /lib64/libc.so.6
(gdb)
Sorry this is so obvious ;)
BitDhtHandler is being destroyed at the end of the function.
This class must be persistent!
change it to BitDhtHandler *bdhandler = new BitDhtHandler(...) and it'll work.