This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients amaury.forgeotdarc, belopolsky, furkanonder, meador.inge, miss-islington, python-dev, vstinner
Date 2020-05-27.15:54:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1590594886.31.0.286700595551.issue13097@roundup.psfhosted.org>
In-reply-to
Content
Thanks Meador Inge for the bug report and thanks Sean Gillespie for the fix! It just took 9 years to fix this corner case ;-)

Copy of the comment on the PR:
https://github.com/python/cpython/pull/19914#pullrequestreview-419331432

I tried to rewrite _ctypes_callproc() to use PyMem_Malloc() instead of alloca(), but it's quite complicated. There are 3 arrays with a length of argcount items: args, avalues, atypes. Moreover, resbuf is also allocated with alloca(). When using PyMem_Malloc(), error handling is much more complicated.

I also tried to restrict the overall usage of stack memory to 4096 bytes (size of one page on x86), but users would be surprised by CTYPES_MAX_ARGCOUNT value.

I would say that raising an exception is better than crashing for a lot of arguments. If someone is blocked by this new limitation, in that case we can revisit the PyMem_Malloc() idea.
History
Date User Action Args
2020-05-27 15:54:46vstinnersetrecipients: + vstinner, amaury.forgeotdarc, belopolsky, meador.inge, python-dev, miss-islington, furkanonder
2020-05-27 15:54:46vstinnersetmessageid: <1590594886.31.0.286700595551.issue13097@roundup.psfhosted.org>
2020-05-27 15:54:46vstinnerlinkissue13097 messages
2020-05-27 15:54:46vstinnercreate