Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segfault when restarting the server #2210

Open
dkalinowski opened this issue Nov 22, 2024 · 2 comments
Open

Segfault when restarting the server #2210

dkalinowski opened this issue Nov 22, 2024 · 2 comments

Comments

@dkalinowski
Copy link

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
@dkalinowski
Copy link
Author

Any hints? Is it not supported?

@an-tao
Copy link
Member

an-tao commented Nov 30, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants