-
Notifications
You must be signed in to change notification settings - Fork 709
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
Crashed with std::runtime_error - bad file descriptor #1157
Comments
Hey @tronghung279. What is your |
Thank you @kiplingw for quick response.
|
Hmm, probably not file descriptor exhaustion then if only two service threads. |
Yes I think. I have no idea why it raises EBADF when accept the connection. :(. But should we handle the error instead of throwing? |
Come to think of it, EBADF I don't think is generated on file descriptor exhaustion. It sounds like one is being used in an invalid state (e.g. after it's already been closed). Are you using the binary package from the PPA? Can you show us your endpoint handler? |
Hi @kiplingw |
What distro are you running on the embedded system? |
Hi @kiplingw |
Hmm in that case you will have to build from source, as you did. My guess is you might be doing something else that's corrupting memory. |
Not yet figure out the reason but when I use thread |
I'm not an |
My application use Pistache::Http::Endpoint::serveThreaded and got crashed with message
terminate called after throwing an instance of 'std::runtime_error' what(): Bad file descriptor
I use 2 threads for pistache as the following
m_httpEndpoint = std::make_shared<Pistache::Http::Endpoint>(addr);
m_router = std::make_shared<Pistache::Rest::Router>();
m_router->addCustomHandler(Pistache::Rest::Routes::bind(&EventListenerServer::defaultRequestHandling, this));
auto opts = Pistache::Http::Endpoint::options().threads(2);
opts.flags(Pistache::Tcp::Options::ReuseAddr);
opts.maxPayload(32768);
m_httpEndpoint->init(opts);
Pistache::Rest::Routes::Post(*m_router, std::string("/" + m_path), Pistache::Rest::Routes::bind(&EventListenerServer::eventRequest, this));
m_httpEndpoint->setHandler(m_router->handler());
m_httpEndpoint->serveThreaded();
Coredump log
#0 0xa4adc3a0 in epoll_wait () from /home/docker/development/projects/coredump/libs/libc.so.6
#1 0xa3d65de4 in Pistache::Polling::Epoll::poll(std::vector<Pistache::Polling::Event, std::allocator<Pistache::Polling::Event> >&, std::chrono::duration<long long, std::ratio<1ll, 1000ll> >) const () from /home/docker/development/projects/coredump/libs/libpistache.so.0
#2 0xa3d82610 in Pistache::Tcp::Listener::run() () from /home/docker/development/projects/coredump/libs/libpistache.so.0
#3 0xa4c1a44c in execute_native_thread_routine () from /home/docker/development/projects/coredump/libs/libstdc++.so.6
#4 0xa52a6d94 in ?? () from /home/docker/development/projects/coredump/libs/libpthread.so.0
#5 0xa4adbf68 in ?? () from /home/docker/development/projects/coredump/libs/libc.so.6
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
Take a look into
Pistache::Tcp::Listener::run
I see it throws a ServerError when handling EBADF, which then print the same crash message.Is it possible to not throw the exception? Or could you guide me how to catch and handle it effectively? I see it breaks the whole run loop on exception but I don't want it.
Thank you
The text was updated successfully, but these errors were encountered: