<div dir="ltr">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).<div>
<br></div><div>J.J.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Nov 1, 2013 at 10:01 AM, Simon Zehnder <span dir="ltr"><<a href="mailto:szehnder@uni-bonn.de" target="_blank">szehnder@uni-bonn.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Dear Rcpp::Users and Rcpp::Devels,<br>
<br>
I get a weird exception when I try to compile an attribute in one of my packages:<br>
<br>
compileAttributes("/Users/simonzehnder/git/mmstruct/mmstruct/")<br>
R(6256,0x7fff79ad9310) malloc: *** error for object 0x7fff7ac48330: pointer being freed was not allocated<br>
*** set a breakpoint in malloc_error_break to debug<br>
Abort trap: 6<br>
<br>
If I instead use the sourceCpp function all works fine:<br>
<br>
sourceCpp("/Users/simonzehnder/git/mmstruct/mmstruct/src/testing.cpp”)<br>
testfunction_cc(c(0,0,0), list(trades = rnorm(10), T = 360))<br>
[1] 0.000000e+00 3.509927e-05 1.169976e-05<br>
<br>
The function in my file is actually pretty simple (and its the only one):<br>
<br>
#include<Rcpp.h><br>
<br>
// [[Rcpp::export]]<br>
<br>
Rcpp::NumericVector testfunction_cc(Rcpp::NumericVector par,<br>
Rcpp::List list)<br>
{<br>
const unsigned int K = par.size();<br>
Rcpp::NumericVector trades = list["trades"];<br>
const unsigned int T = list["T"];<br>
double tmp = mean(trades)/T;<br>
std::vector<double> startp(K);<br>
startp[0] = 0.0;<br>
startp[1] = tmp * 0.75/2;<br>
startp[2] = tmp * 0.25/2;<br>
<br>
return Rcpp::wrap(startp);<br>
}<br>
<br>
At this moment I am a little perplexed. Where should I search for a possible error? What are things to try out?<br>
<br>
Best<br>
<br>
Simon<br>
<br>
_______________________________________________<br>
Rcpp-devel mailing list<br>
<a href="mailto:Rcpp-devel@lists.r-forge.r-project.org">Rcpp-devel@lists.r-forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a><br>
</blockquote></div><br></div>