uNetworking / uWebSockets

Simple, secure & standards compliant web server for the most demanding of applications
Apache License 2.0
17.32k stars 1.75k forks source link

Random crashes #1751

Closed koen1711 closed 4 months ago

koen1711 commented 4 months ago

I've had multiple instances where with no pattern uWebSockets crashes internally, at an instruction in pthread_kill.c, with errors such as:

terminate called after throwing an instance of 'std::length_error'
  what():  basic_string::_M_replace_aux

What could be the issue? It shows the crash to be at:

call   0x7ffff78ec040 <getpid>  
    mov    %r12d,%edx               
    mov    %ebp,%esi                
    mov    %eax,%edi                
    mov    $0xea,%eax               
    syscall                         
    mov    %eax,%r13d // here               
    neg    %r13d                    
    cmp    $0xfffff000,%eax         
    mov    $0x0,%eax                
    cmovbe %eax,%r13d  
uNetworkingAB commented 4 months ago

You need to use AddressSanitizer to find your issue

koen1711 commented 4 months ago

You need to use AddressSanitizer to find your issue

Hmmm, the AdressSanitizer seems to give back that there is a buffer overflow within uWebSockets.

==78640==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x626000002924 at pc 0x646be1662885 bp 0x7ffd6541a2c0 sp 0x7ffd6541a2b0
READ of size 1 at 0x626000002924 thread T0
    #0 0x646be1662884 in uWS::TemplatedApp<false>::ws<PerSocketData>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, uWS::TemplatedApp<false>::WebSocketBehavior<PerSocketData>&&)::{lambda(uWS::Subscriber*, uWS::TopicTreeMessage&, uWS::TopicTree<uWS::TopicTreeMessage, uWS::TopicTreeBigMessage>::IteratorFlags)#1}::operator()(uWS::Subscriber*, uWS::TopicTreeMessage&, uWS::TopicTree<uWS::TopicTreeMessage, uWS::TopicTreeBigMessage>::IteratorFlags) /usr/local/include/uWebSockets/App.h:317
uNetworkingAB commented 4 months ago

You have cut the output, don't cut it.

