Skip to content

Conversation

@rostan-t
Copy link

@rostan-t rostan-t commented Jan 22, 2025

This fixes the crash by moving _PyTraceMalloc_Fini() after _PyImport_Fini(). I'm not sure if it breaks some invariant that I'm not aware of or even if it's the best solution, happy to take feedbacks!

@ghost
Copy link

ghost commented Jan 22, 2025

The following commit authors need to sign the Contributor License Agreement:

Click the button to sign:
CLA not signed

@bedevere-app
Copy link

bedevere-app bot commented Jan 22, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

Copy link
Member

@ZeroIntensity ZeroIntensity left a comment

Choose a reason for hiding this comment

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

Could you add a test?

@vstinner
Copy link
Member

I wrote a different fix with a test: PR gh-129191.

@rostan-t
Copy link
Author

Thanks @vstinner! Closing this one

@rostan-t rostan-t closed this Jan 22, 2025

/* Disable tracemalloc after all Python objects have been destroyed,
so it is possible to use tracemalloc in objects destructor. */
_PyTraceMalloc_Fini();
Copy link
Member

Choose a reason for hiding this comment

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

I don't think that this fix is enough. Some objects can be deleted later, in finalize_interp_clear(). So I wrote a different fix to restore the old behavior: PR gh-129191.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants