From owner-freebsd-newbies@FreeBSD.ORG Tue May 13 09:32:44 2003 Return-Path: Delivered-To: freebsd-newbies@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 367E137B401 for ; Tue, 13 May 2003 09:32:44 -0700 (PDT) Received: from mta6.snfc21.pbi.net (mta6.snfc21.pbi.net [206.13.28.240]) by mx1.FreeBSD.org (Postfix) with ESMTP id B0BDD43FBD for ; Tue, 13 May 2003 09:32:43 -0700 (PDT) (envelope-from seva3@pacbell.net) Received: from gusenok ([66.123.222.250]) by mta6.snfc21.pbi.net (iPlanet Messaging Server 5.1 HotFix 1.6 (built Oct 18 2002)) with ESMTP id <0HEU00ELW3AIC8@mta6.snfc21.pbi.net> for freebsd-newbies@freebsd.org; Tue, 13 May 2003 09:32:43 -0700 (PDT) Date: Tue, 13 May 2003 09:34:17 -0700 From: Seva Tonkonoh To: freebsd-newbies@freebsd.org Message-id: MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7BIT Importance: Normal X-Priority: 3 (Normal) X-MSMail-priority: Normal Subject: python gives memory fault with my .so library X-BeenThere: freebsd-newbies@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Gathering place for new users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 May 2003 16:32:44 -0000 When I try to run my extension shared library for Python, it gives me "Memory fault(coredump)". I am running FreeBSD 4.7 on VMWare 4 on Dell 4100 workstation. I tried 2 versions of Python: 2.2.1 and 2.1.3. They both give the same error message, which makes me think I didn't create .so file correctly. Here is how I compiled my .so file: hello.so: hello.c gcc hello.c -g -I/usr/local/include/python2.1 -fpic -shared -o hello.so I tried hello.c from Lutz's O'Rei;;y book "Programming Python" because I had the same problem before with a more complex DLL, so I decided I have to try something simple first to narrow the problem. hello.c code is at the bottom of this email, just in case. What I tried to do with Python is: -start python interpreter in the directory where .so file resides. -do ">>> import hello". That runs fine. -do ">>> hello.message('bla')". That gives "Memory fault(coredump)". Please, cc me as I am not on the list. Thanks in advance, seva /***************************************************** hello.c ****************************************************/ #include #include /* module functions */ static PyObject * /* returns object */ message(PyObject *self, PyObject *args) /* self unused in modules */ { /* args from python call */ char *fromPython, result[64]; if (! PyArg_Parse(args, "(s)", &fromPython)) /* convert Python -> C */ return NULL; /* null=raise exception */ else { strcpy(result, "Hello, "); /* build up C string */ strcat(result, fromPython); /* add passed Python string */ return Py_BuildValue("s", result); /* convert C -> Python */ } } /* registration table */ static struct PyMethodDef hello_methods[] = { {"message", message, 1}, /* method name, C func ptr, always-tuple */ {NULL, NULL} /* end of table marker */ }; , /* module initializer */ void inithello() /* called on first import */ { /* name matters if loaded dynamically */ (void) Py_InitModule("hello", hello_methods); /* mod name, table ptr */ }