KExtendedSocket crash

Rob Kaper cap at capsi.com
Wed Jul 17 21:47:45 BST 2002


Getting a weird crash in KExtendedSocket..

Apparently the related code there is

      addrinfo *p, *q = NULL;
      if (d->current == 0)
--->    p = d->current = d->resolution->data;
      else
        p = d->current->ai_next;


But that's as far as my KExtendedSocket insights go. ;-)

It started happening since the attached changes to kdegames/atlantik
(KExtSock doesn't allow you to use connectHost twice to just reconnect
elsewhere (or after an error in the first attempt), so I'll have to create a
new network instance. AtlantikNetwork inherits KExtendedSocket.

Click the "localhost" server a couple of times (make sure there is nothing
running on localhost port 1234 though) and voila.

Rob

[New Thread 1024 (LWP 12798)]
0x40f28389 in __wait4 () from /lib/libc.so.6
#0  0x40f28389 in __wait4 () from /lib/libc.so.6
#1  0x40fa0058 in __DTOR_END__ () from /lib/libc.so.6
#2  0x40dce263 in waitpid (pid=12802, stat_loc=0x0, options=0)
    at wrapsyscall.c:173
#3  0x4066e2e9 in KCrash::defaultCrashHandler () at kiconloader.cpp:1079
#4  0x40dcbd94 in pthread_sighandler (signo=11, ctx={gs = 0, __gsh = 0, 
      fs = 0, __fsh = 0, es = 43, __esh = 0, ds = 43, __dsh = 0, 
      edi = 3221220304, esi = 3296973055, ebp = 3221220152, esp =
3221220092, 
      ebx = 1081058828, edx = 3296973055, ecx = 135275784, eax = 97, 
      trapno = 14, err = 5, eip = 1080682198, cs = 35, __csh = 0, 
      eflags = 66183, esp_at_signal = 3221220092, ss = 43, __ssh = 0, 
      fpstate = 0xbfffe880, oldmask = 2147483648, cr2 = 3296973067})
    at signals.c:97
#5  <signal handler called>
#6  0x4069e6d6 in KExtendedSocket::connectionEvent (this=0x8102508)
    at kextsock.cpp:2035
#7  0x4069d248 in KExtendedSocket::startAsyncConnect (this=0x8102508)
    at kextsock.cpp:1400
#8  0x4004f6e0 in AtlantikNetwork::serverConnect (this=0x8102508, host={
      static null = {
        static null = <same as static member of an already seen type>, 
        d = 0x80610e0, static shared_null = 0x80610e0}, d = 0xbfffebd0, 
      static shared_null = 0x80610e0}, port=1234) at
atlantik_network.cpp:797
#9  0x400472aa in AtlantikNetwork::qt_invoke (this=0x8102508, _id=29, 
    _o=0xbfffec4c) at atlantik_network.moc:643
#10 0x40926e26 in QObject::activate_signal () at eval.c:88
#11 0x8058917 in SelectServer::serverConnect (this=0xbfffecf8,
t0=0xbfffecf8, 
    t1=1234) at selectserver_widget.moc:123
#12 0x80596e3 in SelectServer::connectPressed (this=0x813b178)
    at selectserver_widget.cpp:159
#13 0x8058a61 in SelectServer::qt_invoke (this=0x813b178, _id=48, 
    _o=0xbfffedc4) at selectserver_widget.moc:135
#14 0x40926e26 in QObject::activate_signal () at eval.c:88
#15 0x40b5d693 in QListView::doubleClicked () at eval.c:88
#16 0x4045dbef in KListView::contentsMouseDoubleClickEvent ()
    at ktoolbar.moc:111
#17 0x409e875f in QScrollView::viewportMouseDoubleClickEvent () at eval.c:88
#18 0x409e7feb in QScrollView::eventFilter () at eval.c:88
#19 0x409c62fa in QListView::eventFilter () at eval.c:88
#20 0x40925200 in QObject::activate_filters () at eval.c:88
#21 0x409250e1 in QObject::event () at eval.c:88
#22 0x4094ec99 in QWidget::event () at eval.c:88
#23 0x408e9696 in QApplication::internalNotify () at eval.c:88
#24 0x408e8fe3 in QApplication::notify () at eval.c:88
#25 0x406084ba in KApplication::notify (this=0xbffff574, receiver=0x813c7d0, 
    event=0xbffff240) at kapplication.cpp:556
