-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
Crash in insertdict #66843
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
Comments
I got a weird crash in an interpreter session. Here is what I did: $ ./python
Python 3.5.0a0 (default:fd658692db3a+, Oct 15 2014, 23:13:43)
[GCC 4.8.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> f = open('toto', 'ab')
>>> f.write(b'bb')
2
>>> f.flush()
>>>
>>> f = open('toto', 'ab')
__main__:1: ResourceWarning: unclosed file <_io.BufferedWriter name='toto'>
python: Objects/dictobject.c:855: insertdict: Assertion `ep->me_key != ((void *)0) && ep->me_key != (&_dummy_struct)' failed.
Abandon (core dumped) Here are the inner frames of the traceback: (gdb) bt Here are the hash initialization values: (gdb) p _Py_HashSecret The crash seems difficult to reproduce simply by typing the lines above. Perhaps by forcing the hash initialization values as above. |
Ok, here is how to reproduce deterministically:
Python 3.5.0a0 (default:030fda7b1de8+, Oct 16 2014, 14:27:32)
[GCC 4.8.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> >>> >>> >>> __main__:1: ResourceWarning: unclosed file <_io.BufferedWriter name='x'>
python: Objects/dictobject.c:855: insertdict: Assertion `ep->me_key != ((void *)0) && ep->me_key != (&_dummy_struct)' failed.
Abandon |
Looking down into the insertdict frame: (gdb) p key So this seems to have hit the following line in insertdict(): if (old_value != NULL) {
assert(ep->me_key != NULL && ep->me_key != dummy);
*value_addr = value;
---> Py_DECREF(old_value); /* which **CAN** re-enter */
} And it *has* reentered because the ResourceWarning inserted the __warningregistry__ attribute into the __main__ dict. Note the reentrancy looks safe: the dict should be in a stable state at this point (?). But the assert at the end of insertdict assumes the dict hasn't mutated... Why? |
So after moving away that specific assert, there doesn't seem to be any problem (I ran the whole test suite in the same interpreter). If it's really a case of the assert being too strict, then the issue isn't very severe, as most people would you a non-debug build. |
The assertion on line 855 I don't know why the assertion is at the end of the function rather than earlier, but hg blame says its my code :( I'll put a patch together this weekend, once I've had time to reproduce the failure. |
Here is a patch, with a test that fails deterministically without the fix. |
Le 16/10/2014 15:43, Mark Shannon a écrit :
Sorry, I was already writing mine when you said that :-) |
Crash when running test_reentrant_insertion is reproducible also in 3.3 branch, but not in 3.2 branch. |
But 3.3 only receives security fixes, and this is not a security issue. It's up to Georg whether we really wants to backport the fix. |
This is not a crash, but an abort, so it's not a security issue. |
New changeset 9ec84f9b61c6 by Antoine Pitrou in branch '3.4': New changeset 4ff865976bb9 by Antoine Pitrou in branch 'default': |
Ok, then I've committed the patch to 3.4 and 3.5. |
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: