Skip to content

[Rcpp-devel] Debug RInside crash

4 messages · Dirk Eddelbuettel, Jose Quesada

#
Hello,

I am invoking some R code using RInside from a
C++ tool. Every time I invoke the code it crashes
randomly. Sometimes even with the same data. It never
crashes when I use R directly.

I am invoking this function DESeq2::DESeq(data) which runs
a set of statistical operaions. It always crashes (when it does)
at this point "mean-dispersion relationship" and the system's log
shows that it always crashes at the same point:

Thread 3 Crashed:: Thread (pooled)
0   locfit.so                      0x00000001229b4b34 atree_grow + 20
(ev_atree.c:92)
1   locfit.so                      0x00000001229b4d06 atree_grow + 486
(ev_atree.c:124)
2   locfit.so                      0x00000001229b4d06 atree_grow + 486
(ev_atree.c:124)
3   locfit.so                      0x00000001229b4d06 atree_grow + 486
(ev_atree.c:124)
4   locfit.so                      0x00000001229b5259 atree_start + 1033
(ev_atree.c:167)
5   locfit.so                      0x00000001229e384d startlf + 1053
(startlf.c:160)
6   locfit.so                      0x00000001229a7147 slocfit + 1335
(S_enter.c:301)
7   libR.dylib                    0x000000010d0ebcd5 do_dotCode + 5973
8   libR.dylib                    0x000000010d1183d9 Rf_eval + 1657
(eval.c:728)

locfit seems to be the R library for local regression fit.

Is there something that I can do to overcome this issue? Why would this
happen
if it never happens when I invoke DESeq from R directly?.

Thanks for the help.

Best,
Jose
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20171213/c3e2677a/attachment.html>
#
On 13 December 2017 at 14:51, Jose wrote:
| Hello,
| 
| I am invoking some R code using RInside from a
| C++ tool. Every time I invoke the code it crashes
| randomly. Sometimes even with the same data. It never
| crashes when I use R directly.
| 
| I am invoking this function DESeq2::DESeq(data) which runs
| a set of statistical operaions. It always crashes (when it does)
| at this point "mean-dispersion relationship" and the system's log
| shows that it always crashes at the same point:
| 
| Thread 3 Crashed:: Thread (pooled)
| 0   locfit.so                      0x00000001229b4b34 atree_grow + 20
| (ev_atree.c:92)
| 1   locfit.so                      0x00000001229b4d06 atree_grow + 486
| (ev_atree.c:124)
| 2   locfit.so                      0x00000001229b4d06 atree_grow + 486
| (ev_atree.c:124)
| 3   locfit.so                      0x00000001229b4d06 atree_grow + 486
| (ev_atree.c:124)
| 4   locfit.so                      0x00000001229b5259 atree_start + 1033
| (ev_atree.c:167)
| 5   locfit.so                      0x00000001229e384d startlf + 1053
| (startlf.c:160)
| 6   locfit.so                      0x00000001229a7147 slocfit + 1335
| (S_enter.c:301)
| 7   libR.dylib                    0x000000010d0ebcd5 do_dotCode + 5973
| 8   libR.dylib                    0x000000010d1183d9 Rf_eval + 1657
| (eval.c:728)
| 
| locfit seems to be the R library for local regression fit.
| 
| Is there something that I can do to overcome this issue?

Create smaller and smaller example that this exhibit the issue?

| Why would this happen if it never happens when I invoke DESeq from R
| directly?.

Maybe locfit does something it is not supposed to do like threading?

Dirk

| Thanks for the help.
| 
| Best,
| Jose
| _______________________________________________
| 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
#
Unfortunately, I have not been able to find any common pattern.
I run it 10 times with the same dataset and It would crash only sometimes.

There's gotta be a race condition most likely related to threading as you
said.

I explicitly tell DESeq to not use multi-threading though but I believe that
doesn't necessarily affect locfit.

Anyways, by digging into DESeq's R code I am able to avoid the potentially
race conditioned part by using a simpler fitting parameter.

So, the behaviour of RInside may be undefined if the R library does
threading?

Thanks for help!

Best,
Jose



2017-12-13 15:31 GMT+01:00 Dirk Eddelbuettel <edd at debian.org>:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20171213/441e155f/attachment.html>
#
On 13 December 2017 at 17:30, Jose wrote:
| So, the behaviour of RInside may be undefined if the R library does
| threading?

As is all (embedded) R code (!!), and that is well documented.

So "maybe" all you need is a mutex.  We can't tell without code.

Dirk