koen1711 commented 4 months ago
=================================================================
==78640==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x626000002924 at pc 0x646be1662885 bp 0x7ffd6541a2c0 sp 0x7ffd6541a2b0
READ of size 1 at 0x626000002924 thread T0
    #0 0x646be1662884 in uWS::TemplatedApp<false>::ws<PerSocketData>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, uWS::TemplatedApp<false>::WebSocketBehavior<PerSocketData>&&)::{lambda(uWS::Subscriber*, uWS::TopicTreeMessage&, uWS::TopicTree<uWS::TopicTreeMessage, uWS::TopicTreeBigMessage>::IteratorFlags)#1}::operator()(uWS::Subscriber*, uWS::TopicTreeMessage&, uWS::TopicTree<uWS::TopicTreeMessage, uWS::TopicTreeBigMessage>::IteratorFlags) /usr/local/include/uWebSockets/App.h:317
    #1 0x646be1662884 in bool std::__invoke_impl<bool, uWS::TemplatedApp<false>::ws<PerSocketData>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, uWS::TemplatedApp<false>::WebSocketBehavior<PerSocketData>&&)::{lambda(uWS::Subscriber*, uWS::TopicTreeMessage&, uWS::TopicTree<uWS::TopicTreeMessage, uWS::TopicTreeBigMessage>::IteratorFlags)#1}&, uWS::Subscriber*, uWS::TopicTreeMessage&, uWS::TopicTree<uWS::TopicTreeMessage, uWS::TopicTreeBigMessage>::IteratorFlags>(std::__invoke_other, uWS::TemplatedApp<false>::ws<PerSocketData>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, uWS::TemplatedApp<false>::WebSocketBehavior<PerSocketData>&&)::{lambda(uWS::Subscriber*, uWS::TopicTreeMessage&, uWS::TopicTree<uWS::TopicTreeMessage, uWS::TopicTreeBigMessage>::IteratorFlags)#1}&, uWS::Subscriber*&&, uWS::TopicTreeMessage&, uWS::TopicTree<uWS::TopicTreeMessage, uWS::TopicTreeBigMessage>::IteratorFlags&&) /usr/include/c++/11/bits/invoke.h:61
    #2 0x646be1662884 in std::enable_if<is_invocable_r_v<bool, uWS::TemplatedApp<false>::ws<PerSocketData>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, uWS::TemplatedApp<false>::WebSocketBehavior<PerSocketData>&&)::{lambda(uWS::Subscriber*, uWS::TopicTreeMessage&, uWS::TopicTree<uWS::TopicTreeMessage, uWS::TopicTreeBigMessage>::IteratorFlags)#1}&, uWS::Subscriber*, uWS::TopicTreeMessage&, uWS::TopicTree<uWS::TopicTreeMessage, uWS::TopicTreeBigMessage>::IteratorFlags>, bool>::type std::__invoke_r<bool, uWS::TemplatedApp<false>::ws<PerSocketData>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, uWS::TemplatedApp<false>::WebSocketBehavior<PerSocketData>&&)::{lambda(uWS::Subscriber*, uWS::TopicTreeMessage&, uWS::TopicTree<uWS::TopicTreeMessage, uWS::TopicTreeBigMessage>::IteratorFlags)#1}&, uWS::Subscriber*, uWS::TopicTreeMessage&, uWS::TopicTree<uWS::TopicTreeMessage, uWS::TopicTreeBigMessage>::IteratorFlags>(uWS::TemplatedApp<false>::ws<PerSocketData>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, uWS::TemplatedApp<false>::WebSocketBehavior<PerSocketData>&&)::{lambda(uWS::Subscriber*, uWS::TopicTreeMessage&, uWS::TopicTree<uWS::TopicTreeMessage, uWS::TopicTreeBigMessage>::IteratorFlags)#1}&, uWS::Subscriber*&&, uWS::TopicTreeMessage&, uWS::TopicTree<uWS::TopicTreeMessage, uWS::TopicTreeBigMessage>::IteratorFlags&&) /usr/include/c++/11/bits/invoke.h:114
    #3 0x646be1662884 in std::_Function_handler<bool (uWS::Subscriber*, uWS::TopicTreeMessage&, uWS::TopicTree<uWS::TopicTreeMessage, uWS::TopicTreeBigMessage>::IteratorFlags), uWS::TemplatedApp<false>::ws<PerSocketData>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, uWS::TemplatedApp<false>::WebSocketBehavior<PerSocketData>&&)::{lambda(uWS::Subscriber*, uWS::TopicTreeMessage&, uWS::TopicTree<uWS::TopicTreeMessage, uWS::TopicTreeBigMessage>::IteratorFlags)#1}>::_M_invoke(std::_Any_data const&, uWS::Subscriber*&&, uWS::TopicTreeMessage&, uWS::TopicTree<uWS::TopicTreeMessage, uWS::TopicTreeBigMessage>::IteratorFlags&&) /usr/include/c++/11/bits/std_function.h:290
    #4 0x646be164eccc in std::function<bool (uWS::Subscriber*, uWS::TopicTreeMessage&, uWS::TopicTree<uWS::TopicTreeMessage, uWS::TopicTreeBigMessage>::IteratorFlags)>::operator()(uWS::Subscriber*, uWS::TopicTreeMessage&, uWS::TopicTree<uWS::TopicTreeMessage, uWS::TopicTreeBigMessage>::IteratorFlags) const /usr/include/c++/11/bits/std_function.h:590
    #5 0x646be164eccc in uWS::TopicTree<uWS::TopicTreeMessage, uWS::TopicTreeBigMessage>::drainImpl(uWS::Subscriber*) /usr/local/include/uWebSockets/TopicTree.h:126
    #6 0x646be164eccc in uWS::TopicTree<uWS::TopicTreeMessage, uWS::TopicTreeBigMessage>::drain() /usr/local/include/uWebSockets/TopicTree.h:274
    #7 0x646be164eccc in uWS::TemplatedApp<false>::ws<PerSocketData>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, uWS::TemplatedApp<false>::WebSocketBehavior<PerSocketData>&&)::{lambda(uWS::Loop*)#2}::operator()(uWS::Loop*) const /usr/local/include/uWebSockets/App.h:342
    #8 0x646be164eccc in void std::__invoke_impl<void, uWS::TemplatedApp<false>::ws<PerSocketData>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, uWS::TemplatedApp<false>::WebSocketBehavior<PerSocketData>&&)::{lambda(uWS::Loop*)#2}&, uWS::Loop*>(std::__invoke_other, uWS::TemplatedApp<false>::ws<PerSocketData>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, uWS::TemplatedApp<false>::WebSocketBehavior<PerSocketData>&&)::{lambda(uWS::Loop*)#2}&, uWS::Loop*&&) /usr/include/c++/11/bits/invoke.h:61
    #9 0x646be164eccc in std::__invoke_result<uWS::TemplatedApp<false>::ws<PerSocketData>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, uWS::TemplatedApp<false>::WebSocketBehavior<PerSocketData>&&)::{lambda(uWS::Loop*)#2}&, uWS::Loop*>::type std::__invoke<uWS::TemplatedApp<false>::ws<PerSocketData>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, uWS::TemplatedApp<false>::WebSocketBehavior<PerSocketData>&&)::{lambda(uWS::Loop*)#2}&, uWS::Loop*>(uWS::TemplatedApp<false>::ws<PerSocketData>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, uWS::TemplatedApp<false>::WebSocketBehavior<PerSocketData>&&)::{lambda(uWS::Loop*)#2}&, uWS::Loop*&&) /usr/include/c++/11/bits/invoke.h:96
    #10 0x646be164eccc in std::invoke_result<uWS::TemplatedApp<false>::ws<PerSocketData>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, uWS::TemplatedApp<false>::WebSocketBehavior<PerSocketData>&&)::{lambda(uWS::Loop*)#2}&, uWS::Loop*>::type std::invoke<uWS::TemplatedApp<false>::ws<PerSocketData>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, uWS::TemplatedApp<false>::WebSocketBehavior<PerSocketData>&&)::{lambda(uWS::Loop*)#2}&, uWS::Loop*>(uWS::TemplatedApp<false>::ws<PerSocketData>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, uWS::TemplatedApp<false>::WebSocketBehavior<PerSocketData>&&)::{lambda(uWS::Loop*)#2}&, uWS::Loop*&&) /usr/include/c++/11/functional:97
    #11 0x646be164eccc in ofats::any_detail::handler_traits<void, uWS::Loop*>::small_handler<uWS::TemplatedApp<false>::ws<PerSocketData>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, uWS::TemplatedApp<false>::WebSocketBehavior<PerSocketData>&&)::{lambda(uWS::Loop*)#2}>::call(ofats::any_detail::storage&, uWS::Loop*) /usr/local/include/uWebSockets/MoveOnlyFunction.h:133
    #12 0x646be164d279 in ofats::any_detail::any_invocable_impl<void, false, uWS::Loop*>::call(uWS::Loop*) /usr/local/include/uWebSockets/MoveOnlyFunction.h:247
    #13 0x646be164d279 in ofats::any_invocable<void (uWS::Loop*)>::operator()(uWS::Loop*) /usr/local/include/uWebSockets/MoveOnlyFunction.h:354
    #14 0x646be164d279 in uWS::Loop::postCb(us_loop_t*) /usr/local/include/uWebSockets/Loop.h:58
    #15 0x646be16b2de8 in uv__run_check (/media/koen/PortableSSD/GitHub/6School/AudioRecorder/cmake-build-debug/AudioRecorder+0x262de8)
    #16 0x646be16b08f3 in uv_run (/media/koen/PortableSSD/GitHub/6School/AudioRecorder/cmake-build-debug/AudioRecorder+0x2608f3)
    #17 0x646be1646afc in uWS::Loop::run() /usr/local/include/uWebSockets/Loop.h:182
    #18 0x646be1646afc in uWS::run() /usr/local/include/uWebSockets/Loop.h:199
    #19 0x646be1646afc in uWS::TemplatedApp<false>::run() /usr/local/include/uWebSockets/App.h:591
    #20 0x646be1646afc in Dashboard::startServer() /media/koen/PortableSSD/GitHub/6School/AudioRecorder/src/dashboard/dashboard.cpp:310
    #21 0x646be147ffc3 in main /media/koen/PortableSSD/GitHub/6School/AudioRecorder/src/main.cpp:12
    #22 0x776f4de29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #23 0x776f4de29e3f in __libc_start_main_impl ../csu/libc-start.c:392
    #24 0x646be147feb4 in _start (/media/koen/PortableSSD/GitHub/6School/AudioRecorder/cmake-build-debug/AudioRecorder+0x2feb4)

0x626000002924 is located 36 bytes to the right of 10240-byte region [0x626000000100,0x626000002900)
freed by thread T1 here:
    #0 0x776f4e6b724f in operator delete(void*, unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cpp:172
    #1 0x646be15bb0e4 in __gnu_cxx::new_allocator<uWS::TopicTreeMessage>::deallocate(uWS::TopicTreeMessage*, unsigned long) /usr/include/c++/11/ext/new_allocator.h:145
    #2 0x646be15bb0e4 in std::allocator_traits<std::allocator<uWS::TopicTreeMessage> >::deallocate(std::allocator<uWS::TopicTreeMessage>&, uWS::TopicTreeMessage*, unsigned long) /usr/include/c++/11/bits/alloc_traits.h:496
    #3 0x646be15bb0e4 in std::_Vector_base<uWS::TopicTreeMessage, std::allocator<uWS::TopicTreeMessage> >::_M_deallocate(uWS::TopicTreeMessage*, unsigned long) /usr/include/c++/11/bits/stl_vector.h:354
    #4 0x646be15bb0e4 in void std::vector<uWS::TopicTreeMessage, std::allocator<uWS::TopicTreeMessage> >::_M_realloc_insert<uWS::TopicTreeMessage&>(__gnu_cxx::__normal_iterator<uWS::TopicTreeMessage*, std::vector<uWS::TopicTreeMessage, std::allocator<uWS::TopicTreeMessage> > >, uWS::TopicTreeMessage&) /usr/include/c++/11/bits/vector.tcc:500
    #5 0x646be15bc3ea in uWS::TopicTree<uWS::TopicTreeMessage, uWS::TopicTreeBigMessage>::publish(uWS::Subscriber*, std::basic_string_view<char, std::char_traits<char> >, uWS::TopicTreeMessage&&) (/media/koen/PortableSSD/GitHub/6School/AudioRecorder/cmake-build-debug/AudioRecorder+0x16c3ea)
    #6 0x646be15bce07 in uWS::TemplatedApp<false>::publish(std::basic_string_view<char, std::char_traits<char> >, std::basic_string_view<char, std::char_traits<char> >, uWS::OpCode, bool) (/media/koen/PortableSSD/GitHub/6School/AudioRecorder/cmake-build-debug/AudioRecorder+0x16ce07)
    #7 0x646be1598580 in data_callback(ma_device*, void*, void const*, unsigned int) /media/koen/PortableSSD/GitHub/6School/AudioRecorder/src/recording/audio/audioRecorder.cpp:127
    #8 0x646be150a52e in ma_device__on_data_inner /media/koen/PortableSSD/GitHub/6School/AudioRecorder/include/miniaudio.h:18692
    #9 0x646be151d9c7 in ma_device__on_data /media/koen/PortableSSD/GitHub/6School/AudioRecorder/include/miniaudio.h:18738
    #10 0x646be151e102 in ma_device__handle_data_callback /media/koen/PortableSSD/GitHub/6School/AudioRecorder/include/miniaudio.h:18825
    #11 0x646be151e9b7 in ma_device__send_frames_to_client /media/koen/PortableSSD/GitHub/6School/AudioRecorder/include/miniaudio.h:18984
    #12 0x646be15213bb in ma_device_handle_backend_data_callback /media/koen/PortableSSD/GitHub/6School/AudioRecorder/include/miniaudio.h:42525
    #13 0x646be1522b76 in ma_device_on_read__pulse /media/koen/PortableSSD/GitHub/6School/AudioRecorder/include/miniaudio.h:30097
    #14 0x776f4f080250  (/lib/x86_64-linux-gnu/libpulse.so.0+0x14250)

