[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: seg fault with repeated function calls from C?
From: |
Ludovic Courtès |
Subject: |
Re: seg fault with repeated function calls from C? |
Date: |
Tue, 16 Dec 2008 21:08:09 +0100 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.3 (gnu/linux) |
Hello,
Anand Dixit <address@hidden> 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<count;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'.