Skip to content

Static Analysis#546

Merged
sean-parent merged 14 commits intomainfrom
sparent/coverity1
May 22, 2024
Merged

Static Analysis#546
sean-parent merged 14 commits intomainfrom
sparent/coverity1

Conversation

@sean-parent
Copy link
Member

@sean-parent sean-parent commented May 10, 2024

This PR was started to address an issue reported by Covarity regarding the exception handling in the future reduction code. It led to a rewrite of the future reduction code, the inclusion of clang-tidy and clang-tidy fixes in the CMake setup, and several other changes:

API Changes

  • package() will now reduce futures (future<future> -> future). All APIs that return futures now reduce the future.
  • await() and await_for() take the future by rvalue-ref. They now take it by rvalue-ref with deprecated overloads for const-ref for compatibility. I'm moving away from implicit copies. Use stlab::copy() or std::move() as appropriate to upgrade to the new interface.
  • Clang-tidy was run across the interfaces and made several changes, including adding [[nodiscard]] to many interfaces. In general, these should catch misuse.
  • Added get_ready() API to future that can be used in a recover() clause or when the future is known to be ready. It asserts the future is ready and would be a race to invoke on a non-ready future.

Fixes

  • task(const task&&) is now deleted, which avoids a bad recursive runtime error if you attempt to copy a task.
  • When using future<> with C++20 coroutines, exceptions are now correctly reported.
  • The mutable size property in forest is now atomic. A const forest can be safely shared across threads.

Improvements

  • future reduction was completely rewritten and is considerably more efficient with 1 (instead of 3) heap allocations and 2 (instead of 3) synchronization points.
  • Added cmake presents and a .clang-tidy file (with support for fixes). The code is clean for the default clang-tidy analyzers, all the cert-*, performance-*, and modernize*- checks for C++17.

sean-parent and others added 12 commits April 11, 2024 17:44
Transfering work in progress on handling broken promise exceptions between machines.
Added system_timer for libdispatch to pre-exit group.
Cleaned up tests.
Cleaned up futures with efficient reduction.
Changed the await() and await_for interface to take an rvalue references. Use `move()` or `copy()` when calling with an lvalue. (This change generated a lot of test changes!).

Fixes to future coroutine support to correctly report exceptions.

Check box items should be in a subsequent PR
[] Support waiting for multiple futures directly.
Fixed up remaining clang-tidy issues.
Added (back) await and await_for with implicit copy as deprecated APIs.
@dabrahams
Copy link
Contributor

Just reading the summary it seems like a lot of changes that could've been separate PR's, for example, a clang tidy pass seems like a different topic from fixing the bug.

Unfortunately, it doesn't work in .hpp files :-(
@sean-parent
Copy link
Member Author

Just reading the summary it seems like a lot of changes that could've been separate PR's, for example, a clang tidy pass seems like a different topic from fixing the bug.

Yes - it should have been about 5 PRs. It started with "could clang-tidy find the same issue as Coverity" (answer, not that I've been able to determine) - and snowballed.

@nickpdemarco
Copy link
Member

FYI I ran clang-tidy locally over these changes and it seems to work. The presets are nice. Haven't had time yet to review the changes themselves, though.

@sean-parent
Copy link
Member Author

Going to take the heat for pushing my own oversized PR...

@sean-parent sean-parent merged commit c21ea83 into main May 22, 2024
@sean-parent sean-parent deleted the sparent/coverity1 branch May 22, 2024 23:21
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.

3 participants