previously allocated by thread T1 here:
    #0 0x776f4e6b61e7 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cpp:99
    #1 0x646be15ba8a8 in __gnu_cxx::new_allocator<uWS::TopicTreeMessage>::allocate(unsigned long, void const*) /usr/include/c++/11/ext/new_allocator.h:127
    #2 0x646be15ba8a8 in std::allocator_traits<std::allocator<uWS::TopicTreeMessage> >::allocate(std::allocator<uWS::TopicTreeMessage>&, unsigned long) /usr/include/c++/11/bits/alloc_traits.h:464
    #3 0x646be15ba8a8 in std::_Vector_base<uWS::TopicTreeMessage, std::allocator<uWS::TopicTreeMessage> >::_M_allocate(unsigned long) /usr/include/c++/11/bits/stl_vector.h:346
    #4 0x646be15ba8a8 in void std::vector<uWS::TopicTreeMessage, std::allocator<uWS::TopicTreeMessage> >::_M_realloc_insert<uWS::TopicTreeMessage&>(__gnu_cxx::__normal_iterator<uWS::TopicTreeMessage*, std::vector<uWS::TopicTreeMessage, std::allocator<uWS::TopicTreeMessage> > >, uWS::TopicTreeMessage&) /usr/include/c++/11/bits/vector.tcc:440
    #5 0x646be15bc3ea in uWS::TopicTree<uWS::TopicTreeMessage, uWS::TopicTreeBigMessage>::publish(uWS::Subscriber*, std::basic_string_view<char, std::char_traits<char> >, uWS::TopicTreeMessage&&) (/media/koen/PortableSSD/GitHub/6School/AudioRecorder/cmake-build-debug/AudioRecorder+0x16c3ea)
    #6 0x646be15bce07 in uWS::TemplatedApp<false>::publish(std::basic_string_view<char, std::char_traits<char> >, std::basic_string_view<char, std::char_traits<char> >, uWS::OpCode, bool) (/media/koen/PortableSSD/GitHub/6School/AudioRecorder/cmake-build-debug/AudioRecorder+0x16ce07)
    #7 0x646be1598580 in data_callback(ma_device*, void*, void const*, unsigned int) /media/koen/PortableSSD/GitHub/6School/AudioRecorder/src/recording/audio/audioRecorder.cpp:127
    #8 0x646be150a52e in ma_device__on_data_inner /media/koen/PortableSSD/GitHub/6School/AudioRecorder/include/miniaudio.h:18692
    #9 0x646be151d9c7 in ma_device__on_data /media/koen/PortableSSD/GitHub/6School/AudioRecorder/include/miniaudio.h:18738
    #10 0x646be151e102 in ma_device__handle_data_callback /media/koen/PortableSSD/GitHub/6School/AudioRecorder/include/miniaudio.h:18825
    #11 0x646be151e9b7 in ma_device__send_frames_to_client /media/koen/PortableSSD/GitHub/6School/AudioRecorder/include/miniaudio.h:18984
    #12 0x646be15213bb in ma_device_handle_backend_data_callback /media/koen/PortableSSD/GitHub/6School/AudioRecorder/include/miniaudio.h:42525
    #13 0x646be1522b76 in ma_device_on_read__pulse /media/koen/PortableSSD/GitHub/6School/AudioRecorder/include/miniaudio.h:30097
    #14 0x776f4f080250  (/lib/x86_64-linux-gnu/libpulse.so.0+0x14250)

