From 7b8a2e77e459e1f1bb349814195bd022b0be7649 Mon Sep 17 00:00:00 2001 From: Johannes Schlatow Date: Thu, 4 Jul 2024 11:55:26 +0200 Subject: [PATCH] socket_fs: invalidate fd on context destruction This prevents accesses to `Socket_fs::Context::_fd_ready_ready()` that caused a "__cxa_pure_virtual called" error. Fixes #5265 --- repos/libports/src/lib/libc/socket_fs_plugin.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/repos/libports/src/lib/libc/socket_fs_plugin.cc b/repos/libports/src/lib/libc/socket_fs_plugin.cc index e9074d727f..f5b9b49ed7 100644 --- a/repos/libports/src/lib/libc/socket_fs_plugin.cc +++ b/repos/libports/src/lib/libc/socket_fs_plugin.cc @@ -236,7 +236,11 @@ struct Libc::Socket_fs::Context : Plugin_context ~Context() { - _fd_apply([] (int fd) { ::close(fd); }); + for (unsigned i = 0; i < Fd::MAX; ++i) { + ::close(_fd[i].num); + _fd[i].num = -1; + _fd[i].file = nullptr; + } ::close(_handle_fd); }