Issue 15306: Python3 segfault? (works in Python2) (original) (raw)

Created on 2012-07-09 14:35 by Ztatik.Light, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
test.py Ztatik.Light,2012-07-09 14:35 freetype/ctypes/Python3 segfault
backtrace.txt Ztatik.Light,2012-07-09 15:00 FT_Request_Size crash backtrace
Messages (7)
msg165084 - (view) Author: Ztatik Light (Ztatik.Light) Date: 2012-07-09 14:35
I think I've found a bug ... The issue is that it works fine on Python2 but segfaults on Python3.. (The second to last line causes the crash) Tested on v2.6.6 and 3.1.3: (Must have libfreetype6 and the TTF specified on 5th to last line [if on Windows, simple download libfreetype6 here: http://tinyurl.com/7dvgffw and replace the '.ttf' string with any existing .ttf file]) [File attached as 'test.py']
msg165086 - (view) Author: Ztatik Light (Ztatik.Light) Date: 2012-07-09 15:00
Crash happens in FT_Request_Size and seems to have been addressed by someone working at SFML: http://en.sfml-dev.org/forums/index.php?topic=2208.0 [Backtrace attached as 'backtrace.txt']
msg165088 - (view) Author: Ztatik Light (Ztatik.Light) Date: 2012-07-09 15:15
I think this is the related SFML fix patch commit: https://github.com/LaurentGomila/SFML/commit/da5ac8a9512885c5b245a24915733c3b26f689b7
msg165089 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2012-07-09 15:21
How is the fix related to Python? Also, you pass a unicode string to freetype.FT_New_Face. You should probably pass a bytes string there, and in any case set the "argtypes" and "restypes" attributes to ctypes functions, to prevent such failures.
msg165090 - (view) Author: Ztatik Light (Ztatik.Light) Date: 2012-07-09 15:37
Mmmm. The fix isn't necessary related to python at all but I figured might potentially AIDE in a python fix. Also, I'm not passing a unicode string... that says '/u' not '\u' ... Also, I tried setting res/argtypes but to no avail.
msg165091 - (view) Author: Ztatik Light (Ztatik.Light) Date: 2012-07-09 15:40
Ooohhhh ... using bytes() DID seem to help. HAHA?
msg165092 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2012-07-09 15:43
In Python2, strings are bytes; in Python3, they are unicode. You need to use the b'' syntax.
History
Date User Action Args
2022-04-11 14:57:32 admin set github: 59511
2012-07-09 15:43:23 amaury.forgeotdarc set status: open -> closedresolution: not a bugmessages: +
2012-07-09 15:40:03 Ztatik.Light set messages: +
2012-07-09 15:37:12 Ztatik.Light set messages: +
2012-07-09 15:21:16 amaury.forgeotdarc set nosy: + amaury.forgeotdarcmessages: +
2012-07-09 15:15:52 Ztatik.Light set messages: +
2012-07-09 15:00:01 Ztatik.Light set files: + backtrace.txtmessages: +
2012-07-09 14:35:48 Ztatik.Light create