Thread T1 created by T0 here:
    #0 0x776f4e658685 in __interceptor_pthread_create ../../../../src/libsanitizer/asan/asan_interceptors.cpp:216
    #1 0x646be14f5ed4 in ma_thread_create__posix /media/koen/PortableSSD/GitHub/6School/AudioRecorder/include/miniaudio.h:16169
    #2 0x646be14f5ed4 in ma_thread_create /media/koen/PortableSSD/GitHub/6School/AudioRecorder/include/miniaudio.h:16544
    #3 0x646be1529899 in ma_device_init /media/koen/PortableSSD/GitHub/6School/AudioRecorder/include/miniaudio.h:41970
    #4 0x646be1529cc5 in ma_device_init_ex /media/koen/PortableSSD/GitHub/6School/AudioRecorder/include/miniaudio.h:42125
    #5 0x646be15274c6 in ma_device_init /media/koen/PortableSSD/GitHub/6School/AudioRecorder/include/miniaudio.h:41653
    #6 0x646be1597621 in AudioRecorder::init() /media/koen/PortableSSD/GitHub/6School/AudioRecorder/src/recording/audio/audioRecorder.cpp:157
    #7 0x646be1649e3d in operator()<uWS::WebSocket<false, true, PerSocketData> > /media/koen/PortableSSD/GitHub/6School/AudioRecorder/src/dashboard/dashboard.cpp:204
    #8 0x646be164c78f in __invoke_impl<void, Dashboard::startServer()::<lambda(auto:20*, std::string_view, uWS::OpCode)>&, uWS::WebSocket<false, true, PerSocketData>*, std::basic_string_view<char, std::char_traits<char> >, uWS::OpCode> /usr/include/c++/11/bits/invoke.h:61
    #9 0x646be164c78f in __invoke<Dashboard::startServer()::<lambda(auto:20*, std::string_view, uWS::OpCode)>&, uWS::WebSocket<false, true, PerSocketData>*, std::basic_string_view<char, std::char_traits<char> >, uWS::OpCode> /usr/include/c++/11/bits/invoke.h:96
    #10 0x646be164c78f in invoke<Dashboard::startServer()::<lambda(auto:20*, std::string_view, uWS::OpCode)>&, uWS::WebSocket<false, true, PerSocketData>*, std::basic_string_view<char, std::char_traits<char> >, uWS::OpCode> /usr/include/c++/11/functional:97
    #11 0x646be164c78f in call /usr/local/include/uWebSockets/MoveOnlyFunction.h:133
    #12 0x646be167541a in ofats::any_detail::any_invocable_impl<void, false, uWS::WebSocket<false, true, PerSocketData>*, std::basic_string_view<char, std::char_traits<char> >, uWS::OpCode>::call(uWS::WebSocket<false, true, PerSocketData>*, std::basic_string_view<char, std::char_traits<char> >, uWS::OpCode) /usr/local/include/uWebSockets/MoveOnlyFunction.h:247
    #13 0x646be167541a in ofats::any_invocable<void (uWS::WebSocket<false, true, PerSocketData>*, std::basic_string_view<char, std::char_traits<char> >, uWS::OpCode)>::operator()(uWS::WebSocket<false, true, PerSocketData>*, std::basic_string_view<char, std::char_traits<char> >, uWS::OpCode) /usr/local/include/uWebSockets/MoveOnlyFunction.h:354
    #14 0x646be167541a in uWS::WebSocketContext<false, true, PerSocketData>::handleFragment(char*, unsigned long, unsigned int, int, bool, uWS::WebSocketState<true>*, void*) /usr/local/include/uWebSockets/WebSocketContext.h:100
    #15 0x646be167794a in bool uWS::WebSocketProtocol<true, uWS::WebSocketContext<false, true, PerSocketData> >::consumeMessage<6u, unsigned char>(unsigned char, char*&, unsigned int&, uWS::WebSocketState<true>*, void*) /usr/local/include/uWebSockets/WebSocketProtocol.h:363
    #16 0x646be167b74c in uWS::WebSocketProtocol<true, uWS::WebSocketContext<false, true, PerSocketData> >::consume(char*, unsigned int, uWS::WebSocketState<true>*, void*) /usr/local/include/uWebSockets/WebSocketProtocol.h:476
    #17 0x646be167ba92 in auto uWS::WebSocketContext<false, true, PerSocketData>::init()::{lambda(auto:1*, char*, int)#2}::operator()<us_socket_t>(us_socket_t*, char*, int) const /usr/local/include/uWebSockets/WebSocketContext.h:306
    #18 0x646be167ba92 in decltype (((*(({lambda(auto:1*, char*, int)#2} const* const)0)).(operator()<us_socket_t>))(static_cast<us_socket_t*&&>({parm#1}), static_cast<char*&&>({parm#2}), static_cast<int&&>({parm#3}))) uWS::WebSocketContext<false, true, PerSocketData>::init()::{lambda(auto:1*, char*, int)#2}::_FUN<us_socket_t>(us_socket_t*, char*, int) /usr/local/include/uWebSockets/WebSocketContext.h:284
    #19 0x646be16ab037 in poll_cb ../../../../../../../home/koen/Documents/uWebSockets/uSockets/src/loop.c:358

