Crow
Crow copied to clipboard
Segmentation Fault on load testing
Hi there! When I'm load testing a simple app with the locust
#define CROW_JSON_USE_MAP
#include "crow.h"
int main() {
crow::SimpleApp app;
CROW_ROUTE(app, "/test/<int>")
.name("test")
([](int count) {
crow::json::wvalue x({});
for (int i = 0; i < count; ++i) {
x["item" + std::to_string(i)] = i;
}
return x;
});
app.loglevel(crow::LogLevel::Critical);
app.port(8080)
.multithreaded()
.run();
}
I always get an segfault
There is a gdb backtrace:
#0 0x000000000043ffc4 in std::less<unsigned long>::operator() (this=0xfffff7b08010, __x=<error reading variable>, __y=@0xffffd7ffdbd0: 0) at /usr/include/c++/11/bits/stl_function.h:400
#1 0x00000000004388ac in std::_Rb_tree<unsigned long, std::pair<unsigned long const, std::pair<std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long, std::ratio<1l, 1000000000l> > >, std::function<void ()> > >, std::_Select1st<std::pair<unsigned long const, std::pair<std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long, std::ratio<1l, 1000000000l> > >, std::function<void ()> > > >, std::less<unsigned long>, std::allocator<std::pair<unsigned long const, std::pair<std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long, std::ratio<1l, 1000000000l> > >, std::function<void ()> > > > >::equal_range(unsigned long const&) (this=0xfffff7b08010, __k=@0xffffd7ffdbd0: 0)
at /usr/include/c++/11/bits/stl_tree.h:1973
#2 0x000000000043062c in std::_Rb_tree<unsigned long, std::pair<unsigned long const, std::pair<std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long, std::ratio<1l, 1000000000l> > >, std::function<void ()> > >, std::_Select1st<std::pair<unsigned long const, std::pair<std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long, std::ratio<1l, 1000000000l> > >, std::function<void ()> > > >, std::less<unsigned long>, std::allocator<std::pair<unsigned long const, std::pair<std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long, std::ratio<1l, 1000000000l> > >, std::function<void ()> > > > >::erase(unsigned long const&) (this=0xfffff7b08010, __x=@0xffffd7ffdbd0: 0)
at /usr/include/c++/11/bits/stl_tree.h:2510
#3 0x0000000000429718 in std::map<unsigned long, std::pair<std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long, std::ratio<1l, 1000000000l> > >, std::function<void ()> >, std::less<unsigned long>, std::allocator<std::pair<unsigned long const, std::pair<std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long, std::ratio<1l, 1000000000l> > >, std::function<void ()> > > > >::erase(unsigned long const&) (this=0xfffff7b08010, __x=@0xffffd7ffdbd0: 0) at /usr/include/c++/11/bits/stl_map.h:1069
#4 0x000000000041cc24 in crow::detail::task_timer::cancel (this=0xfffff7b07fb0, id=0) at /cxx/apiServer/dependencies/Crow/include/crow/task_timer.h:45
#5 0x000000000044b338 in crow::Connection<crow::SocketAdaptor, crow::Crow<>>::cancel_deadline_timer() (this=0xffffd0518ce0) at /cxx/apiServer/dependencies/Crow/include/crow/http_connection.h:587
#6 0x0000000000445320 in crow::Connection<crow::SocketAdaptor, crow::Crow<>>::~Connection() (this=0xffffd0518ce0, __in_chrg=<optimized out>)
at /cxx/apiServer/dependencies/Crow/include/crow/http_connection.h:68
#7 0x000000000043e1cc in crow::Server<crow::Crow<>, crow::SocketAdaptor>::do_accept()::{lambda(std::error_code)#1}::operator()(std::error_code) const (__closure=0xffffd7ffe390, ec=
std::error_code = {asio::detail::system_category: 24}) at /cxx/apiServer/dependencies/Crow/include/crow/http_server.h:242
#8 0x000000000046af74 in asio::detail::binder1<crow::Server<crow::Crow<>, crow::SocketAdaptor>::do_accept()::{lambda(std::error_code)#1}, std::error_code>::operator()() (this=0xffffd7ffe390)
at /usr/include/asio/detail/bind_handler.hpp:64
#9 0x000000000046a234 in asio::asio_handler_invoke<asio::detail::binder1<crow::Server<crow::Crow<>, crow::SocketAdaptor>::do_accept()::{lambda(std::error_code)#1}, std::error_code> >(asio::detail::binder1<crow::Server<crow::Crow<>, crow::SocketAdaptor>::do_accept()::{lambda(std::error_code)#1}, std::error_code>&, ...) (function=...) at /usr/include/asio/handler_invoke_hook.hpp:68
#10 0x0000000000468b24 in asio_handler_invoke_helpers::invoke<asio::detail::binder1<crow::Server<crow::Crow<>, crow::SocketAdaptor>::do_accept()::{lambda(std::error_code)#1}, std::error_code>, crow::Server<crow::Crow<>, crow::SocketAdaptor>::do_accept()::{lambda(std::error_code)#1}>(asio::detail::binder1<crow::Server<crow::Crow<>, crow::SocketAdaptor>::do_accept()::{lambda(std::error_code)#1}, std::error_code>&, crow::Server<crow::Crow<>, crow::SocketAdaptor>::do_accept()::{lambda(std::error_code)#1}&) (function=..., context=...) at /usr/include/asio/detail/handler_invoke_helpers.hpp:37
#11 0x0000000000466ef0 in asio::detail::asio_handler_invoke<asio::detail::binder1<crow::Server<crow::Crow<>, crow::SocketAdaptor>::do_accept()::{lambda(std::error_code)#1}, std::error_code>, crow::Server<crow::Crow<>, crow::SocketAdaptor>::do_accept()::{lambda(std::error_code)#1}, std::error_code>(asio::detail::binder1<crow::Server<crow::Crow<>, crow::SocketAdaptor>::do_accept()::{lambda(std::error_code)#1}, std::error_code>&, asio::detail::binder1<crow::Server<crow::Crow<>, crow::SocketAdaptor>::do_accept()::{lambda(std::error_code)#1}, std::error_code>*) (function=...,
this_handler=0xffffd7ffe390) at /usr/include/asio/detail/bind_handler.hpp:105
#12 0x00000000004653ac in asio_handler_invoke_helpers::invoke<asio::detail::binder1<crow::Server<crow::Crow<>, crow::SocketAdaptor>::do_accept()::{lambda(std::error_code)#1}, std::error_code>, asio::detail::binder1<crow::Server<crow::Crow<>, crow::SocketAdaptor>::do_accept()::{lambda(std::error_code)#1}, std::error_code> >(asio::detail::binder1<crow::Server<crow::Crow<>, crow::SocketAdaptor>::do_accept()::{lambda(std::error_code)#1}, std::error_code>&, asio::detail::binder1<crow::Server<crow::Crow<>, crow::SocketAdaptor>::do_accept()::{lambda(std::error_code)#1}, std::error_code>&) (
function=..., context=...) at /usr/include/asio/detail/handler_invoke_helpers.hpp:37
#13 0x00000000004637d0 in asio::detail::io_object_executor<asio::executor>::dispatch<asio::detail::binder1<crow::Server<crow::Crow<>, crow::SocketAdaptor>::do_accept()::{lambda(std::error_code)#1}, std::error_code>, std::allocator<void> >(asio::detail::binder1<crow::Server<crow::Crow<>, crow::SocketAdaptor>::do_accept()::{lambda(std::error_code)#1}, std::error_code>&&, std::allocator<void> const&) const (this=0xffffd7ffe3d0, f=..., a=...) at /usr/include/asio/detail/io_object_executor.hpp:118
#14 0x0000000000461370 in asio::detail::handler_work<crow::Server<crow::Crow<>, crow::SocketAdaptor>::do_accept()::{lambda(std::error_code)#1}, asio::detail::io_object_executor<asio::executor>, asio::detail::io_object_executor<asio::executor> >::complete<asio::detail::binder1<crow::Server<crow::Crow<>, crow::SocketAdaptor>::do_accept()::{lambda(std::error_code)#1}, std::error_code> >(asio::detail::binder1<crow::Server<crow::Crow<>, crow::SocketAdaptor>::do_accept()::{lambda(std::error_code)#1}, std::error_code>&, crow::Server<crow::Crow<>, crow::SocketAdaptor>::do_accept()::{lambda(std::error_code)#1}&) (this=0xffffd7ffe3c0, function=..., handler=...) at /usr/include/asio/detail/handler_work.hpp:71
#15 0x000000000045bd30 in asio::detail::reactive_socket_accept_op<asio::basic_socket<asio::ip::tcp, asio::executor>, asio::ip::tcp, crow::Server<crow::Crow<>, crow::SocketAdaptor>::do_accept()::{lambda(std::error_code)#1}, asio::detail::io_object_executor<asio::executor> >::do_complete(void*, asio::detail::scheduler_operation*, std::error_code const&, unsigned long) (owner=0x4d8fc0,
base=0xffffd04d8fb0) at /usr/include/asio/detail/reactive_socket_accept_op.hpp:139
#16 0x00000000004114e8 in asio::detail::scheduler_operation::complete (this=0xffffd04d8fb0, owner=0x4d8fc0, ec=std::error_code = { }, bytes_transferred=0)
at /usr/include/asio/detail/scheduler_operation.hpp:39
#17 0x00000000004156f0 in asio::detail::scheduler::do_run_one (this=0x4d8fc0, lock=..., this_thread=..., ec=std::error_code = { }) at /usr/include/asio/detail/impl/scheduler.ipp:446
#18 0x00000000004151a0 in asio::detail::scheduler::run (this=0x4d8fc0, ec=std::error_code = { }) at /usr/include/asio/detail/impl/scheduler.ipp:199
#19 0x0000000000415cbc in asio::io_context::run (this=0x4d8da0) at /usr/include/asio/impl/io_context.ipp:62
#20 0x0000000000435448 in crow::Server<crow::Crow<>, crow::SocketAdaptor>::run()::{lambda()#4}::operator()() const (__closure=0x4d44f8)
at /cxx/apiServer/dependencies/Crow/include/crow/http_server.h:158
--Type <RET> for more, q to quit, c to continue without paging--c
#21 0x0000000000470728 in std::__invoke_impl<void, crow::Server<crow::Crow<>, crow::SocketAdaptor>::run()::{lambda()#4}>(std::__invoke_other, crow::Server<crow::Crow<>, crow::SocketAdaptor>::run()::{lambda()#4}&&) (__f=...) at /usr/include/c++/11/bits/invoke.h:61
#22 0x00000000004700bc in std::__invoke<crow::Server<crow::Crow<>, crow::SocketAdaptor>::run()::{lambda()#4}>(crow::Server<crow::Crow<>, crow::SocketAdaptor>::run()::{lambda()#4}&&) (__fn=...) at /usr/include/c++/11/bits/invoke.h:96
#23 0x000000000046fb88 in std::thread::_Invoker<std::tuple<crow::Server<crow::Crow<>, crow::SocketAdaptor>::run()::{lambda()#4}> >::_M_invoke<0ul>(std::_Index_tuple<0ul>) (this=0x4d44f8) at /usr/include/c++/11/bits/std_thread.h:253
#24 0x000000000046efa4 in std::thread::_Invoker<std::tuple<crow::Server<crow::Crow<>, crow::SocketAdaptor>::run()::{lambda()#4}> >::operator()() (this=0x4d44f8) at /usr/include/c++/11/bits/std_thread.h:260
#25 0x000000000046dfc8 in std::thread::_State_impl<std::thread::_Invoker<std::tuple<crow::Server<crow::Crow<>, crow::SocketAdaptor>::run()::{lambda()#4}> > >::_M_run() (this=0x4d44f0) at /usr/include/c++/11/bits/std_thread.h:211
#26 0x0000fffff7e5bfcc in std::execute_native_thread_routine (__p=0x4d44f0) at ../../../../../libstdc++-v3/src/c++11/thread.cc:82
#27 0x0000fffff7b8ca08 in start_thread () from /lib64/libc.so.6
#28 0x0000fffff7b35b9c in thread_start () from /lib64/libc.so.6