From owner-freebsd-bugs@FreeBSD.ORG Sun Dec 14 16:50:22 2003 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D096B16A4CE for ; Sun, 14 Dec 2003 16:50:22 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 754CA43D32 for ; Sun, 14 Dec 2003 16:50:20 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) hBF0oKFR081018 for ; Sun, 14 Dec 2003 16:50:20 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.10/8.12.10/Submit) id hBF0oKaN081017; Sun, 14 Dec 2003 16:50:20 -0800 (PST) (envelope-from gnats) Resent-Date: Sun, 14 Dec 2003 16:50:20 -0800 (PST) Resent-Message-Id: <200312150050.hBF0oKaN081017@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, "Jin-Hwan Cho" Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 24BC516A4CE for ; Sun, 14 Dec 2003 16:49:11 -0800 (PST) Received: from mail.kias.re.kr (mail.kias.re.kr [210.98.29.13]) by mx1.FreeBSD.org (Postfix) with ESMTP id 095F843D31 for ; Sun, 14 Dec 2003 16:49:08 -0800 (PST) (envelope-from chofchof@kias.re.kr) Received: from mail (localhost [127.0.0.1]) by mail2 (Spambreaker) with ESMTP id 564ED92E84 for ; Mon, 15 Dec 2003 09:47:36 +0900 (KST) Received: from spin (dhcp.kias.re.kr [210.98.29.3]) by mail.kias.re.kr (Spambreaker) with SMTP id 4143E92E83; Mon, 15 Dec 2003 09:47:36 +0900 (KST) Message-Id: <002501c3c2a5$3a5c8480$8f1da8c0@kias.re.kr> Date: Mon, 15 Dec 2003 09:48:59 +0900 From: "Jin-Hwan Cho" To: cc: "Cho, Jin-Hwan" Subject: misc/60243: Problem in calling kpathsea library from Python extension X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Dec 2003 00:50:22 -0000 >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 #include 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: