From bbd2e675a5c1f1aaadebc53b7fbb4541bcafe1cb Mon Sep 17 00:00:00 2001 From: Galas' Sergey Date: Thu, 12 Dec 2024 07:05:56 +0000 Subject: [PATCH] file: unexpected throw from inside noexcept make_file_impl is marked noexcept but append_challenged_posix_file_impl constructor can throw and it does. std::terminate occurs. let's catch, then wrap into exceptional future. --- src/core/file.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/core/file.cc b/src/core/file.cc index e83d84fad6..cf53b8d9fc 100644 --- a/src/core/file.cc +++ b/src/core/file.cc @@ -1115,11 +1115,15 @@ make_file_impl(int fd, file_open_options options, int flags, struct stat st) noe }); } - const internal::fs_info& fsi = i->second; - if (!fsi.append_challenged || options.append_is_unlikely || ((flags & O_ACCMODE) == O_RDONLY)) { - return make_ready_future>(make_shared(fd, open_flags(flags), std::move(options), fsi, st_dev)); + try { + const internal::fs_info& fsi = i->second; + if (!fsi.append_challenged || options.append_is_unlikely || ((flags & O_ACCMODE) == O_RDONLY)) { + return make_ready_future>(make_shared(fd, open_flags(flags), std::move(options), fsi, st_dev)); + } + return make_ready_future>(make_shared(fd, open_flags(flags), std::move(options), fsi, st_dev)); + } catch(...) { + return current_exception_as_future>(); } - return make_ready_future>(make_shared(fd, open_flags(flags), std::move(options), fsi, st_dev)); } file::file(seastar::file_handle&& handle) noexcept