yappari icon indicating copy to clipboard operation
yappari copied to clipboard

Segmentation fault sometimes when lost connection

Open nerdknight opened this issue 10 years ago • 4 comments

This happens once in a while, usally when the phone disconnects form wifi , 3g, or connect to other network, it's a bit dificult to reproduce. Here is the log:

There was an IO error: Connection closed by server. 
Connection closed. 
Stopping timers. 
Freeing up the connection. 
Freeing up the socket. 
Yappari will retry the connection in 10 seconds. 
Segmentation fault

nerdknight avatar Feb 05 '15 20:02 nerdknight

Hi!

Is there any news on this? Latest patches you and cepiperez sent solved this issue or is it still standing?

agamez avatar Apr 16 '15 09:04 agamez

It's not anymore a segfault per se, but Yappari still crashes here, with an "invalid length" message:

INCOMING:
<chatstate>
   from=***@s.whatsapp.net
<composing>

INCOMING:
<message>
   from=***@s.whatsapp.net
   id=1429144049-138
   notify=***
   t=1429151616
   type=text
<body>
   Ehehehe

parseMessageInitialTagAlreadyChecked
OUTGOING:
<receipt>
   id=1429144049-138
   to=***@s.whatsapp.net

logMessage():  
There was an IO error: Connection closed by server.
Connection closed.
Stopping timers.
Freeing up the connection.
Freeing up the socket.
Yappari will retry the connection in 10 seconds.
Invalid length 0x14
Yappari 2.0.10 Build 5210
Yappari console debug start
Reading roster DB...
Roster retrieved in 555 milliseconds.
Resetting timestamps at 1429151933006
Next run in 1266994
Reading open chats DB...
Open Chats retrieved in 5 milliseconds.
Entry retrieved: ***@s.whatsapp.net
Entry retrieved: ***@s.whatsapp.net

nunks avatar Apr 16 '15 19:04 nunks

Works a little better but still crashes some times with segfault:

#0  0x414f03d2 in QIODevice::isOpen() const () from /usr/lib/libQtCore.so.4
#1  0x414e3336 in QBuffer::setBuffer(QByteArray*) ()
   from /usr/lib/libQtCore.so.4
#2  0x0005ed34 in BinTreeNodeReader::getOneToplevelStream (this=0xce2a88)
    at Whatsapp/bintreenodereader.cpp:60
#3  0x0005ed9c in BinTreeNodeReader::nextTree (this=0xce2a88, node=...)
    at Whatsapp/bintreenodereader.cpp:103
#4  0x0004eb64 in Connection::read (this=0xee6578)
    at Whatsapp/connection.cpp:124
#5  0x00063dcc in Client::read (this=0x3fe3b0) at client.cpp:1132
#6  0x001423ac in Client::qt_metacall (this=0x3fe3b0, 
    _c=QMetaObject::InvokeMetaMethod, _id=12, _a=0xbeac3fa0)
    at moc_client.cpp:198
#7  0x41533770 in QMetaObject::metacall(QObject*, QMetaObject::Call, int, void**) () from /usr/lib/libQtCore.so.4
#8  0x4153dcca in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) () from /usr/lib/libQtCore.so.4
---Type <return> to continue, or q <return> to quit---
#9  0x4136c418 in ?? () from /usr/lib/libQtNetwork.so.4
#10 0x413611ca in ?? () from /usr/lib/libQtNetwork.so.4
#11 0x4136183a in ?? () from /usr/lib/libQtNetwork.so.4
#12 0x40d88c3c in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
   from /usr/lib/libQtGui.so.4
#13 0x40d8bafa in QApplication::notify(QObject*, QEvent*) ()
   from /usr/lib/libQtGui.so.4
#14 0x40adad28 in ?? () from /lib/libglib-2.0.so.0
#15 0x40adad28 in ?? () from /lib/libglib-2.0.so.0

nerdknight avatar Apr 17 '15 23:04 nerdknight

I'm still not sure how SEGFAULT can happen while using a QByteArray member, but lets assume it's not correctly initialized.

Could you please try replacing the BinTreeNodeReader constructor with the following code? It simply initializes both QByteArray to the empty (not null) string. It works for me but I've never experiencied any segfault, so I need you test this for me. Thanks!

BinTreeNodeReader::BinTreeNodeReader(QTcpSocket *socket, WATokenDictionary *dictionary, QObject *parent) : QObject(parent) { this->dict = dictionary; this->socket = socket;

decodedBuffer = "";
rawBuffer = "";

}

agamez avatar Apr 18 '15 09:04 agamez