Skip to content

segmentation fault in integrate (PR#812)

4 messages · Achim Zeileis, Torsten Hothorn, Brian Ripley +1 more

#
I tried to integrate numerically a function wich is similar to the
following:
[1] 0
[1] NaN
[1] NaN

If I choose the lower boundary to be too small integrate causes a
segmentation fault:
[1] 1.387143
[1] NaN
Warning message:
Ifail=1, maxpts was too small. Check the returned relerr! in: adapt(1,
lower, upper, minpts, maxpts, functn, eps, ...)
Segmentation fault

I'm running R.1.2.0 on Debian Linux.

Regards
Achim
_                
platform i686-pc-linux-gnu
arch     i686             
os       linux-gnu        
system   i686, linux-gnu  
status                    
major    1                
minor    2.0              
year     2000             
month    12               
day      15               
language R   



-------------------------

Achim Zeileis
Institut für Statistik
Technische Universität Wien

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Running Version 1.2.0 Patched (2001-01-07) and integrate Version  2.2-3
on SuSE 6.4 gives:
[1] NaN
Warning message: 
Ifail=1, maxpts was too small. Check the returned relerr! in: adapt(1,
lower, upper, minpts, maxpts, functn, eps, ...) 

I has not able to reproduce the segfault ;-)

BTW: if one uses
a) }

this returns
[1] 1.387143
[1] 0.6935715

Torsten
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Fri, 12 Jan 2001, Torsten Hothorn wrote:

            
Better, try

dummy <- function(x) { exp(-1*x + dnorm(x, log=TRUE))}

that is, do your calculations on log scale as far as possible.  This is
more accurate than cop-ing out at Inf*0.

Even better, you can adjust the normal mean to cancel the linear term
exactly: dnorm(x, mu) has linear term -mu*x. So use

dummy <- function(x) exp(0.5)*dnorm(x, -1)

You will still need to adjust maxpts or find a sensible lower end.

(BTW, I don't get a segfault either, and we need you to debug it
on your system, I am afraid.)
#
Prof Brian D Ripley wrote:
But crashes also on:
- NT4.0, R-1.2.0
- sparc-sun-solaris2.7, R-1.2.0
- SuSE 7.0, R-1.2.0 Patched (2001-01-07), integrate Version  2.2-3

Strange: With the same version of R-1.2.0 Patched (2001-01-07) and
integrate (2.2-3), the crash happens on SuSE 7.0, but not on SuSE 6.4,
as Torsten told us.

Uwe
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._