-
-
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
obmalloc radix tree typo in code #89684
Comments
There is a typo in the radix tree obmalloc code, spotted by Inada Naoki. -#define MAP_TOP_MASK (MAP_BOT_LENGTH - 1) This should be fixed both in the main branch and in 3.10.x. |
When I am trying to understand this issue, I see this segfault. https://gist.github.com/methane/1b83e2abc6739017e0490c5f70a27b52 I am not sure this segfault is caused by this issue or not. If this is unrelated, I will create another issue. |
I have not yet been able to reproduce methane's crash. My guess it it's not related. An explanation of what I think the impact of this bug is: The radix tree is used to determine if memory is from obmalloc or from the system malloc (i.e return value from address_in_range()). WIth ADDRESS_BITS set to 48, we ignore the top 16 bits of addresses. The next 10 bits are supposed to be the index into the top level node array for the radix tree. Due to the bug, we mask those and only use the bottom 8 of those 10. So, if you have virtual addresses that span more than that 8 bit range, we will index into the wrong node. That means address_in_range() could give the wrong answer. Which means you might try to free memory with the wrong malloc. I think this is likely to be triggered only if you allocate a massive amount of memory, like 70 TB. However, triggering it would depend on how the kernel maps virtual memory to the Python process. I.e. there might be a wierd OS that gives pages at 0x7f0000000000 and then right after pages at 0x3f0000000000. |
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: