-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
Set GC_DEBUG for debug builds of the interpreter #82618
Comments
While working on bpo-38379 I had to manually set the GC_DEBUG macro to 1 to activate the extra checks that 'validate_list' does. These checks are super useful to make sure all the gc lists used are consistent and in the expected state with the expected masks. For this reason, I propose to always activate GC_DEBUG for debug builds of the interpreter. It will have a performance impact, but the debugging benefits are substantial. |
Under which condition can such list be corrupted? |
If someone is adding/modifiying the gc and calls any of the functions that set the gc flags like (PREV_MASK_COLLECTING). One example is that after calling move_unreachable(), the unreachable set has NEXT_MASK_UNREACHABLE and therefore is an invalid list (until move_legacy_finalizers removes the flag and makes it valid again). If you mess the order or violate any of the contract, the lists will be invalid. It helps a lot to know that you are not leaving the lists in invalid state by mistake or on the other hand, to check that they are valid when they are supposed to be valid. |
+1. This code got quite brittle when they decided to fit two pointers, a fat integer, and 3 flags into a struct with room for only the two pointers ;-) It's a mine field now. Enabling one of the few automated mine detectors is thoroughly sensible. |
Thanks Victor and Tim! |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: