tplgy / bonefish

C++ WAMP application router that enables building applications from loosely-coupled components.
Apache License 2.0
55 stars 33 forks source link

Segfault on unexpected subscriber disconnect #43

Open alex3d opened 7 years ago

alex3d commented 7 years ago

Bonefish dies with SEGFAULT when unexpected client disconnect detected in wamp_broker::process_publish_message. The problem is that topic_subscriptions_itr invalidated after disconnected session detach.

How to reproduce: 1) Connect client A to bonefish and subscribe to topic T 2) Connect client B to bonefish and start publishing T periodically 3) Kill client A (without clean WAMP disconnect procedure)

Logs:

[wamp_broker.cpp:112][process_publish_message] session-id 2257228500326156
[wamp_broker.cpp:113][process_publish_message] session [2257228500326156,realm1,open], publish [7457382369929906, {}, com.myapp.hello, ["Hello, world!"], nil]
[wamp_broker.cpp:148][process_publish_message] Subscription 1 of 2
[wamp_broker.cpp:150][process_publish_message] session [2257228500326156,realm1,open], event [3, 6749176572856079, {}, ["Hello, world!"], nil]
[websocket_transport.cpp:39][send_message] sending message: event
[wamp_broker.cpp:148][process_publish_message] Subscription 2 of 2
[wamp_broker.cpp:150][process_publish_message] session [7090515283965860,realm1,open], event [2, 6749176572856079, {}, ["Hello, world!"], nil]
[rawsocket_transport.cpp:39][send_message] sending message: event
[rawsocket_connection.hpp:306][handle_system_error] connection failed: system:32
[wamp_dealer.cpp:82][detach_session] detach session: session [7090515283965860,realm1,open]
[wamp_dealer.cpp:87][detach_session] cleaning up session registrations
[wamp_dealer.cpp:116][detach_session] cleaning up pending caller invocations
[wamp_dealer.cpp:136][detach_session] cleaning up pending callee invocations
[wamp_broker.cpp:66][detach_session] detach session-id: 7090515283965860
[wamp_broker.cpp:67][detach_session] detach session: 0x88d310
[wamp_broker.cpp:70][detach_session] cleaning up session subscriptions
[wamp_broker.cpp:79][detach_session] cleaning up subscription topic
[wamp_broker.cpp:91][detach_session] cleaning up topic subscriptions
[wamp_broker.cpp:79][detach_session] cleaning up subscription topic
[wamp_broker.cpp:91][detach_session] cleaning up topic subscriptions
[wamp_broker.cpp:148][process_publish_message] Subscription 3 of 2 (WTF?)
[wamp_broker.cpp:150][process_publish_message] Segmentation fault