Add clarifying code comments to ScopeGuard / ON_BLOCK_EXIT()

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Fixed
    • Priority: Trivial - P5
    • 8.2.0-rc0, 8.1.0-rc2
    • Affects Version/s: None
    • Component/s: None
    • None
    • Server Programmability
    • Fully Compatible
    • Programmability 2025-03-31, Programmability 2025-04-14
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      Users of the ON_BLOCK_EXIT macro may not be aware that the callback function they are passing to it runs in a noexcept context, and that any exception escaping from it will terminate the process.
      While it is clear when writing a destructor that it is implicitly noexcept and that exceptions should be handled, it is less clear when writing code using the ON_BLOCK_EXIT macro. SERVER-100707 is a real world issue that led to a server crash because an exception escaped an ON_BLOCK_EXIT callback function. There may be more such issues.

      We could improve on this by adding code comments to both the ScopeGuard class and the ON_BLOCK_EXIT macro, stating that the callback function will run in a noexcept context and that callers are responsible for handling exceptions in their callback function, and failure to do so will result in process termination.

            Assignee:
            Billy Donahue
            Reporter:
            Jan Steemann
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: