[Rcpp-devel] R session crashes when largely using a Rcpp sourced function
Jonathan Olmsted
jpolmsted at gmail.com
Wed Oct 8 15:53:44 CEST 2014
>
> So, you think I should go to postfix increments instead of prefix?
> I'm a beginner in C++, so I'm not comfortable on which of them to chose.
>
I was just giving some tips in case you needed to look at the output from
Valgrind. When using the prefix, Valgrinds messages didn't lead me right to
the problem. When using postfix, they did. A more seasoned user may have
been able to identify the problem using prefix, but I did not.
> If it still don't work after these fixings,
>
... fingers crossed.
-Jonathan
> Again, thank you for your help, and if you're interested I could describe
> you in details the goals of this code (i guess it's not the purpose of tis
> list)
> I'll let you know!
>
> Pierre
>
>
> Jonathan Olmsted <jpolmsted at gmail.com> a écrit :
>
>
> Pierre,
>>
>> Have you used a tool like Valgrind? There is a bit of a learning curve,
>> but
>> it is exceedingly useful.
>>
>> A few comments:
>>
>> 1) For cases likes this gctortute(TRUE) in your R script helps those “for
>> enough iterations in a loop…” bugs to present quickly. With
>> gctorture(TRUE)
>> I’m producing the crash with fewer than 50 iters.
>>
>> 2) What you are implementing has everything to do with RNGs, so setting
>> the seed is useful for reproducibility
>> .
>>
>> 2) I got useful messages from Valgrind after changing your prefix
>> increments to postfix increments, but I didn’t before making that switch
>> (if I remember correctly)
>> .
>>
>> 3) These msgs points me to these lines
>>
>> for(int i = 1; i < kappa+2; i++){
>> phi_omega[i-1] = phi_C(arma::trans(omegas.row(i)),
>> piks,muks,Cks,Gamma);
>> }
>> accept = all_C((phi_omega < Upsilon));
>>
>> in main_function_C(). Pretty sure you have an “off by 1” error here. kappa
>> is an int, phi_omega has kappa elements (in elements 0 through kappa -1),
>> but you refer to elements 1-1=0 through kappa+1-1=kappa which is the
>> position of the kappa+1st elem.
>>
>> I switched your loop to for(int i = 1; i < kappa+1; i++) and it is running
>> under Valgrind now (i.e. slowly) and it’s gotten farther than any other
>> run
>> thus far.
>> Without having a conceptual understanding of what you are trying to do,
>> I
>> have no idea if this is the right fix for you (and I may be mistaken
>> altogether of course...).
>>
>> HTH,
>> Jonathan
>>
>>
>>
>> On Tue, Oct 7, 2014 at 8:17 PM, Dirk Eddelbuettel <edd at debian.org> wrote:
>>
>>
>>> Hi Pierre,
>>>
>>> On 8 October 2014 at 01:59, Pierre.Gloaguen at ifremer.fr wrote:
>>> | I will do what I can to reduce the code and have to same error
>>> occuring.
>>> | Of course i don't expect you to read all of it :) I was just wondering
>>> | if that kind of memory problem occured before, and if has some
>>> | "typical/generic" solutions.
>>> | I will try to have a shortest code to exhibit.
>>>
>>> Really appreciate it.
>>>
>>> Many of us found over the years that just by "creating a better example"
>>> to
>>> often drill down close enough to the problem core.
>>>
>>> And the easier you make it for folks to help you, the likier it is that
>>> some
>>> kind soul from around here can give you a hand.
>>>
>>> Just lowering the barriers, be it cognitive or just plain effort ...
>>>
>>> Best, Dirk
>>>
>>> --
>>> http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
>>> _______________________________________________
>>> 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
>>>
>>>
>>
>>
>> --
>>
>> J.P. Olmsted
>> j.p.olmsted at gmail.com
>>
>>
>
>
>
--
J.P. Olmsted
j.p.olmsted at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20141008/b3314636/attachment.html>
More information about the Rcpp-devel
mailing list