-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Posix remote_address() may throw, but it is marked noexcept #2379
Comments
But the class name suggests that the socket is connected, while kernel thinks otherwise. Can you shed more light on this -- how did you end up having unconnected socket wrapped with connected_socket_impl object? |
This happened when I used an external tcpkill process to rapidly terminate connections, for testing purposes. What is supposed to happen to a |
Ah, I see. In that case this can be a nice unit test too -- a local listening posix socket, a local established connection, then server-side closes and client-side tries to call
It won't transform into some other class, that's for sure. No I understand where the issue could be. |
Can you show me your full test? The ENOTCON is returned for SYN_SENT and CLOSE states. The latter doesn't happen until client closes its side, and if it does it's no longer valid to call remote_address() on connected_socket(). So I assume we're in SYN_SENT state, but don't see how it happens until connected_socket is instantiated. |
hi Pavel, Here is an (ugly) reproducer (no attempts to cleanly shutdown services, just a fairly minimal reproducer to trigger the bug): I first run, in another terminal, tcpkill, and leave it running:
Then I run the following program: (I compiled my test in dev mode) #include "stop_signal.hh"
#include <seastar/core/abort_source.hh>
#include <seastar/core/app-template.hh>
#include <seastar/core/future.hh>
#include <seastar/core/sleep.hh>
#include <seastar/core/thread.hh>
#include <seastar/core/when_all.hh>
#include <seastar/util/log.hh>
static seastar::logger mylog("main");
using namespace seastar;
using namespace std::chrono_literals;
abort_source as;
future<> client()
{
ipv4_addr addr(8000);
connected_socket s = co_await connect(addr);
auto out = s.output();
auto in = s.input();
std::string hello{"hello"};
co_await out.write(hello);
co_await out.flush();
auto payload = co_await in.read();
}
future<> server()
{
connected_socket srv_sock;
listen_options opts;
opts.reuse_address = true;
opts.set_fixed_cpu(0);
server_socket socket = listen(make_ipv4_address(8000), opts);
accept_result ar = co_await socket.accept();
srv_sock = std::move(ar.connection);
auto in = srv_sock.input();
auto out = srv_sock.output();
while (!as.abort_requested()) {
if (as.abort_requested()) {
break;
}
uint16_t acc{};
for (int i = 0; i < 10000; ++i) {
auto ra = srv_sock.remote_address();
acc += ra.port();
}
mylog.info("port sum: {}", acc);
}
}
int main(int argc, char** argv)
{
app_template app;
return app.run(argc, argv, [] {
return seastar::async([] {
seastar_apps_lib::stop_signal s;
auto server_fut = server();
auto client_fut = client();
s.wait().get();
});
});
} When the program is run, tcpkill has output like this:
The seastar program then crashes with:
|
@xemul Is this helpful? |
Polite "ping" @xemul . See reproducer above. |
I ran into the following error:
Partial backtrace:
I believe the cause is
posix_connected_socket_impl::remote_address()
is marked noexcept, but it callsposix_connected_socket_operations::remote_address()
, which is not noexcept, and in fact the latter callsfile_desc::get_remote_address()
which explicitly throws.See:
https://github.com/scylladb/seastar/blob/master/src/net/posix-stack.cc#L288
https://github.com/scylladb/seastar/blob/master/src/net/posix-stack.cc#L110
https://github.com/scylladb/seastar/blob/master/include/seastar/core/posix.hh#L298
The text was updated successfully, but these errors were encountered: