classification
Title: Python3 segfault? (works in Python2)
Type: crash Stage:
Components: None, ctypes, Interpreter Core, IO, Library (Lib) Versions: Python 3.1, Python 2.6
process
Status: closed Resolution: invalid
Dependencies: Superseder:
Assigned To: Nosy List: Ztatik.Light, amaury.forgeotdarc
Priority: normal Keywords:

Created on 2012-07-09 14:35 by Ztatik.Light, last changed 2012-07-09 15:43 by amaury.forgeotdarc. 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
2012-07-09 15:43:23amaury.forgeotdarcsetstatus: open -> closed
resolution: invalid
messages: + msg165092
2012-07-09 15:40:03Ztatik.Lightsetmessages: + msg165091
2012-07-09 15:37:12Ztatik.Lightsetmessages: + msg165090
2012-07-09 15:21:16amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg165089
2012-07-09 15:15:52Ztatik.Lightsetmessages: + msg165088
2012-07-09 15:00:01Ztatik.Lightsetfiles: + backtrace.txt

messages: + msg165086
2012-07-09 14:35:48Ztatik.Lightcreate