sourcey / libsourcey

C++14 evented IO libraries for high performance networking and media based applications
https://sourcey.com/libsourcey
GNU Lesser General Public License v2.1
1.32k stars 349 forks source link

http example "httpechoserverd" crashes under stress test from wrk benchmark. #114

Closed traw closed 7 years ago

traw commented 7 years ago

Example command: ./httpechoserverd Test Command: wrk -t12 -c400 -d30s http://127.0.0.1:1337/index.html Stack Strace:

`#0 0x00007ffff66d0428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54

1 0x00007ffff66d202a in __GI_abort () at abort.c:89

2 0x00007ffff66c8bd7 in __assert_fail_base (fmt=, assertion=assertion@entry=0x5d8213 "_parser.data != this",

file=file@entry=0x5d81d8 "/mnt/repos/cctv/sourcey/libsourcey/src/http/src/parser.cpp", line=line@entry=68, 
function=function@entry=0x5d8360 <scy::http::Parser::init(http_parser_type)::__PRETTY_FUNCTION__> "void scy::http::Parser::init(http_parser_type)") at assert.c:92

3 0x00007ffff66c8c82 in __GI___assert_fail (assertion=0x5d8213 "_parser.data != this", file=0x5d81d8 "/mnt/repos/cctv/sourcey/libsourcey/src/http/src/parser.cpp",

line=68, function=0x5d8360 <scy::http::Parser::init(http_parser_type)::__PRETTY_FUNCTION__> "void scy::http::Parser::init(http_parser_type)") at assert.c:101

4 0x0000000000573188 in scy::http::Parser::init (this=0x875ea8, type=HTTP_REQUEST) at /mnt/repos/cctv/sourcey/libsourcey/src/http/src/parser.cpp:68

5 0x0000000000572f09 in scy::http::Parser::Parser (this=0x875ea8, type=HTTP_REQUEST) at /mnt/repos/cctv/sourcey/libsourcey/src/http/src/parser.cpp:53

6 0x000000000056d05c in scy::http::ConnectionAdapter::ConnectionAdapter (this=0x875d40, connection=..., type=HTTP_REQUEST)

at /mnt/repos/cctv/sourcey/libsourcey/src/http/src/connection.cpp:265

7 0x000000000055ac80 in scy::http::ServerAdapter::ServerAdapter (this=0x875d40, connection=...)

at /mnt/repos/cctv/sourcey/libsourcey/src/http/include/scy/http/server.h:77

8 0x000000000055c701 in scy::http::ServerConnection::ServerConnection (this=0x549a9eb0, server=..., socket=std::shared_ptr (count 8724656, weak -1) 0x7fffffffa6e0)

at /mnt/repos/cctv/sourcey/libsourcey/src/http/src/server.cpp:164

9 0x000000000055ba4b in scy::http::Server::createConnection (this=0x7fffffffdc20, sock=std::shared_ptr (count 4, weak 0) 0x853920)

at /mnt/repos/cctv/sourcey/libsourcey/src/http/src/server.cpp:88

10 0x000000000055c0e1 in scy::http::Server::onSocketAccept (this=0x7fffffffdc20, sock=std::shared_ptr (count 4, weak 0) 0x853860)

at /mnt/repos/cctv/sourcey/libsourcey/src/http/src/server.cpp:129

11 0x00000000005694eb in scy::ClassDelegate<scy::http::Server, void, std::shared_ptr const&>::operator() (this=0x855450,

args#0=std::shared_ptr (count 4, weak 0) 0x853860) at /mnt/repos/cctv/sourcey/libsourcey/src/base/include/scy/delegate.h:80

12 0x00000000005b5dfc in scy::Signal<void (std::shared_ptr const&)>::emit(std::shared_ptr const&) (this=0x8522c8,

args#0=std::shared_ptr (count 4, weak 0) 0x853860) at /mnt/repos/cctv/sourcey/libsourcey/src/base/include/scy/signal.h:209

13 0x00000000005b4a71 in scy::net::TCPSocket::acceptConnection (this=0x8520b0) at /mnt/repos/cctv/sourcey/libsourcey/src/net/src/tcpsocket.cpp:183

14 0x00000000005b5518 in scy::net::TCPSocket::onAcceptConnection (this=0x8520b0, status=0) at /mnt/repos/cctv/sourcey/libsourcey/src/net/src/tcpsocket.cpp:309

15 0x00000000005b3860 in scy::net::internal::onAcceptConnection (handle=0x852330, status=0) at /mnt/repos/cctv/sourcey/libsourcey/src/net/src/tcpsocket.cpp:58

16 0x000000000059262d in uv__server_io (loop=0x81eca0 , w=0x8523b8, events=1)

at /mnt/repos/cctv/sourcey/libsourcey/vendor/libuv/src/unix/stream.c:551

17 0x0000000000599bd9 in uv__io_poll (loop=0x81eca0 , timeout=2400) at /mnt/repos/cctv/sourcey/libsourcey/vendor/libuv/src/unix/linux-core.c:365

18 0x00000000005852eb in uv_run (loop=0x81eca0 , mode=UV_RUN_DEFAULT) at /mnt/repos/cctv/sourcey/libsourcey/vendor/libuv/src/unix/core.c:351

19 0x000000000052efa1 in scy::uv::waitForShutdown(std::function<void (void)>, void, uv_loop_s*) (callback=..., opaque=0x7fffffffdc20,

loop=0x81eca0 <default_loop_struct>) at /mnt/repos/cctv/sourcey/libsourcey/src/uv/include/scy/uv/uvpp.h:227

20 0x0000000000531936 in main (argc=1, argv=0x7fffffffddb8) at /mnt/repos/cctv/sourcey/libsourcey/src/http/samples/httpechoserver/httpechoserver.cpp:29

`

auscaster commented 7 years ago

Hi, thanks for the bug report - I'll try to reproduce the issue on my end.

traw commented 7 years ago

You can reproduce it with command I have given.

traw commented 7 years ago

I have coredump but can't attach it here

traw commented 7 years ago

If we remove assert at 68th line in parser.cpp. Then we can resolve it. But don't know the purpose of assert there.

auscaster commented 7 years ago

I've just updated the core, please let me know if it fixes your issue.

I'm actually working on adding support for SO_REUSEPORT for multicore socket load balancing at the kernel level on linux >= 3.9 which will speed up benchmarks considerably.

auscaster commented 7 years ago

The assertion was there in error ... since the parser instance wasn't initialised yet the data value was undefined causing unpredictable results