SUMMARY: AddressSanitizer: heap-buffer-overflow /usr/local/include/uWebSockets/App.h:317 in uWS::TemplatedApp<false>::ws<PerSocketData>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, uWS::TemplatedApp<false>::WebSocketBehavior<PerSocketData>&&)::{lambda(uWS::Subscriber*, uWS::TopicTreeMessage&, uWS::TopicTree<uWS::TopicTreeMessage, uWS::TopicTreeBigMessage>::IteratorFlags)#1}::operator()(uWS::Subscriber*, uWS::TopicTreeMessage&, uWS::TopicTree<uWS::TopicTreeMessage, uWS::TopicTreeBigMessage>::IteratorFlags)
Shadow bytes around the buggy address:
  0x0c4c7fff84d0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c4c7fff84e0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c4c7fff84f0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c4c7fff8500: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c4c7fff8510: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
=>0x0c4c7fff8520: fa fa fa fa[fa]fa fa fa fa fa fa fa fa fa fa fa
  0x0c4c7fff8530: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c4c7fff8540: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c4c7fff8550: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c4c7fff8560: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c4c7fff8570: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==78640==ABORTING
koen1711 commented 4 months ago

I'm sorry, here is the full output

uNetworkingAB commented 4 months ago

You are using threading too promiscuously. It's a single threaded lib

koen1711 commented 4 months ago

You are using threading too promiscuously. It's a single threaded lib

Is there a way to work around this problem? The only thing interacting with uWS in the other thread is this line of code:

nlohmann::json j = recorder->queryInformation();
pGlobalApp->publish("recorder-info", j.dump(), uWS::OpCode::TEXT);}
uNetworkingAB commented 4 months ago

It's not al dente but you can wrap that call in Loop->defer(lambda) to make it work.

koen1711 commented 4 months ago

It's not al dente but you can wrap that call in Loop->defer(lambda) to make it work.

Thank you so much! Everything seems to be working great no problem!