-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
gh-145792: Fix incorrect alloca allocation size in traceback.c #145814
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -625,6 +625,18 @@ def test_signatures(self): | |
| str(inspect.signature(traceback.format_exception_only)), | ||
| '(exc, /, value=<implicit>, *, show_group=False, **kwargs)') | ||
|
|
||
| def test_traceback_deep_recursion_alloca(self): | ||
|
|
||
| def recurse(n): | ||
| if n == 0: | ||
| raise RuntimeError("boom") | ||
| return recurse(n - 1) | ||
| try: | ||
| recurse(50) | ||
| except RuntimeError as exc: | ||
| tb = traceback.format_exception(exc) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test is unrelated to the fix, I suggest removing it. I tried to write a test using
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think there's a reliable test we can write for this at the moment. The code path in question is only triggered on compilers that don't support VLAs, which is likely only MSVC on our buildbots. But, since Windows doesn't support |
||
| assert any("RuntimeError" in line for line in tb) | ||
|
|
||
|
|
||
| class PurePythonExceptionFormattingMixin: | ||
| def get_exception(self, callable, slice_start=0, slice_end=-1): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Fix incorrect memory allocation in the VLA fallback macro in traceback.c | ||
| when using alloca(), preventing potential out-of-bounds access. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is too technical. We should say something like "Fix out-of-bounds access when invoking |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,7 +41,7 @@ | |
|
|
||
| #if defined(__STDC_NO_VLA__) && (__STDC_NO_VLA__ == 1) | ||
| /* Use alloca() for VLAs. */ | ||
| # define VLA(type, name, size) type *name = alloca(size) | ||
| # define VLA(type, name, size) type *name = (type *)alloca(sizeof(type) * (size)) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove the |
||
| #elif !defined(__STDC_NO_VLA__) || (__STDC_NO_VLA__ == 0) | ||
| /* Use actual C VLAs.*/ | ||
| # define VLA(type, name, size) type name[size] | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this test.