Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only initialize libgit2's atexit once #54254

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sjkelly
Copy link
Contributor

@sjkelly sjkelly commented Apr 25, 2024

The current implementation registers multiple atexit
handlers because the git_libgit2_init ccall returns
the number of inits that have happened. So,
every time we run ensure_initialized (which is frequent),
we register a new, unnecessary handler.

The current implementation registers multiple `atexit`
handlers because the `git_libgit2_init` `ccall` returns
the number of inits that have happened. So,
every time we run `ensure_initialized` (which is frequent),
we register a new, unnecessary handler.
@inkydragon inkydragon added libgit2 The libgit2 library or the LibGit2 stdlib module stdlib Julia's standard library labels Apr 25, 2024
@topolarity
Copy link
Member

Hmm, how is it possible to hit this?

I would have expected that we don't hit REFCOUNT == 0 again until after the first registered atexit() handler has run and all LibGit2 objects have finalized, so that there are never multiple inits to worry about

@sjkelly
Copy link
Contributor Author

sjkelly commented Apr 26, 2024

Right, I was not entirely clear in my comment that this is mostly due to static analysis tools being unable to reason about this. "Simplify" should have been the operational word.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libgit2 The libgit2 library or the LibGit2 stdlib module stdlib Julia's standard library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants