-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
ctypes: segfault with large POINTER type names #57305
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
Reproducible in 2.7 and tip: [meadori@motherbrain cpython]$ ./python
Python 3.3.0a0 (default:61de28fa5537+d05350c14e77+, Oct 3 2011, 21:47:04)
[GCC 4.6.0 20110603 (Red Hat 4.6.0-10)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes import *
>>> T = type('x' * 2 ** 25, (Structure,), {})
>>> p = POINTER(T)
Segmentation fault (core dumped) |
There is similar crasher to this one that can be reproduced like: [meadori@motherbrain cpython]$ ./python
Python 3.3.0a0 (default:61de28fa5537+d05350c14e77+, Oct 3 2011, 21:47:04)
[GCC 4.6.0 20110603 (Red Hat 4.6.0-10)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes import *
>>> p = POINTER('x' * 2 ** 25)
Segmentation fault (core dumped) It should be fixed as well. |
The problem is around line 1734 of callproc.c in tip:
Replacing the alloca with a malloc fixes it, so I presume it's hitting the stack size limit as 2^25 is 32MB (my stack limit is 8MB). |
Here is a small patch against tip. OK? |
Thanks for the report and patch, meador.inge. I'd prefer not to add more globals that are only used in one place, but doing so is consistent with the existing style of test_pointers.py, and there's plenty in this file that could be cleaned up in another ticket.
lgtm! => commit review |
Thanks for the review and reminder about this issue, jesstess. I will apply the patch later today. |
New changeset e940bb13d010 by R David Murray in branch '3.4': New changeset 02c9c3204a04 by R David Murray in branch 'default': New changeset ff59b0f9e142 by R David Murray in branch '2.7': |
Committed. |
It seems the python2 backport was incomplete as a PyMem_Free is missing, making buf leak. |
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: