From p.dalgaard at biostat.ku.dk  Wed Aug 31 00:03:21 2005
From: p.dalgaard at biostat.ku.dk (Peter Dalgaard)
Date: 31 Aug 2005 00:03:21 +0200
Subject: [Rd] .Call and Segmentation Fault
In-Reply-To: <973080e1050830133260bec316@mail.gmail.com>
References: <973080e10508261519699235ea@mail.gmail.com>
	<F81375EB-3C7E-4385-ADC1-8842A449A332@stat.harvard.edu>
	<973080e10508271924266ea3bf@mail.gmail.com>
	<Pine.LNX.4.61.0508280718090.3599@gannet.stats>
	<973080e1050830133260bec316@mail.gmail.com>
Message-ID: <x2oe7faxqu.fsf@turmalin.kubism.ku.dk>

Ricardo Luiz Andrade Abrantes <rabrantes82 at gmail.com> writes:

> Hello to everybody!
> After reading all the C code, checking for problems, and find nothing, I 
> decided something a little bit different...
> If my ".so" library works in a wrog way in R it should do the same in C. So 
> I created a C program that loads my library file and the executes the same 
> function R is executing.
> The program worked perfectly! In fact I changed two things in my library: 
> The function I call now return an int, not a SEXP, and the return value is 0 
> not R_NilValue.
> Valgrind's output is ok too... 
> If .Call has no problems, and if my function works perfect when called from 
> a C program, where the problem lies? Why my program becomes "crazy" when I 
> run it from R?
> I would apreciate very much your help! I don't where else I could find help 
> on this.

Well, did you try running under a debugger? 

  R -d gdb 

then "bt" after the segfault. (Make sure that things are compiled with
-g option)



-- 
   O__  ---- Peter Dalgaard             ?ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907



[Rd] .Call and Segmentation Fault
Peter Dalgaard