#26 0x408a0beb in QETWidget::translateMouseEvent () at eval.c:88
#27 0x4089e227 in QApplication::x11ProcessEvent () at eval.c:88
#28 0x4089d1f6 in QApplication::processNextEvent () at eval.c:88
#29 0x408eaacf in QApplication::enter_loop () at eval.c:88
#30 0x4089d16b in QApplication::exec () at eval.c:88
#31 0x8055544 in main (argc=1, argv=0xbffff6e4) at main.cpp:73
#32 0x40ea174f in __libc_start_main (main=0x8055320 <main>, argc=1, 
    ubp_av=0xbffff6e4, init=0x804fe0c <_init>, fini=0x805b680 <_fini>, 
    rtld_fini=0x4000aa00 <_dl_fini>, stack_end=0xbffff6dc)
    at ../sysdeps/generic/libc-start.c:129

-- 
Rob Kaper     | Gimme some love, gimme some skin,
cap at capsi.com | if we ain't got that then we ain't got much
www.capsi.com | and we ain't got nothing, nothing! -- "Nothing" by A
-------------- next part --------------
Index: client/atlantik.cpp
===================================================================
RCS file: /home/kde/kdegames/atlantik/client/atlantik.cpp,v
retrieving revision 1.105
diff -u -3 -d -p -r1.105 atlantik.cpp
--- client/atlantik.cpp	2002/07/16 01:47:36	1.105
+++ client/atlantik.cpp	2002/07/17 20:40:10
@@ -69,24 +69,8 @@ Atlantik::Atlantik () : KMainWindow ()
 
 	connect(m_atlanticCore, SIGNAL(removeGUI(Trade *)), this, SLOT(removeGUI(Trade *)));
 
-	// Network layer
-	m_atlantikNetwork = new AtlantikNetwork(m_atlanticCore, this, "atlantikNetwork");
-
-	connect(m_atlantikNetwork, SIGNAL(msgInfo(QString)), this, SLOT(slotMsgInfo(QString)));
-	connect(m_atlantikNetwork, SIGNAL(msgError(QString)), this, SLOT(slotMsgError(QString)));
-	connect(m_atlantikNetwork, SIGNAL(msgChat(QString, QString)), this, SLOT(slotMsgChat(QString, QString)));
-
-	connect(m_atlantikNetwork, SIGNAL(connectionSuccess()), this, SLOT(slotNetworkConnected()));
-	connect(m_atlantikNetwork, SIGNAL(connectionFailed(int)), this, SLOT(slotNetworkError(int)));
-
-	connect(m_atlantikNetwork, SIGNAL(joinedGame()), this, SLOT(showSelectConfiguration()));
-	connect(m_atlantikNetwork, SIGNAL(initGame()), this, SLOT(initGame()));
-	connect(m_atlantikNetwork, SIGNAL(gameStarted()), this, SLOT(gameStarted()));
-
-	connect(m_atlantikNetwork, SIGNAL(newPlayer(Player *)), this, SLOT(newPlayer(Player *)));
-	connect(m_atlantikNetwork, SIGNAL(newEstate(Estate *)), this, SLOT(newEstate(Estate *)));
-	connect(m_atlantikNetwork, SIGNAL(newTrade(Trade *)), this, SLOT(createGUI(Trade *)));
-	connect(m_atlantikNetwork, SIGNAL(newAuction(Auction *)), this, SLOT(newAuction(Auction *)));
+	m_atlantikNetwork = 0;
+	initNetworkObject();
 
 	// Menu,toolbar: Move
 	m_roll = KStdGameAction::roll(m_atlantikNetwork, SLOT(rollDice()), actionCollection());
@@ -240,8 +224,11 @@ void Atlantik::showSelectServer()
 		delete m_selectGame;
 		m_selectGame = 0;
 	}
