From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Anand Dixit Newsgroups: gmane.lisp.guile.user Subject: Re: seg fault with repeated function calls from C? Date: Tue, 16 Dec 2008 16:23:39 -0800 Message-ID: <1229473419.11638.13.camel@home-desktop> References: <1229408522.10718.11.camel@home-desktop> <1229447835.11638.3.camel@home-desktop> <871vw7hoie.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1229473135 14126 80.91.229.12 (17 Dec 2008 00:18:55 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 17 Dec 2008 00:18:55 +0000 (UTC) Cc: guile-user@gnu.org To: Ludovic =?ISO-8859-1?Q?Court=E8s?= Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Wed Dec 17 01:19:59 2008 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LCk8q-0004vp-Ga for guile-user@m.gmane.org; Wed, 17 Dec 2008 01:19:56 +0100 Original-Received: from localhost ([127.0.0.1]:53224 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LCk7e-0006L3-Fm for guile-user@m.gmane.org; Tue, 16 Dec 2008 19:18:42 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LCk6g-0005m6-3R for guile-user@gnu.org; Tue, 16 Dec 2008 19:17:42 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LCk6d-0005kA-UB for guile-user@gnu.org; Tue, 16 Dec 2008 19:17:41 -0500 Original-Received: from [199.232.76.173] (port=44837 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LCk6d-0005k0-Jn for guile-user@gnu.org; Tue, 16 Dec 2008 19:17:39 -0500 Original-Received: from brmea-mail-2.sun.com ([192.18.98.43]:40604) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LCk6a-0005Sa-NK; Tue, 16 Dec 2008 19:17:37 -0500 Original-Received: from fe-amer-09.sun.com ([192.18.109.79]) by brmea-mail-2.sun.com (8.13.6+Sun/8.12.9) with ESMTP id mBH0HZbK003394; Wed, 17 Dec 2008 00:17:35 GMT Original-Received: from conversion-daemon.mail-amer.sun.com by mail-amer.sun.com (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) id <0KBZ00301V6J3I00@mail-amer.sun.com> (original mail from Anand.Dixit@Sun.COM); Tue, 16 Dec 2008 17:17:35 -0700 (MST) Original-Received: from [192.168.2.4] ([64.9.237.132]) by mail-amer.sun.com (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) with ESMTPSA id <0KBZ009GHVH9GB50@mail-amer.sun.com>; Tue, 16 Dec 2008 17:17:34 -0700 (MST) In-reply-to: <871vw7hoie.fsf@gnu.org> X-Mailer: Evolution 2.22.3.1 X-MIME-Autoconverted: from 8bit to quoted-printable by brmea-mail-2.sun.com id mBH0HZbK003394 X-detected-operating-system: by monty-python.gnu.org: Solaris 9 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:7006 Archived-At: Hi Ludo, Looks like it accepts a post to guile-user only when you are registered. That would explain why the first post didn't show up.=20 Guile version is 1.8.3 running on Ubuntu 8.04. I tried the gdb commands you mentioned and here is a portion of the output : This GDB was configured as "x86_64-linux-gnu"... (no debugging symbols found) warning: core file may not match specified executable file. (no debugging symbols found) (no debugging symbols found) Core was generated by `fdtd poisson.ctl'. Program terminated with signal 11, Segmentation fault. [New process 12395] #0 0x00007f18eff3b49b in ?? () (gdb) bt full #0 0x00007f18eff3b49b in ?? () No symbol table info available. #1 0x00007f18eff3b3c7 in ?? () No symbol table info available. #2 0x00007ffff83f19dc in ?? () This continues to #132 lines. My C++ code is compiled with -g option. I am not sure if this is what you expected from gdb. =20 Thanks, Anand On Tue, 2008-12-16 at 21:08 +0100, Ludovic Court=C3=A8s wrote: > Hello, >=20 > Anand Dixit writes: >=20 > > Resending to the group.My apologies if you receive it twice but I did= n't > > see the post in the archives. >=20 > Apparently I did not receive it the first time. >=20 > >> I am calling a guile function from my C code. Its a fairly straig= ht > >> forward implementation. However, as I keep calling this function a > >> number of times, it breaks at some point with a segmentation fault. = Here > >> is the relevant portion : > >>=20 > >> int tmp,count=3D10000; > >> for (tmp=3D1;tmp >> func_symbol =3D scm_c_lookup("EsourceFn");=09 > >> func =3D scm_variable_ref(func_symbol); > >> ret=3Dscm_call_4(func,scm_int2num(i),scm_int2num(j),scm_int2num(k),s= cm_double2num(currentTime)); > >> retValue =3D scm_num2double(ret,0,"fdtd"); > >> printf("Value from guile is tmp=3D%d %g\n",tmp,retValue); > >> } > >>=20 > >> The break point in one case was after 4000+ calls. I was able to > >> localize the point of failure to the "scm_call_4" line. Any clue wou= ld > >> be greatly appreciated. >=20 > Could you provide a complete backtrace with GDB? To do that, run GDB a= s > follows on the `core' file yielded by the segfault: >=20 > $ gdb `which guile` core > (gdb) bt full >=20 > (If there's no `core' file, type "ulimit -c unlimited".) >=20 > Could it be that the `EsourceFn' symbol becomes unbound at some point, > or that it becomes bound to something that's not a procedure? Both > errors should normally be caught gracefully, but it's worth > investigating. >=20 > Also, which version of Guile are you using? >=20 > Thanks, > Ludo'. >=20 >=20 >=20