twsapi icon indicating copy to clipboard operation
twsapi copied to clipboard

Fix: assertion failed: tws-api/cpp/suppl/EPosixClientSocket.cpp:412:virtual int EPosixClientSocket::receive(char*, size_t): sz > 0

Open jankratochvil opened this issue 6 years ago • 0 comments

(gdb) bt
%0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
%1  0x00007ffff6131895 in __GI_abort () at abort.c:79
%2  0x000000000136a43d in fatal (fmt=0x1503d48 "ib __assert_fail: %s:%d:%s: %s") at lib/log.C:29
%3  0x0000000001072a11 in IBSTOCK__assert_fail (assertion=0x1503cf9 "sz > 0", file=0x1503bb0 "tws-api/cpp/suppl/EPosixClientSocket.cpp", line=412, function=0x1506760 <EPosixClientSocket::receive(char*, unsigned long)::__PRETTY_FUNCTION__> "virtual int EPosixClientSocket::receive(char*, size_t)") at iblib.C:44
%4  0x00000000010715a8 in EPosixClientSocket::receive (this=0x2e3a5f0, buf=0x2e626a0 "", sz=0) at tws-api/cpp/suppl/EPosixClientSocket.cpp:412
%5  0x000000000106cace in EReaderST::onReceive (this=0x2e3adb8) at tws-api/cpp/suppl/EReaderST.cpp:132
%6  0x0000000000secret in secret (this=0x2e3a5f0) at secret.C:secret
...
(gdb) frame 5
132             int nRes = m_pClientSocket->receive(m_buf->begin + m_buf->offset, sz );
(gdb) p m_buf->size
$8 = 106496
(gdb) p m_buf->offset
$9 = 106496

That is because I read data as long as they are available (POLLIN) and only then I start processing them.

The last chunk with newsize is unrelated a bit and not so important, it is just the optimal size of m_buf which is IMO what the code tried to do.

jankratochvil avatar May 23 '19 09:05 jankratochvil