-	connect(m_selectServer, SIGNAL(serverConnect(const QString, int)), m_atlantikNetwork, SLOT(serverConnect(const QString, int)));
-	connect(m_atlantikNetwork, SIGNAL(gameListClear()), this, SLOT(showSelectGame()));
+	if (m_atlantikNetwork)
+	{
+		connect(m_selectServer, SIGNAL(serverConnect(const QString, int)), m_atlantikNetwork, SLOT(serverConnect(const QString, int)));
+		connect(m_atlantikNetwork, SIGNAL(gameListClear()), this, SLOT(showSelectGame()));
+	}
 }
 
 void Atlantik::showSelectGame()
@@ -332,6 +319,9 @@ void Atlantik::slotNetworkError(int errn
 	}
 
 	serverMsgsAppend(errMsg);
+
+	// Re-init network object
+	initNetworkObject();
 }
 
 void Atlantik::initGame()
@@ -476,4 +466,33 @@ void Atlantik::playerChanged()
 	m_jailCard->setEnabled(m_playerSelf->hasTurn() && m_playerSelf->inJail());
 	m_jailPay->setEnabled(m_playerSelf->hasTurn() && m_playerSelf->inJail());
 	m_jailRoll->setEnabled(m_playerSelf->hasTurn() && m_playerSelf->inJail());
+}
+
+void Atlantik::initNetworkObject()
+{
+	if (m_atlantikNetwork)
+		delete m_atlantikNetwork;
+
+	m_atlantikNetwork = new AtlantikNetwork(m_atlanticCore, this, "atlantikNetwork");
+	connect(m_atlantikNetwork, SIGNAL(msgInfo(QString)), this, SLOT(slotMsgInfo(QString)));
+	connect(m_atlantikNetwork, SIGNAL(msgError(QString)), this, SLOT(slotMsgError(QString)));
+	connect(m_atlantikNetwork, SIGNAL(msgChat(QString, QString)), this, SLOT(slotMsgChat(QString, QString)));
+
+	connect(m_atlantikNetwork, SIGNAL(connectionSuccess()), this, SLOT(slotNetworkConnected()));
+	connect(m_atlantikNetwork, SIGNAL(connectionFailed(int)), this, SLOT(slotNetworkError(int)));
+
+	connect(m_atlantikNetwork, SIGNAL(joinedGame()), this, SLOT(showSelectConfiguration()));
+	connect(m_atlantikNetwork, SIGNAL(initGame()), this, SLOT(initGame()));
+	connect(m_atlantikNetwork, SIGNAL(gameStarted()), this, SLOT(gameStarted()));
+
+	connect(m_atlantikNetwork, SIGNAL(newPlayer(Player *)), this, SLOT(newPlayer(Player *)));
+	connect(m_atlantikNetwork, SIGNAL(newEstate(Estate *)), this, SLOT(newEstate(Estate *)));
+	connect(m_atlantikNetwork, SIGNAL(newTrade(Trade *)), this, SLOT(createGUI(Trade *)));
+	connect(m_atlantikNetwork, SIGNAL(newAuction(Auction *)), this, SLOT(newAuction(Auction *)));
+
+	if (m_selectServer)
+	{
+		connect(m_selectServer, SIGNAL(serverConnect(const QString, int)), m_atlantikNetwork, SLOT(serverConnect(const QString, int)));
+		connect(m_atlantikNetwork, SIGNAL(gameListClear()), this, SLOT(showSelectGame()));
+	}
 }
Index: client/atlantik.h
===================================================================
RCS file: /home/kde/kdegames/atlantik/client/atlantik.h,v
retrieving revision 1.45
diff -u -3 -d -p -r1.45 atlantik.h
--- client/atlantik.h	2002/07/16 00:35:16	1.45
+++ client/atlantik.h	2002/07/17 20:40:10
@@ -177,6 +177,8 @@ public slots:
 	void playerChanged();
 
 private:
+	void initNetworkObject();
+
 	QWidget *m_mainWidget, *m_portfolioWidget;
 	QGridLayout *m_mainLayout;
 	QVBoxLayout *m_portfolioLayout;


More information about the kde-core-devel mailing list