From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?iso-8859-1?Q?Court=E8s?=) Newsgroups: gmane.lisp.guile.user Subject: Re: seg fault with repeated function calls from C? Date: Tue, 16 Dec 2008 21:08:09 +0100 Message-ID: <871vw7hoie.fsf@gnu.org> References: <1229408522.10718.11.camel@home-desktop> <1229447835.11638.3.camel@home-desktop> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1229458160 30404 80.91.229.12 (16 Dec 2008 20:09:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 16 Dec 2008 20:09:20 +0000 (UTC) Cc: Anand Dixit To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Tue Dec 16 21:10:25 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 1LCgEn-0004iS-Nm for guile-user@m.gmane.org; Tue, 16 Dec 2008 21:09:49 +0100 Original-Received: from localhost ([127.0.0.1]:39904 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LCgDb-0001XJ-My for guile-user@m.gmane.org; Tue, 16 Dec 2008 15:08:35 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LCgDW-0001UX-BD for guile-user@gnu.org; Tue, 16 Dec 2008 15:08:30 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LCgDT-0001Nj-Q2 for guile-user@gnu.org; Tue, 16 Dec 2008 15:08:29 -0500 Original-Received: from [199.232.76.173] (port=56696 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LCgDS-0001Ml-S5 for guile-user@gnu.org; Tue, 16 Dec 2008 15:08:27 -0500 Original-Received: from main.gmane.org ([80.91.229.2]:35291 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LCgDS-0001Ox-EQ for guile-user@gnu.org; Tue, 16 Dec 2008 15:08:26 -0500 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1LCgDM-0007OE-Ek for guile-user@gnu.org; Tue, 16 Dec 2008 20:08:20 +0000 Original-Received: from reverse-83.fdn.fr ([80.67.176.83]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 16 Dec 2008 20:08:20 +0000 Original-Received: from ludo by reverse-83.fdn.fr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 16 Dec 2008 20:08:20 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 44 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: reverse-83.fdn.fr X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 26 Frimaire an 217 de la =?iso-8859-1?Q?R=E9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 821D 815D 902A 7EAB 5CEE D120 7FBA 3D4F EB1F 5364 X-OS: i686-pc-linux-gnu User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.3 (gnu/linux) Cancel-Lock: sha1:LzKysO4n45P5OaklXZnV2N1eSRA= X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) 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:7004 Archived-At: Hello, Anand Dixit writes: > Resending to the group.My apologies if you receive it twice but I didn't > see the post in the archives. Apparently I did not receive it the first time. >> I am calling a guile function from my C code. Its a fairly straight >> 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 : >> >> int tmp,count=10000; >> for (tmp=1;tmp> func_symbol = scm_c_lookup("EsourceFn"); >> func = scm_variable_ref(func_symbol); >> ret=scm_call_4(func,scm_int2num(i),scm_int2num(j),scm_int2num(k),scm_double2num(currentTime)); >> retValue = scm_num2double(ret,0,"fdtd"); >> printf("Value from guile is tmp=%d %g\n",tmp,retValue); >> } >> >> 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 would >> be greatly appreciated. Could you provide a complete backtrace with GDB? To do that, run GDB as follows on the `core' file yielded by the segfault: $ gdb `which guile` core (gdb) bt full (If there's no `core' file, type "ulimit -c unlimited".) 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. Also, which version of Guile are you using? Thanks, Ludo'.