-
-
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
Segmentation fault with compile
#113297
Comments
Hello! Thanks for the report. FWIW, it's reproducible without a compile: Details# example.py
def mocks(self, search_rv=None, mock_internal_search=False):
with mock.patch.object(
TestResourceController, "_search" if mock_internal_search else "search", return_value=search_rv
) as mock_search, mock.patch.object(TestResourceController, "_count") as mock_count, mock.patch.object(
TestResourceController, "_before_create"
) as mock_before_create, mock.patch.object(
TestResourceController, "_create"
) as mock_create, mock.patch.object(
TestResourceController, "_after_create"
) as mock_after_create, mock.patch.object(
TestResourceController, "_before_update"
) as mock_before_update, mock.patch.object(
TestResourceController, "_update"
) as mock_update, mock.patch.object(
TestResourceController, "_after_update"
) as mock_after_update, mock.patch.object(
TestResourceController, "_before_delete"
) as mock_before_delete, mock.patch.object(
TestResourceController, "_delete"
) as mock_delete, mock.patch.object(
TestResourceController, "_after_delete"
) as mock_after_delete, mock.patch.object(
TestResourceController, "validate"
) as mock_validate, mock.patch.object(
TestSourceManager, "search", side_effect=self.mock_source_search_func()
) as mock_source_search, mock.patch.object(
TestSourceManager, "before_create"
) as mock_source_before_create, mock.patch.object(
TestSourceManager, "after_create"
) as mock_source_after_create, mock.patch.object(
TestSourceManager, "before_update"
) as mock_source_before_update, mock.patch.object(
TestSourceManager, "after_update"
) as mock_source_after_update, mock.patch.object(
TestSourceManager, "before_delete"
) as mock_source_before_delete, mock.patch.object(
TestSourceManager, "after_delete"
) as mock_source_after_delete, mock.patch.object(
TestSourceManager2, "search", side_effect=self.mock_source_search_func()
) as mock_source2_search:
yield 1 ./python example.py
> Segmentation fault |
It's an out of range array error at the C level, Tagging @iritkatriel Stack trace:
|
Reduced MRE: def bug():
with (
a
as a, a
as a, a
as a, a
as a, a
as a, a
as a, a
as a, a
as a, a
as a, a
as a, a
as a, a
as a, a
as a, a
as a, a
as a, a
as a, a
as a, a
as a, a
as a, a
as a
):
yield a |
|
Ah, I can reproduce on 3.12.1+, but not on 3.12.0a0. |
I cannot judge how this solution is true, but changing this line Line 651 in b221e03
to this: basicblock *handlers[CO_MAXBLOCKS+2]; solves the segfault.
|
This is the same as @Eclips4 's repro (just numbered): def bug():
with (
a
as a1, a
as a2, a
as a3, a
as a4, a
as a5, a
as a6, a
as a7, a
as a8, a
as a9, a
as a10, a
as a11, a
as a12, a
as a13, a
as a14, a
as a15, a
as a16, a
as a17, a
as a18, a
as a19, a
as a
):
yield a If I add one more context manager, it doesn't crash but raises a syntax error about exceeding static depth: def bug():
with (
a
as a1, a
as a2, a
as a3, a
as a4, a
as a5, a
as a6, a
as a7, a
as a8, a
as a9, a
as a10, a
as a11, a
as a12, a
as a13, a
as a14, a
as a15, a
as a16, a
as a17, a
as a18, a
as a19, a
as a20, a
as a
):
yield a % ./python.exe tt.py
File "/Users/iritkatriel/src/cpython-1/tt.py", line 2
with (
^^^^^^^
SyntaxError: too many statically nested blocks The bug is that the compiler allocates space for one too few elements in the exception stack. I will make a PR to fix this. |
We crossed wires - yes that's the one. |
…context managers (python#113327) (cherry picked from commit c31943a)
Crash report
What happened?
Minimal reproducible example
tests.py
crash.py
Segmentation fault
shadchin@i113735019 ~ % python3.12 crash.py zsh: segmentation fault python3.12 crash.py
CPython versions tested on:
3.12
Operating systems tested on:
Linux, macOS
Output from running 'python -VV' on the command line:
Python 3.12.1 (main, Dec 8 2023, 18:57:37) [Clang 14.0.3 (clang-1403.0.22.14.1)]
Linked PRs
The text was updated successfully, but these errors were encountered: