classification
Title: ctypes: unions as arguments
Type: crash Stage: needs patch
Components: ctypes, Documentation Versions: Python 3.2, Python 3.3, Python 3.4, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Arfrever, alex, arigo, docs@python, eli.bendersky, meador.inge, python-dev, theller, vinay.sajip
Priority: normal Keywords:

Created on 2012-11-29 04:24 by arigo, last changed 2017-02-23 08:18 by vinay.sajip.

Files
File name Uploaded Description Edit
test184_lib.tgz arigo, 2012-11-29 04:24
Messages (6)
msg176627 - (view) Author: Armin Rigo (arigo) * (Python committer) Date: 2012-11-29 04:24
ctypes pretends to support passing arguments to C functions that are unions (not pointers to unions), but that's a lie.  In fact, the underlying libffi does not support it.  The attached example misbehaves on Linux x86-64.
msg183461 - (view) Author: Eli Bendersky (eli.bendersky) * (Python committer) Date: 2013-03-04 14:54
A minimal fix would be to update the documentation.

A more comprehensive fix would be to tweak ctypes to reject unions and bit-fields when running on non-x86 (does this work for ARM and other non-Intel archs?)

An even more comprehensive fix would be to make this work, but that would require forking libffi and should presumably be first implemented upstream.
msg183464 - (view) Author: Armin Rigo (arigo) * (Python committer) Date: 2013-03-04 15:12
See also http://bugs.python.org/issue16576.
msg183817 - (view) Author: Roundup Robot (python-dev) Date: 2013-03-09 13:56
New changeset 0acd9408b6f1 by Eli Bendersky in branch '3.2':
Add warning in ctypes documentation for #16575 and #16576
http://hg.python.org/cpython/rev/0acd9408b6f1

New changeset bfc159f8e4b4 by Eli Bendersky in branch '3.3':
Add warning in ctypes documentation for #16575 and #16576
http://hg.python.org/cpython/rev/bfc159f8e4b4

New changeset 502624235c7b by Eli Bendersky in branch 'default':
Add warning in ctypes documentation for #16575 and #16576
http://hg.python.org/cpython/rev/502624235c7b
msg183819 - (view) Author: Roundup Robot (python-dev) Date: 2013-03-09 13:57
New changeset eece32440a52 by Eli Bendersky in branch '2.7':
Add warning in ctypes documentation for #16575 and #16576
http://hg.python.org/cpython/rev/eece32440a52
msg186689 - (view) Author: Eli Bendersky (eli.bendersky) * (Python committer) Date: 2013-04-13 03:12
I've opened a libffi issue in an attempt to get this fixed upstream:

  https://github.com/atgreen/libffi/issues/33
History
Date User Action Args
2017-02-23 08:18:33vinay.sajipsetnosy: + vinay.sajip
2016-06-23 09:30:48berker.peksaglinkissue14354 superseder
2013-04-13 03:12:03eli.benderskysetmessages: + msg186689
2013-03-18 12:26:28eli.benderskysetnosy: + theller
2013-03-09 13:57:30python-devsetmessages: + msg183819
2013-03-09 13:56:20python-devsetnosy: + python-dev
messages: + msg183817
2013-03-04 15:12:57arigosetmessages: + msg183464
2013-03-04 14:54:53eli.benderskysetassignee: docs@python
components: + Documentation
versions: + Python 3.3, Python 3.4
nosy: + eli.bendersky, docs@python

messages: + msg183461
stage: needs patch
2012-12-14 08:30:56Arfreversetnosy: + Arfrever
2012-12-11 06:20:05meador.ingesetnosy: + meador.inge
2012-11-29 04:49:13arigosettype: crash
2012-11-29 04:33:04alexsetnosy: + alex
2012-11-29 04:24:04arigocreate