[issue12764] segfault in ctypes.Struct with bad _fields_
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset b8acee08283c by Amaury Forgeot d'Arc in branch '3.2': Issue #12764: Fix a crash in ctypes when the name of a Structure field is not http://hg.python.org/cpython/rev/b8acee08283c New changeset 1ed1ea0f4cd8 by Amaury Forgeot d'Arc in branch 'default': Merge from 3.2: Issue #12764: Fix a crash in ctypes when the name of a http://hg.python.org/cpython/rev/1ed1ea0f4cd8 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12764 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12764] segfault in ctypes.Struct with bad _fields_
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset 73827c23cdde by Amaury Forgeot d'Arc in branch '2.7': Issue #12764: Fix a crash in ctypes when the name of a Structure field is not http://hg.python.org/cpython/rev/73827c23cdde -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12764 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12764] segfault in ctypes.Struct with bad _fields_
Meador Inge mead...@gmail.com added the comment: This has been fixed. I verified tip and 2.7. -- resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12764 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12764] segfault in ctypes.Struct with bad _fields_
Meador Inge mead...@gmail.com added the comment: Vlad, Thanks for the patch. A few nits: 1. The test case is in 'test_bitfields.py'. I think it should go in 'test_structures.py'. 2. The test case would probably be cleaner using a 'with' context manager: with self.assertRaises(TypeError): class S(Structure): _fields_ = [(bx, c_int)] A few more test cases might be nice too. 3. The TypeError message display something like: structure field name must be string not bytes maybe the following would be more understandable: field name must be an object of type str not bytes 4. The 'ptr', 'len', and 'buf' initializers are unnecessary. Otherwise, looks good. -- nosy: +meadori stage: - patch review versions: +Python 3.3, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12764 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12764] segfault in ctypes.Struct with bad _fields_
Vlad Riscutia riscutiav...@gmail.com added the comment: Attached patch for 3.3 with unittest -- keywords: +patch nosy: +vladris Added file: http://bugs.python.org/file22923/issue12764_patch3x.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12764 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12764] segfault in ctypes.Struct with bad _fields_
Vlad Riscutia riscutiav...@gmail.com added the comment: Also patch for 2.7 with unittest. BTW, bx works on 2.7. -- Added file: http://bugs.python.org/file22924/issue12764_patch2x.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12764 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12764] segfault in ctypes.Struct with bad _fields_
New submission from Amaury Forgeot d'Arc amaur...@gmail.com: This crashes on python 3.3:: class S(ctypes.Structure): _fields_ = [(b'x', ctypes.c_int)] This also crashes on python 2.7:: class S(ctypes.Structure): _fields_ = [(u'x\xe9', ctypes.c_int)] The cause is the same: in Modules/_ctypes/stgdict.c, the assignment fieldname = _PyUnicode_AsString(name); does not check for errors. -- components: ctypes keywords: easy messages: 142218 nosy: amaury.forgeotdarc priority: normal severity: normal status: open title: segfault in ctypes.Struct with bad _fields_ type: crash ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12764 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com