Re: [Rcpp-devel] (Very) rare segfault

2014-08-21 Thread Romain Francois
That makes sense. No real reason not to use attributes anyway :) Le 21 août 2014 à 15:54, JJ Allaire a écrit : > Yes, the link posted by Matteo is what provoked us to make the change in Rcpp > Attributes to dance around the constructor/destructor issues. > > Net: If you are using attributes

Re: [Rcpp-devel] (Very) rare segfault

2014-08-21 Thread Romain Francois
Ah interesting. PutRNGstate does indeed allocate so might trigger GC. https://github.com/wch/r-source/blob/fbf5cdf29d923395b537a9893f46af1aa75e38f3/src/main/RNG.c#L437 That's a whole new Pandora's box right there. Le 21 août 2014 à 12:10, Matteo Fasiolo a écrit : > Hi Romain and Gregor, > >

Re: [Rcpp-devel] (Very) rare segfault

2014-08-21 Thread Matteo Fasiolo
Hi Romain and Gregor, maybe I am misunderstanding everything, but hasn't this problem been explained and solved here: http://lists.r-forge.r-project.org/pipermail/rcpp-devel/2013-May/005838.html Best, Matteo On Thu, Aug 21, 2014 at 10:58 AM, Romain Francois wrote: > > Le 21 août 2014 à 11

Re: [Rcpp-devel] (Very) rare segfault

2014-08-21 Thread Romain Francois
Le 21 août 2014 à 11:47, Gregor Kastner a écrit : > On Thu, 21 Aug 2014 11:34:23 +0200 > Romain Francois wrote: > > GK> Yep, sorry for the misuse of language. And I do understand going back to > GK> GetRNGstate() and PutRNGstate() is a bit old school; but I can definitely > GK> confirm that it

Re: [Rcpp-devel] (Very) rare segfault

2014-08-21 Thread Gregor Kastner
On Thu, 21 Aug 2014 11:34:23 +0200 Romain Francois wrote: GK> Yep, sorry for the misuse of language. And I do understand going back to GK> GetRNGstate() and PutRNGstate() is a bit old school; but I can definitely GK> confirm that it seems to be safer than resorting do the GK> constructor/destucto

Re: [Rcpp-devel] (Very) rare segfault

2014-08-21 Thread Romain Francois
Le 20 août 2014 à 20:57, Gregor Kastner a écrit : > JJ> Yes, RNGScope isn't safe by itself. You can use it via attributes (and we > JJ> make sure to use it correctly) or you could use this pattern e.g. if you > JJ> are planning to return a NumericVector: > JJ> > JJ> NumericVector vec(20); //

Re: [Rcpp-devel] (Very) rare segfault

2014-08-20 Thread Gregor Kastner
JJ> Yes, RNGScope isn't safe by itself. You can use it via attributes (and we JJ> make sure to use it correctly) or you could use this pattern e.g. if you JJ> are planning to return a NumericVector: JJ> JJ> NumericVector vec(20); // or whatever size, the important thing is JJ> allocating the ret

Re: [Rcpp-devel] (Very) rare segfault

2014-08-20 Thread William Dunlap
The point of gctorture(TRUE), preferably used with an address-validity checker like valgrind, is that you are alerted the first time you use an address that you did not allocate for your use. With gctorture(FALSE) you are alerted after the n'th bad usage, where n depends on when the garbage collec

Re: [Rcpp-devel] (Very) rare segfault

2014-08-20 Thread Dirk Eddelbuettel
On 20 August 2014 at 20:24, Gregor Kastner wrote: | Thanks to all three of you for your blazing responses. | | > | 1. Try running the code with `gctortue(TRUE)` on, | | Currently running. Extrapolating from the performance I see now I expect the | bug to reappear in <10 years... :) | > | 2. T

Re: [Rcpp-devel] (Very) rare segfault

2014-08-20 Thread Gregor Kastner
Thanks to all three of you for your blazing responses. > | 1. Try running the code with `gctortue(TRUE)` on, Currently running. Extrapolating from the performance I see now I expect the bug to reappear in <10 years... > | 2. Try running with a debugger (gdb, lldb, valgrind), > | 3. Try running w

Re: [Rcpp-devel] (Very) rare segfault

2014-08-20 Thread Dirk Eddelbuettel
On 20 August 2014 at 10:42, Kevin Ushey wrote: | The general prescription is: | | 1. Try running the code with `gctortue(TRUE)` on, | 2. Try running with a debugger (gdb, lldb, valgrind), | 3. Try running with sanitizers (see e.g. Dirk's docker containers: https:// | github.com/eddelbuettel/docke

Re: [Rcpp-devel] (Very) rare segfault

2014-08-20 Thread Kevin Ushey
The general prescription is: 1. Try running the code with `gctortue(TRUE)` on, 2. Try running with a debugger (gdb, lldb, valgrind), 3. Try running with sanitizers (see e.g. Dirk's docker containers: https://github.com/eddelbuettel/docker-ubuntu-r) This should help provide you (and/or us) enough

Re: [Rcpp-devel] (Very) rare segfault

2014-08-20 Thread Romain François
This would be typical gc problems. Could be anywhere. Even if you run it through gdb, the problem will incubate for some time before showing symptoms. We’ve been lucky sometimes to fix some of these by accident, but it is otherwise pretty hard. Romain Le 20 août 2014 à 19:38, Gregor Kastner

[Rcpp-devel] (Very) rare segfault

2014-08-20 Thread Gregor Kastner
Dear all, during a large simulation study on around 300 cores, I have just noticed "strange" behavior of my package depending on Rcpp. "Strange" in the sense that on very rare occasions (around 1 in 10 function calls through .Call), a NumericMatrix object created at C level and returned back t