Re: [Rd] .Call and Segmentation Fault

From: Byron Ellis <ellis_at_stat.harvard.edu>
Date: Fri 26 Aug 2005 - 22:55:06 GMT

Are you returning a SEXP? .Call (unlike .C) expects a SEXP return value. It sounds like you're returning garbage and R is choking on that when it tries to use the address as a SEXP.

On Aug 26, 2005, at 3:19 PM, Ricardo Luiz Andrade Abrantes wrote:

> Hello to everyone!
> I use .Call to call a C function without arguments wich calls a
> fortran optimization package. My C function uses others C and Fortran
> functions and it works fine when I call it from a main() in a C
> program. But when I call it from R with
> .Call("name_of_the_c_function"), R gives me some weird output.
> This weird output is a worng answer to my optimization problem
> (sometimes after thousands iteractions, what does not occur when
> called from C) or a segmentation fault error. The kind of output
> depends on the machine I am using. At home I got a segmentation faul,
> in university I got those wrong values.
> I tried a memcheck in C and Fortran binaries, but everything seems
> allright except by 2 missing free() calls (wich I don`t think might be
> causing this error).
> I compiled my C and Fortran files with R CMD SHARED and then linked
> all the .o with the same command. I also tried compiling all the
> needed object files with -fPIC and -shared and then using R CMD SHARED
> to link everything, but I got the same problem.
> The only thing I do in R is the following:
>
> dyn.load("mylib.so")
> .Call("name_of_the_c_function")
>
> Can someone hellp me with this?
>
>
> Thanks!
>
>
> Ricardo
>
> ______________________________________________
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

---
Byron Ellis (ellis@stat.harvard.edu)
"Oook" -- The Librarian

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Sat Aug 27 08:58:43 2005

This archive was generated by hypermail 2.1.8 : Mon 20 Feb 2006 - 03:21:19 GMT