Boost logo

Boost :

Subject: Re: [boost] Is the async_read more reliable than async_read_some?
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2018-12-09 02:08:12


AMDG

On 12/08/2018 06:50 PM, hh h wrote:
>> How does it crash? There's no fundamental reason
>> why prepending your own header with the size
>> wouldn't work.
>
> I sent 4 bytes header and 221 bytes messages repeatedly (every 2
> seconds) calling from async_write of a sender, the receiver works
> correctly and perfectly at async_read for a couple minutes, then it
> crashed in the statement of readMessageBody for 221 bytes message at
> async_read(socket_, boost::asio::buffer(buffer, size), ....), where
> the size = 221n I don't think it is related to my program, either some
> bugs in async_read or libssl. Here is my debug:
>
>
> Read body size = 221
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x00007ffff69d4c01 in __GI___libc_free (mem=0x5555557f7770) at malloc.c:3123
> 3123 malloc.c: No such file or directory.
>
> (gdb) backtrace
> #0 0x00007ffff69d4c01 in __GI___libc_free (mem=0x5555557f7770)
> at malloc.c:3123
> #1 0x00007ffff796a8fc in ?? () from /usr/lib/x86_64-linux-gnu/libssl.so.1.1
> #2 0x00007ffff796a139 in ?? () from /usr/lib/x86_64-linux-gnu/libssl.so.1.1
> #3 0x00007ffff796f9aa in ?? () from /usr/lib/x86_64-linux-gnu/libssl.so.1.1
> #4 0x00007ffff79797d5 in SSL_read ()
> from /usr/lib/x86_64-linux-gnu/libssl.so.1.1
> #5 0x00005555555665b1 in boost::asio::ssl::detail::engine::do_read (
> this=0x5555557d0fe0, data=0x5555557f7765, length=221)
> at /usr/include/boost/asio/ssl/detail/impl/engine.ipp:309
>
> ........
>
> (gdb) print (char *)mem
> $2 = 0x5555557f7770 "n\226"
>

This looks like some kind of memory corruption,
possibly a double free. Have you tried valgrind
or addrsan?

In Christ,
Steven Watanabe


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk