drogonframework / drogonframework/drogon

Segfault when restarting the server

Open
#2,210 3 comments 2 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
14.3k
Forks
1.4k
Avg merge
1d 13h
Merged PRs (30d)
14

Description

**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, std::allocator > const&, unsigned short, bool, std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&, bool, std::vector, std::allocator >, std::__cxx11::basic_string, std::allocator > >, std::allocator, std::allocator >, std::__cxx11::basic_string, std::allocator > > > > const&) ()
(gdb)
```

**To Reproduce**
```
#include

#include
#include

...

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.