Date: Mon, 15 Dec 2003 09:48:59 +0900 From: "Jin-Hwan Cho" <chofchof@kias.re.kr> To: <FreeBSD-gnats-submit@FreeBSD.org> Cc: "Cho, Jin-Hwan" <chofchof@ktug.or.kr> Subject: misc/60243: Problem in calling kpathsea library from Python extension Message-ID: <002501c3c2a5$3a5c8480$8f1da8c0@kias.re.kr> Resent-Message-ID: <200312150050.hBF0oKaN081017@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 60243 >Category: misc >Synopsis: Problem in calling kpathsea library from Python extension >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun Dec 14 16:50:19 PST 2003 >Closed-Date: >Last-Modified: >Originator: Jin-Hwan Cho >Release: FreeBSD 5.1-RELEASE i386 >Organization: Korean TeX Users Group >Environment: System: FreeBSD hep-ph.konkuk.ac.kr 5.1-RELEASE FreeBSD 5.1-RELEASE #0: Thu Jun 5 02:55:42 GMT 2003 root@wv1u.btc.adaptec.com:/usr/obj/usr/src/sys/GENERIC i386 Packages: python-2.2.2_2, teTeX-2.0.2_2 (kpathsea library version 3.4.5) >Description: Recently I am trying to write a Python extension using the kpathsea library. It was simple and everying went smoothly. But I got a severe problem in FreeBSD. Even simple code did not work in FreeBSD. After trying some tests, I found where the problem occurred. That was "cnf.c" in the kpathsea library (contained in teTeX-2.0.2_2 package). There is a place in "cnf.c" calling "hash_create()" function (defined in hash.c). However, in FreeBSD, the "hash_create()" was not called properly. After changing the name "hash_create()" to another one, for example, "hash_create2()", everything worked fine. I'd like to know exact reason why this kind of problem occurs in FreeBSD. >How-To-Repeat: On FreeBSD system with python-2.2.2_2 and teTeX-2.0.2_2 installed, using the attached three files, run the following command python setup.py install and then run python kpse_test.py The result is "Segmentation fault (core dumped)". >Fix: The problem above can be fixed by modifying the kpathsea library itself as follows: Change the name of "hash_create" function (defined in hash.c) to another name, for example, "hash_create2" from several files, cnf.c, db.c, dir.c, fontname.c, hash.c, and hash.h. It seems quite curious because there was no problem in cygwin. --- setup.py begins here --- from distutils.core import setup, Extension kpse_module = Extension('kpse', include_dirs = ['/usr/local/include'], libraries = ['kpathsea'], library_dirs = ['/usr/local/lib'], sources = ['kpse_module.c']) setup(name = 'kpse', ext_modules = [kpse_module]) --- setup.py ends here --- --- kpse_module.c begins here --- #include <Python.h> #include <kpathsea/kpathsea.h> static PyObject *SetProgramName (PyObject *self, PyObject *args) { string argv0, progname; if (!PyArg_ParseTuple(args, "sz", &argv0, &progname)) return NULL; kpse_set_program_name(argv0, progname); return Py_BuildValue(""); } static PyObject *VarValue (PyObject *self, PyObject *args) { string var; if (!PyArg_ParseTuple(args, "s", &var)) return NULL; return Py_BuildValue("z", kpse_var_value(var)); } static PyMethodDef kpseMethods[] = { {"set_program_name", SetProgramName, METH_VARARGS, NULL}, {"var_value", VarValue, METH_VARARGS, NULL}, {NULL, NULL, 0, NULL} /* sentinel */ }; void initkpse (void) { Py_InitModule("kpse", kpseMethods); } --- kpse_module.c ends here --- --- kpse_test.py begins here --- import kpse kpse.set_program_name('/usr/local/bin/kpsewhich', None) print kpse.var_value('TEXMFMAIN') --- kpse_test.py ends here --- >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?002501c3c2a5$3a5c8480$8f1da8c0>