Skip to content

Conversation

DerGuteMoritz
Copy link
Collaborator

Also, make test-alt a bit more reliable and make the exception messages distinct so that a dropped error can easily be matched up with the deferred.

Based on #243

Manifold has a debug mechanism which instruments deferreds so that a warning is logged when they are
in an error state with no error handler attached at garbage collection time. Such errors are
referred to as "dropped errors" and the instrumented deferreds are called "leak-aware".

The dropped error logging feature is enabled by default but for performance reasons, only every
1024th deferred is made leak-aware (see `manifold.deferred/deferred`). However, deferreds
constructed via `manifold.deferred/error-deferred` are always leak-aware.

This patch introduces a new option `manifold.debug/*leak-aware-deferred-rate*` which allows changing
the rate of leak-aware deferreds being instantiated, with default still being 1024. When this option
is set to to 1 (= every deferred will be leak-aware), dropped errors can be detected more reliably
e.g. during testing.

To that end, the patch also includes a test util for instrumenting all tests in a namespace so that
they fail when a dropped error was detected. All test namespaces are now instrumented like
this (except for `:benchmark` and `:stress` tests), which already uncovered a few latent dropped
errors. These will be fixed in separate patches.
Also, make test-alt a bit more reliable and make the exception messages distinct so that a dropped
error can easily be matched up with the deferred.
@DerGuteMoritz
Copy link
Collaborator Author

Damn, looks like I can't change this PR's base branch to #243 because it doesn't live in the same repository 😢 @KingMob if you don't mind, you could give me write access to this repo here, then I should be able to create properly stacked PRs 🙏

@DerGuteMoritz
Copy link
Collaborator Author

Alternatively, I could push all follow-up patches to #243, as well (3-4 more). Whichever you prefer!

@KingMob
Copy link
Collaborator

KingMob commented Sep 19, 2025

OK @DerGuteMoritz you should be an admin now

@DerGuteMoritz
Copy link
Collaborator Author

Thanks, that worked! 🙏 Closing this one since GH doesn't allow changing a PR's source branch 🤷

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