[Rcpp-devel] Attribute does not compile with 'compileAttributes' but with 'sourceCpp'

JJ Allaire jj.allaire at gmail.com
Fri Nov 1 15:56:21 CET 2013


Are you by any chance on OS X Mavericks? I had one other user report this
specific error on Mavericks and it seemed to be related to the use of
different compilers (and thus different heaps) within the same compilation
(there is exposure to this with the changes made by Apple to the toolchain
in Mavericks).

J.J.


On Fri, Nov 1, 2013 at 10:01 AM, Simon Zehnder <szehnder at uni-bonn.de> wrote:

> Dear Rcpp::Users and Rcpp::Devels,
>
> I get a weird exception when I try to compile an attribute in one of my
> packages:
>
> compileAttributes("/Users/simonzehnder/git/mmstruct/mmstruct/")
> R(6256,0x7fff79ad9310) malloc: *** error for object 0x7fff7ac48330:
> pointer being freed was not allocated
> *** set a breakpoint in malloc_error_break to debug
> Abort trap: 6
>
> If I instead use the sourceCpp function all works fine:
>
> sourceCpp("/Users/simonzehnder/git/mmstruct/mmstruct/src/testing.cpp”)
> testfunction_cc(c(0,0,0), list(trades = rnorm(10), T = 360))
> [1] 0.000000e+00 3.509927e-05 1.169976e-05
>
> The function in my file is actually pretty simple (and its the only one):
>
> #include<Rcpp.h>
>
> // [[Rcpp::export]]
>
> Rcpp::NumericVector testfunction_cc(Rcpp::NumericVector par,
>         Rcpp::List list)
> {
>     const unsigned int K        = par.size();
>     Rcpp::NumericVector trades  = list["trades"];
>     const unsigned int T        = list["T"];
>     double tmp = mean(trades)/T;
>     std::vector<double> startp(K);
>     startp[0] = 0.0;
>     startp[1] = tmp * 0.75/2;
>     startp[2] = tmp * 0.25/2;
>
>     return Rcpp::wrap(startp);
> }
>
> At this moment I am a little perplexed. Where should I search for a
> possible error? What are things to try out?
>
> Best
>
> Simon
>
> _______________________________________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20131101/85e0ea2e/attachment.html>


More information about the Rcpp-devel mailing list