-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
Logically merge cell and locals array. They are already contiguous in memory #87859
Comments
In the interpreter and compiler, the "fast" locals array and cells array are treated separately. By merging them in the compiler, the interpreter can be simplified a bit. |
This doesn't look simpler to me. We will forever lose mental clock cycles disentangling the locals and cells. So, I don't think they should be commingled. |
To me it looks simpler though. The locals and cells are already stored in a single array, f_localsplus (which also contains the evaluation stack). There are various complications in ceval.c to translate cell indexes to indexes in this array (ein particular the extra local variable 'freevars', which weighs down the stack frame). Making the interpreter simpler by moving things to the compiler also makes it easier for the C compiler to optimize the code of the interpreter better. |
LGTM. |
Unfortunately, commit 2c1e258 has broken all the refleak buildbots. Example failure: BISECTION: c1e2583fdc4db6b43d163239ea42b0e8394171f is the first bad commit
https://buildbot.python.org/all/#/builders/384/builds/50/steps/5/logs/stdio As this is affecting all test, I am proceeding with a revert of commit 2c1e258 directly to not mask other issues. |
Please, in the future, check with the buildbots before merging these kinds of big PRs. |
PR reverts commits 2c1e258 and b2bf2bc. Please, commit them back once the refleaks are resolved. I took a quick look and seems that there are several issues but there are more I could find. Some of the issues seem to be related to commit 2c1e258 calling _PyCode_GetVarnames and _PyCode_GetFreevars without decrementing the reference after use but there are more. |
Thanks Pablo. I'll get this sorted out. Sorry for the pain. |
Hi, Unfortunately, the address sanitizer buildbot has been broken by commit631f9938b1604d4f893417ec339b9e0fa9196fb1 : |
Here is the top trace: test_jump_in_nested_finally_3 (test.test_sys_settrace.JumpTestCase) ... ok |
Eric, I saw thay you ran the buildbots on your PR (thanks a lot), but something has gone wrong in some of them and they didn't run correctly. For example: https://buildbot.python.org/all/#/builders/581/builds/58 I'm investigating why that this. Meanwhile, could you take a look? We have already some problems on windows and we don't want more stuff to pile up. |
The problem seems to be that The problem is that PyFrame_LocalsToFast(frame, 1); calls into PyFrame_LocalsToFast where co->co_nlocals has a value of 3, and this causes co->co_cell2arg[i - co->co_nlocals]; to access outside the bounds of the array. As this change is affecting all tests (there are many tests in the test suite that fail with a buffer overflow in the ASAN builds) I opened PR 26597 to revert commit commit631f9938b1604d4f893417ec339b9e0fa9196fb1. As always, please, recommit commit631f9938b1604d4f893417ec339b9e0fa9196fb1 once this issues are fixed. To reproduce these failures locally you can: $ export ASAN_OPTIONS=detect_leaks=0:allocator_may_return_null=1:handle_segv=0
$ ./configure --with-address-sanitizer --without-pymalloc
$ make -j -s
$ ./python -m test test_sys_settrac |
Pablo, Is there a bpo issue for the buildbot failures on Windows? Long term, I expect to fix it by decoupling the C and Python stacks. |
That won't fix half of the Windows failures because the stack overflow you are seeing are for C to C calls if I am not mistaken. This happens on very deep calls when converting Python objects to C objects. There are no Python frames involved in that case IIRC. |
Yes, this one: https://bugs.python.org/issue44348 But just to clarify, the ones affecting this issue are the ones in ASAN, for example: https://buildbot.python.org/all/#/builders/582/builds/227/steps/5/logs/stdio |
Thanks, Pablo! |
FWIW, I've wrapped up the key parts that I wanted to get done here
|
Another task seems to have appeared, Nick Coghlan would like the typedef to be renamed to PyLocal_VarKind, and the getter/setter similarly. |
I don't think there is anything left to do here, so closing. |
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: