[Rd] Have you ever experienced this problem with REAL in a C code

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri May 9 12:38:25 CEST 2008


These messages mean that R's internal code is encountering the wrong 
SEXPTYPE.  This almost always means one of

- lact of PROTECTion, so objects have been garbage-collected before use.

- memory corruption, most often by writing outside array bounds.

See the chapter in 'Writing R Extensions' about this,  and if possible 
make use of valgrind.


On Fri, 9 May 2008, Mathieu Ribatet wrote:

>   Dear all,
>
> I'm currently experiencing big troubles with my C code called by .Call in a R 
> function.
>
> I know this may not be the right place for such things but these errors are 
> driving me crazy. And I hope other people may have already experienced these 
> problems so that they could give me good suggestions.
> Sorry if I'm completely out of topic.
>
> Well let's go...
>
> I'm writing a MCMC algo for Bayesian analysis. The MCMC part is written in C 
> but call R objects (e.g. output and arguments are SEXP). The C is called by a 
> wrapper R function through .Call. The posterior density is computed using a R 
> code that calls 2 different codes: one for the prior distribution and one for 
> the likelihood. The prior distribution is fully written in R while the 
> likelihood is computed using a C code. Both of these codes are (seem to be) 
> ok and *always* return numeric - and no special values as Inf, NA,...
>
> When I'm running my codes (enclosed you'll find the C code), I get one of the 
> following error - *when error occurs*:
>
> Error in gibbs(1000, init, prior.p, "whitmat", data = ms1, coord = locations, 
> :
> REAL() can only be applied to a 'numeric', not a 'raw'
>
> or
>
> Error in gibbs(1000, init, prior.p, "whitmat", data = ms1, coord = locations, 
> :
> REAL() can only be applied to a 'numeric', not a 'list'
>
> or
>
> Error in gibbs(1000, init, prior.p, "whitmat", data = ms1, coord = locations, 
> :
> REAL() can only be applied to a 'numeric', not an 'integer'
>
> The problem is that REAL seems not to be applied to a list (I've got no list 
> objects), and not to an integer too.
> I checked for wrong allocation memory, infinite values but found nothing...
>
> Any suggestions for possible reasons would be definitively appreciated.
> Again, if this mail has no reason to be in this list; sorry and forget it.
> Best,
> Mathieu
>
> -- 
> Institute of Mathematics
> Ecole Polytechnique Fédérale de Lausanne
> STAT-IMA-FSB-EPFL, Station 8
> CH-1015 Lausanne   Switzerland
> http://stat.epfl.ch/
> Tel: + 41 (0)21 693 7907
>
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


More information about the R-devel mailing list