Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fontforge: PyFF_OpenFont(): fontforge killed by signal 6 #3042

Closed
pnemade opened this issue Mar 7, 2017 · 7 comments
Closed

fontforge: PyFF_OpenFont(): fontforge killed by signal 6 #3042

pnemade opened this issue Mar 7, 2017 · 7 comments

Comments

@pnemade
Copy link
Contributor

pnemade commented Mar 7, 2017

  1. Use a simple fontforge script where it will open the sfd file e.g. say generate.ff
import fontforge
from sys import argv

argc = len( argv )

if argc > 1:
	for i in range( 1, argc ):
		f = fontforge.open( argv[i] )
		otfile = f.fontname + ".otf"
		print("Generating OpenType file ", otfile)
		f.close()
  1. get any sfd file e.g. FreeSans.sfd from gnu-free-fonts upstream tarball or get it directly from here https://pnemade.fedorapeople.org/FreeSans.sfd

  2. run following command
    /usr/bin/fontfore -lang=py -script generate.ff FreeSans.sfd

This will cause core dump. I suspect issue somewhere in python3.6 version. I am getting this core dump on Fedora 26 system where we have fontforge-20161012-5.fc26.x86_64, python3-3.6.0-20.fc26.x86_64, gcc-7.0.1-0.10.fc26.x86_64 packages installed.

Truncated backtrace:

 #6 PyFF_OpenFont at python.c:1013
 #7 _PyCFunction_FastCallDict at /usr/src/debug/Python-3.6.0/Objects/methodobject.c:234
 #8 _PyCFunction_FastCallKeywords at /usr/src/debug/Python-3.6.0/Objects/methodobject.c:295
 #9 call_function at /usr/src/debug/Python-3.6.0/Python/ceval.c:4788
 #10 _PyEval_EvalFrameDefault at /usr/src/debug/Python-3.6.0/Python/ceval.c:3275
 #11 _PyEval_EvalCodeWithName at /usr/src/debug/Python-3.6.0/Python/ceval.c:4119
 #12 PyEval_EvalCodeEx at /usr/src/debug/Python-3.6.0/Python/ceval.c:4140

More information can be obtained from https://bugzilla.redhat.com/show_bug.cgi?id=1429574

@frank-trampe
Copy link
Contributor

I can't reproduce the crash on Ubuntu, but it seems to be happening on the free statement. Could you try attaching valgrind to see whether it complains about a double-free there? Do you get the problem if you compile from source locally?

The Python documentation says that we are responsible for freeing a string from PyArg_ParseTuple, but it's customary to use PyMemFree instead of free. That might be a problem, but I don't know why it wouldn't surface anywhere else in our Python code.

Do previous versions of FontForge work?

@pnemade
Copy link
Contributor Author

pnemade commented Mar 9, 2017

I just found this issue can be similar of issue #2992. I need some time to test the fix and if found working will close this as duplicate.

Thanks @frank-trampe for looking into this issue.

@frank-trampe
Copy link
Contributor

@pnemade, I see that you pushed a patch to Fedora with the PyMem_Free change. Does that solve the problem?

@pnemade
Copy link
Contributor Author

pnemade commented Mar 10, 2017

@frank-trampe I think so. I was testing gnu-free-fonts and its built fine but then I realized some other font package is still failing to build using fontforge python API. Hence, I changed many of the free() calls to PyMem_Free() and now those fonts are also building fine against fontforge.
I have submitted #3046 which will fix reported problems here.

@gioele
Copy link
Contributor

gioele commented Mar 14, 2017

@pnemade: with #3046 merged this bug should be fixed, right? Could you please close it if this is the case?

@pnemade
Copy link
Contributor Author

pnemade commented Mar 15, 2017

@gioele Yes this bug is fixed now and all the Fedora fonts builds also succeeded now.

@pnemade pnemade closed this as completed Mar 15, 2017
Omnikron13 pushed a commit to Omnikron13/fontforge that referenced this issue May 31, 2022
…ement

This is also based on the discussion happened in upstream issue
fontforge#2992

This commit is a fix for the reported two problems in issue
fontforge#3042

The upstream documentation says
PyArg_ParseTuple() will allocate a buffer of the needed size, copy the
encoded data into this buffer and adjust *buffer to reference the newly
allocated storage. The caller is responsible for calling PyMem_Free()
to free the allocated buffer after use.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants