Skip to content

add some noexcept#51

Merged
wokron merged 5 commits into
masterfrom
add-noexcept
Feb 21, 2026
Merged

add some noexcept#51
wokron merged 5 commits into
masterfrom
add-noexcept

Conversation

@wokron
Copy link
Copy Markdown
Member

@wokron wokron commented Feb 18, 2026

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds noexcept specifiers to numerous functions across the runtime and ring classes, fundamentally changing the error handling strategy from exceptions to assertions. The changes affect core runtime operations, io_uring wrapper functions, and synchronization helpers.

Changes:

  • Added noexcept to ~30 functions in runtime.hpp, ring.hpp, and helper functions
  • Converted exception-throwing error handling to assertions in critical paths
  • Removed test case that verified exception behavior for deprecated fd_accepter feature
  • Removed try-catch block from sync_wait that handled runtime.run() exceptions

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
tests/test_fd_table.cpp Removed test case that verified std::logic_error throwing behavior for deprecated fd_accepter feature
include/condy/sync_wait.hpp Removed try-catch block around runtime.run() call, consistent with run() becoming noexcept
include/condy/runtime.hpp Added noexcept to run(), schedule(), and other runtime methods; replaced exceptions with assertions and fprintf
include/condy/ring.hpp Added noexcept to Ring, FdTable, BufferTable, and RingSettings methods; replaced throw with assertion in reap_completions_wait()
Comments suppressed due to low confidence (2)

include/condy/runtime.hpp:369

  • The process_cqe_ function is now marked noexcept, but it calls handle->handle_cqe(cqe) on line 368, which can indirectly call user-provided callbacks (e.g., in MultiShotMixin::func_ and ZeroCopyMixin::free_func_) that may throw exceptions. If any of these user callbacks throw an exception, std::terminate will be called. This is a breaking change in behavior and should be carefully considered, especially since the MultiShotMixin pattern allows arbitrary user code to be executed during CQE processing.
    void process_cqe_(io_uring_cqe *cqe) noexcept {
        auto *data_raw = io_uring_cqe_get_data(cqe);
        auto [data, type] = decode_work(data_raw);

        if (type == WorkType::Ignore) {
            // No-op
            assert(cqe->res != -EINVAL); // If EINVAL, something is wrong
        } else if (type == WorkType::SendFd) {
            auto &fd_table = ring_.fd_table();
            if (fd_table.fd_accepter_ == nullptr) [[unlikely]] {
                std::fprintf(stderr, "[Deprecated Warning] Received a file "
                                     "descriptor but no accepter is set.");
            }
            uint64_t payload = reinterpret_cast<uint64_t>(data) >> 3;
            if (payload == 0) { // Auto-allocate
                fd_table.fd_accepter_(cqe->res);
            } else {
                int target_fd = static_cast<int>(payload - 1);
                fd_table.fd_accepter_(target_fd);
            }
        } else if (type == WorkType::Schedule) {
            if (data == nullptr) {
                assert(cqe->res == 0);
                pending_works_--;
            } else {
                auto *work = static_cast<WorkInvoker *>(data);
                tsan_acquire(data);
                local_queue_.push_back(work);
            }
        } else if (type == WorkType::Common) {
            auto *handle = static_cast<OpFinishHandleBase *>(data);
            auto action = handle->handle_cqe(cqe);
            if (action.op_finish) {

include/condy/runtime.hpp:356

  • The warning message is printed when fd_accepter_ is nullptr, but then the code continues to call fd_accepter_ unconditionally on lines 352 and 355, which will cause a null pointer dereference. This check should either return early after printing the warning, or the subsequent calls to fd_accepter_ should be guarded with another nullptr check.
            if (fd_table.fd_accepter_ == nullptr) [[unlikely]] {
                std::fprintf(stderr, "[Deprecated Warning] Received a file "
                                     "descriptor but no accepter is set.");
            }
            uint64_t payload = reinterpret_cast<uint64_t>(data) >> 3;
            if (payload == 0) { // Auto-allocate
                fd_table.fd_accepter_(cqe->res);
            } else {
                int target_fd = static_cast<int>(payload - 1);
                fd_table.fd_accepter_(target_fd);
            }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread include/condy/runtime.hpp Outdated
Comment thread include/condy/runtime.hpp Outdated
@wokron wokron marked this pull request as ready for review February 21, 2026 01:53
@wokron wokron merged commit d88bfea into master Feb 21, 2026
11 checks passed
@wokron wokron deleted the add-noexcept branch February 21, 2026 01:53
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

Successfully merging this pull request may close these issues.

2 participants