Bug 15013 - segfault on stack exhaustion in stats/model.c StripTerm (triggered by terms.formula)
segfault on stack exhaustion in stats/model.c StripTerm (triggered by terms.f...
Status: RESOLVED FIXED
Product: R
Classification: Unclassified
Component: Misc
R 2.15.1
x86_64/x64/amd64 (64-bit) Linux
: P5 normal
Assigned To: R-core
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-08-10 20:17 UTC by Peng Zhang
Modified: 2012-08-10 23:06 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Peng Zhang 2012-08-10 20:17:24 UTC
I am running R under Arch linux. I found this problem when I tried to debug glmulti package.

Open R
and run "terms(as.formula("h~ X1*X2*X3*X4*X5*X6*X7*X8*X9*X10*X11*X12*X13*X14*X15*X16"))"

Every thing is ok.

Now run the following R code:
#################################
library(glmulti)
testdata = cbind(Y=rnorm(100), data.frame(matrix(rnorm(100*50), ncol = 50)))
showMethods("glmulti")
trace(glmulti, tracer=browser, signature=c(y="formula", xr="missing", data="ANY", exclude="missing"))
glmulti(Y~(X1+X2+X3+X4+X5+X6+X7+X8+X9+X10+X11+X12+X13+X14+X15)*X16, data = testdata, level = 2)
#################################

About 10 steps into debug mode, when you reached 
"neotete = terms(as.formula(paste("h~", paste(preds, collapse = "*"))))"
which would be the initial statement ran in the regular mode, however, would produce a "R segmentation fault".

I am unsure whether the problem is R or glmulti.

Thanks,
Peng

sessionInfo()
R version 2.15.1 (2012-06-22)
Platform: x86_64-unknown-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.utf8       LC_NUMERIC=C             
 [3] LC_TIME=en_US.utf8        LC_COLLATE=en_US.utf8    
 [5] LC_MONETARY=en_US.utf8    LC_MESSAGES=en_US.utf8   
 [7] LC_PAPER=C                LC_NAME=C                
 [9] LC_ADDRESS=C              LC_TELEPHONE=C           
[11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C      

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

$ uname -a
Linux Precision 3.4.7-1-ARCH #1 SMP PREEMPT Sun Jul 29 22:02:56 CEST 2012 x86_64 GNU/Linux
Comment 1 Simon Urbanek 2012-08-10 22:20:54 UTC
This is an example of stack exhaustion in StripTerm because you have too many combination terms for your stack (see the R-devel post). The difference is only the stack size at that point.
Comment 2 Simon Urbanek 2012-08-10 22:24:00 UTC
> terms(as.formula("h~ X1*X2*X3*X4*X5*X6*X7*X8*X9*X10*X11*X12*X13*X14*X15*X16"))

Program received signal SIGSEGV, Segmentation fault.
StripTerm (term=0x185a248, list=0x1994c70) at /data/builds/R-devel/src/library/stats/src/model.c:1270
1270	    R_CheckStack();
(gdb) bt
#0  StripTerm (term=0x185a248, list=0x1994c70) at /data/builds/R-devel/src/library/stats/src/model.c:1270
#1  0x00007ffff3fcce60 in StripTerm (term=0x185a248, list=0x1994c38) at /data/builds/R-devel/src/library/stats/src/model.c:1271
#2  0x00007ffff3fcce60 in StripTerm (term=0x185a248, list=0x1994c00) at /data/builds/R-devel/src/library/stats/src/model.c:1271
[...]

(current R-devel)