[R] Mysterious seg fault --- SOLVED

peter dalgaard pd@|gd @end|ng |rom gm@||@com
Mon Aug 13 13:39:30 CEST 2018


It's odd, possibly a bug, that you don't get 

Error: object 'nphi' not found

but I can't offhand see where the evaluation of args to .C/.Fortran is supposed to take place.

-pd

> On 13 Aug 2018, at 11:54 , Rolf Turner <r.turner using auckland.ac.nz> wrote:
> 
> 
> On 13/08/18 20:45, Henrik Bengtsson wrote:
> 
>> On Mon, Aug 13, 2018 at 3:51 AM Rolf Turner <r.turner using auckland.ac.nz> wrote:
>>> 
>>> 
>>> OK everybody!  You can relax.  :-) I managed to spot the loony.  After
>>> mucking around with valgrind, and before trying gdb, I had one more look
>>> at my code and *finally* saw the stupid thing that I had been doing.
>>> 
>>> In the call to .Fortran() I had a line
>>> 
>>>      nphi=as.integer(nphi),
>>> 
>>> but "nphi" was nowhere defined (!!!) in the R code.  The name "nphi"
>>> appeared as an argument in the Fortran subroutine in question, but was
>>> nowhere actually *used*!!!
>> Didn't R CMD check pick this up, that is, didn't it report that 'nphi'
>> is a "global" variable?
> 
> No it didn't.  The name only appears in the call to .Fortran().  I think if it appeared in a call to an ordinary garden-variety R function then a warning would have been issued.
> 
> Such a lapse would be hard for R CMD check to pick up.  E.g
> 
>   nphi=integer(1),
> 
> would be OK in a call to .Fortran (which would allow a value of nphi, calculated within the called subroutine, to be *returned*) whereas
> 
>   nphi=as.integer(nphi),
> 
> causes trouble when nphi has never been defined (as I found out after a great expenditure of time and torn-out hair).  In the former instance it doesn't matter an FTCF whether nphi has been defined or not.
> 
> cheers,
> 
> Rolf
> 
> -- 
> Technical Editor ANZJS
> Department of Statistics
> University of Auckland
> Phone: +64-9-373-7599 ext. 88276
> 
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd.mes using cbs.dk  Priv: PDalgd using gmail.com




More information about the R-help mailing list