drogon
drogon copied to clipboard
Segfault when restarting the server
Describe the bug
There is segfault when the server is closed using ::quit() and then restarted using ::run().
GDB:
[New Thread 0x7fffda5d7640 (LWP 210860)]
[New Thread 0x7fffd9dd6640 (LWP 210861)]
[New Thread 0x7fffd95d5640 (LWP 210862)]
[New Thread 0x7fffd8dd4640 (LWP 210863)]
[Thread 0x7fffda5d7640 (LWP 210860) exited]
[Thread 0x7fffd8dd4640 (LWP 210863) exited]
[Thread 0x7fffd95d5640 (LWP 210862) exited]
[New Thread 0x7fffda5d7640 (LWP 210881)]
[Thread 0x7fffd9dd6640 (LWP 210861) exited]
Thread 1 "ovms_test" received signal SIGSEGV, Segmentation fault.
0x0000555556b23cf7 in drogon::ListenerManager::addListener(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned short, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, std::vector<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > const&) ()
(gdb)
To Reproduce
#include <drogon/drogon.h>
#include <thread>
#include <chrono>
...
for (int i = 0; i < 2; i++) {
std::thread k([] {
std::this_thread::sleep_for(std::chrono::seconds(2));
drogon::app().quit();
});
drogon::app()
.setThreadNum(3)
.setIdleConnectionTimeout(0)
.addListener("0.0.0.0", 11933)
.run();
k.join();
}
Expected behavior No segfault, server restarts
Desktop (please complete the following information):
- OS: ubuntu22
Any hints? Is it not supported?
This is not a common way to use Drogon. In fact, Drogon's design does not take into account the scenario of calling the run function again after it exits.
It is valid use case for our library users to use C-API to stop and re-start the server with different parameters within the same process. I understand Drogon is not designed to support that (probably this is why HttpAppFramework instance is a singleton) - but is there any chance that Drogon team add support for that? The http server we migrate from (Tensorflow's net_http module) does support that.
Thank you