Windows crash in confint() with nls fit (PR#8428)

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Windows crash in confint() with nls fit (PR#8428)

Ben Bolker-2
Full_Name: Ben Bolker
Version: 2.2.1
OS: Windows XP and 2000
Submission from: (NULL) (128.227.60.124)


  The following code, using confint() to try
to get confidence intervals on an nls object
that has been fitted with algorithm="port"
reliably crashes R 2.2.0 and 2.2.1 with the
latest version of MASS on a Windows 2000 and
a Windows XP machine here.  I *think* earlier
versions of MASS may not have crashed, but
I have now updated the versions on most of
my machines and don't have a test version handy.

 On XP, I get an error-report-do-you-want-
to-send-this-to-Microsoft dialog box.  On 2000
I get a "Rgui has generated errors ..." dialog box.

  I can get this far:

debug: profiledModel <- .Call("nls_iter", fittedModel, ctrl, trace,
    PACKAGE = "stats")

Browse[1]> where
where 1: prof$getProfile()
where 2: profile.nls(object, which = parm, alphamax = (1 - level)/4)
where 3: profile(object, which = parm, alphamax = (1 - level)/4)
where 4: confint.nls(n1)
where 5: confint(n1)

  I'm not set up to debug compiled code on Windows, and I haven't
been able to reproduce the problem on Linux.

set.seed(1001)
x = runif(200)
a =1
b = 1
c = -0.1
y = a+b*x+c*x^2+rnorm(200,sd=0.05)
plot(x,y)
curve(a+b*x+c*x^2,add=TRUE)
n1 = nls(y~a+b*x+c*I(x^2),start=c(a=1,b=1,c=0.1),algorithm="port")
confint(n1)  ## boom

  N.B.: It only crashes if algorithm="port" is specified.

## [1] "Windows 2000 Professional (build 2195) Service Pack 4.0"
##
## > R.version
##          _              
## platform i386-pc-mingw32
## arch     i386          
## os       mingw32        
## system   i386, mingw32  
## status                  
## major    2              
## minor    2.0            
## year     2005          
## month    10            
## day      06            
## svn rev  35749          
## language R        
##    
## MASS
##                      
## Version:             7.2-23
## Date:                2005-12-08
##
##  

##  "Windows XP Professional (build 2600) Service Pack 2.0"
      ##               _              
##platform i386-pc-mingw32
##arch     i386          
##os       mingw32        
##system   i386, mingw32  
##status                  
##major    2              
##minor    2.0            
##year     2005          
##month    10            
##day      06            
##svn rev  35749          
##language R        

##
##Version:             7.2-23
##Date:                2005-12-08      ## CRASH
   
##> R.version
##         _              
##platform i386-pc-mingw32
##arch     i386          
##os       mingw32        
##system   i386, mingw32  
##status                  
##major    2              
##minor    2.1            
##year     2005          
##month    12            
##day      20            
##svn rev  36812          
##language R        
## CRASH

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Windows crash in confint() with nls fit (PR#8428)

Duncan Murdoch
On 12/22/2005 1:23 PM, [hidden email] wrote:

> Full_Name: Ben Bolker
> Version: 2.2.1
> OS: Windows XP and 2000
> Submission from: (NULL) (128.227.60.124)
>
>
>   The following code, using confint() to try
> to get confidence intervals on an nls object
> that has been fitted with algorithm="port"
> reliably crashes R 2.2.0 and 2.2.1 with the
> latest version of MASS on a Windows 2000 and
> a Windows XP machine here.  I *think* earlier
> versions of MASS may not have crashed, but
> I have now updated the versions on most of
> my machines and don't have a test version handy.
>
>  On XP, I get an error-report-do-you-want-
> to-send-this-to-Microsoft dialog box.  On 2000
> I get a "Rgui has generated errors ..." dialog box.
>
>   I can get this far:
>
> debug: profiledModel <- .Call("nls_iter", fittedModel, ctrl, trace,
>     PACKAGE = "stats")
>
> Browse[1]> where
> where 1: prof$getProfile()
> where 2: profile.nls(object, which = parm, alphamax = (1 - level)/4)
> where 3: profile(object, which = parm, alphamax = (1 - level)/4)
> where 4: confint.nls(n1)
> where 5: confint(n1)
>
>   I'm not set up to debug compiled code on Windows, and I haven't
> been able to reproduce the problem on Linux.

I see it in R-devel too.  It's in a strcmp; I'll see if I can track down
the cause.

Duncan Murdoch

>
> set.seed(1001)
> x = runif(200)
> a =1
> b = 1
> c = -0.1
> y = a+b*x+c*x^2+rnorm(200,sd=0.05)
> plot(x,y)
> curve(a+b*x+c*x^2,add=TRUE)
> n1 = nls(y~a+b*x+c*I(x^2),start=c(a=1,b=1,c=0.1),algorithm="port")
> confint(n1)  ## boom
>
>   N.B.: It only crashes if algorithm="port" is specified.
>
> ## [1] "Windows 2000 Professional (build 2195) Service Pack 4.0"
> ##
> ## > R.version
> ##          _              
> ## platform i386-pc-mingw32
> ## arch     i386          
> ## os       mingw32        
> ## system   i386, mingw32  
> ## status                  
> ## major    2              
> ## minor    2.0            
> ## year     2005          
> ## month    10            
> ## day      06            
> ## svn rev  35749          
> ## language R        
> ##    
> ## MASS
> ##                      
> ## Version:             7.2-23
> ## Date:                2005-12-08
> ##
> ##  
>
> ##  "Windows XP Professional (build 2600) Service Pack 2.0"
>       ##               _              
> ##platform i386-pc-mingw32
> ##arch     i386          
> ##os       mingw32        
> ##system   i386, mingw32  
> ##status                  
> ##major    2              
> ##minor    2.0            
> ##year     2005          
> ##month    10            
> ##day      06            
> ##svn rev  35749          
> ##language R        
>
> ##
> ##Version:             7.2-23
> ##Date:                2005-12-08      ## CRASH
>    
> ##> R.version
> ##         _              
> ##platform i386-pc-mingw32
> ##arch     i386          
> ##os       mingw32        
> ##system   i386, mingw32  
> ##status                  
> ##major    2              
> ##minor    2.1            
> ##year     2005          
> ##month    12            
> ##day      20            
> ##svn rev  36812          
> ##language R        
> ## CRASH
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Windows crash in confint() with nls fit (PR#8428)

Duncan Murdoch
In reply to this post by Ben Bolker-2
I've found the problem, but someone who knows more about nls() will have
to fix it.

The problem is that in the demo code below, n1 ends up being an nls
object, but n1$call$control is NULL.  profiler.nls() assumed that the
nls object passed to it has a non-NULL element there, and doesn't check.

I've fixed the code so now it doesn't crash, but it now dies with this
error instead:

 > confint(n1)  ## boom
Waiting for profiling to be done...
Error in prof$getProfile() : 'control$maxiter' absent

I'll commmit my change to R-devel and R-patched shortly.

Duncan Murdoch





On 12/22/2005 1:23 PM, [hidden email] wrote:

> Full_Name: Ben Bolker
> Version: 2.2.1
> OS: Windows XP and 2000
> Submission from: (NULL) (128.227.60.124)
>
>
>   The following code, using confint() to try
> to get confidence intervals on an nls object
> that has been fitted with algorithm="port"
> reliably crashes R 2.2.0 and 2.2.1 with the
> latest version of MASS on a Windows 2000 and
> a Windows XP machine here.  I *think* earlier
> versions of MASS may not have crashed, but
> I have now updated the versions on most of
> my machines and don't have a test version handy.
>
>  On XP, I get an error-report-do-you-want-
> to-send-this-to-Microsoft dialog box.  On 2000
> I get a "Rgui has generated errors ..." dialog box.
>
>   I can get this far:
>
> debug: profiledModel <- .Call("nls_iter", fittedModel, ctrl, trace,
>     PACKAGE = "stats")
>
> Browse[1]> where
> where 1: prof$getProfile()
> where 2: profile.nls(object, which = parm, alphamax = (1 - level)/4)
> where 3: profile(object, which = parm, alphamax = (1 - level)/4)
> where 4: confint.nls(n1)
> where 5: confint(n1)
>
>   I'm not set up to debug compiled code on Windows, and I haven't
> been able to reproduce the problem on Linux.
>
> set.seed(1001)
> x = runif(200)
> a =1
> b = 1
> c = -0.1
> y = a+b*x+c*x^2+rnorm(200,sd=0.05)
> plot(x,y)
> curve(a+b*x+c*x^2,add=TRUE)
> n1 = nls(y~a+b*x+c*I(x^2),start=c(a=1,b=1,c=0.1),algorithm="port")
> confint(n1)  ## boom
>
>   N.B.: It only crashes if algorithm="port" is specified.
>
> ## [1] "Windows 2000 Professional (build 2195) Service Pack 4.0"
> ##
> ## > R.version
> ##          _              
> ## platform i386-pc-mingw32
> ## arch     i386          
> ## os       mingw32        
> ## system   i386, mingw32  
> ## status                  
> ## major    2              
> ## minor    2.0            
> ## year     2005          
> ## month    10            
> ## day      06            
> ## svn rev  35749          
> ## language R        
> ##    
> ## MASS
> ##                      
> ## Version:             7.2-23
> ## Date:                2005-12-08
> ##
> ##  
>
> ##  "Windows XP Professional (build 2600) Service Pack 2.0"
>       ##               _              
> ##platform i386-pc-mingw32
> ##arch     i386          
> ##os       mingw32        
> ##system   i386, mingw32  
> ##status                  
> ##major    2              
> ##minor    2.0            
> ##year     2005          
> ##month    10            
> ##day      06            
> ##svn rev  35749          
> ##language R        
>
> ##
> ##Version:             7.2-23
> ##Date:                2005-12-08      ## CRASH
>    
> ##> R.version
> ##         _              
> ##platform i386-pc-mingw32
> ##arch     i386          
> ##os       mingw32        
> ##system   i386, mingw32  
> ##status                  
> ##major    2              
> ##minor    2.1            
> ##year     2005          
> ##month    12            
> ##day      20            
> ##svn rev  36812          
> ##language R        
> ## CRASH
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Windows crash in confint() with nls fit (PR#8428)

Ben Bolker-2
In reply to this post by Ben Bolker-2
Duncan Murdoch wrote:

> I've found the problem, but someone who knows more about nls() will have
> to fix it.
>
> The problem is that in the demo code below, n1 ends up being an nls
> object, but n1$call$control is NULL.  profiler.nls() assumed that the
> nls object passed to it has a non-NULL element there, and doesn't check.
>
> I've fixed the code so now it doesn't crash, but it now dies with this
> error instead:
>
>  > confint(n1)  ## boom
> Waiting for profiling to be done...
> Error in prof$getProfile() : 'control$maxiter' absent
>
> I'll commmit my change to R-devel and R-patched shortly.
>
> Duncan Murdoch
>

   thank you for the quick response!

    actually, I discovered I'm wrong -- bug affects Linux as well,
gives a segmentation fault
(I must have tried it without the algorithm="port" argument by
accident.)  I've looked at the code but I regretfully concur
that someone else will have to work on this -- I can hack nls
so it reinserts a "control" element in n1$call, but $tol
and $minFactor are explicitly deleted from the control list,
and so we only get one step farther.  I don't know what assumptions
nls_iter is really making and whether it's safe to make them
when the port algorithm is being used or not ...

   My best guess at this point, poking around, is that profiler.nls
in src/library/stats/R/nls-profile.R has to be changed in parallel
with nls to call port_nlsb instead of nls_iter when the port
algorithm is being used, but this is all getting a bit deep for
me ...

    Ben

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Windows crash in confint() with nls fit (PR#8428)

P Ehlers
You don't actually need Ben's example. The problem occurs
also for the first example in ?nls if algorithm = "port" is
used.

Peter Ehlers

[hidden email] wrote:

> Duncan Murdoch wrote:
>
>>I've found the problem, but someone who knows more about nls() will have
>>to fix it.
>>
>>The problem is that in the demo code below, n1 ends up being an nls
>>object, but n1$call$control is NULL.  profiler.nls() assumed that the
>>nls object passed to it has a non-NULL element there, and doesn't check.
>>
>>I've fixed the code so now it doesn't crash, but it now dies with this
>>error instead:
>>
>> > confint(n1)  ## boom
>>Waiting for profiling to be done...
>>Error in prof$getProfile() : 'control$maxiter' absent
>>
>>I'll commmit my change to R-devel and R-patched shortly.
>>
>>Duncan Murdoch
>>
>
>
>    thank you for the quick response!
>
>     actually, I discovered I'm wrong -- bug affects Linux as well,
> gives a segmentation fault
> (I must have tried it without the algorithm="port" argument by
> accident.)  I've looked at the code but I regretfully concur
> that someone else will have to work on this -- I can hack nls
> so it reinserts a "control" element in n1$call, but $tol
> and $minFactor are explicitly deleted from the control list,
> and so we only get one step farther.  I don't know what assumptions
> nls_iter is really making and whether it's safe to make them
> when the port algorithm is being used or not ...
>
>    My best guess at this point, poking around, is that profiler.nls
> in src/library/stats/R/nls-profile.R has to be changed in parallel
> with nls to call port_nlsb instead of nls_iter when the port
> algorithm is being used, but this is all getting a bit deep for
> me ...
>
>     Ben
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

--
Peter Ehlers
Department of Mathematics and Statistics
University of Calgary

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Windows crash in confint() with nls fit (PR#8428)

Prof Brian Ripley
In reply to this post by Duncan Murdoch
Actually, only the default algorithm is supported: algorithm="plinear" is
broken too.  I've just added a check for the default algorithm in
R-patched, as the fix is better done on the R-devel code base (which
supports weights).

On Thu, 22 Dec 2005 [hidden email] wrote:

> I've found the problem, but someone who knows more about nls() will have
> to fix it.
>
> The problem is that in the demo code below, n1 ends up being an nls
> object, but n1$call$control is NULL.  profiler.nls() assumed that the
> nls object passed to it has a non-NULL element there, and doesn't check.
>
> I've fixed the code so now it doesn't crash, but it now dies with this
> error instead:
>
> > confint(n1)  ## boom
> Waiting for profiling to be done...
> Error in prof$getProfile() : 'control$maxiter' absent
>
> I'll commmit my change to R-devel and R-patched shortly.
>
> Duncan Murdoch
>
>
>
>
>
> On 12/22/2005 1:23 PM, [hidden email] wrote:
>> Full_Name: Ben Bolker
>> Version: 2.2.1
>> OS: Windows XP and 2000
>> Submission from: (NULL) (128.227.60.124)
>>
>>
>>   The following code, using confint() to try
>> to get confidence intervals on an nls object
>> that has been fitted with algorithm="port"
>> reliably crashes R 2.2.0 and 2.2.1 with the
>> latest version of MASS on a Windows 2000 and
>> a Windows XP machine here.  I *think* earlier
>> versions of MASS may not have crashed, but
>> I have now updated the versions on most of
>> my machines and don't have a test version handy.
>>
>>  On XP, I get an error-report-do-you-want-
>> to-send-this-to-Microsoft dialog box.  On 2000
>> I get a "Rgui has generated errors ..." dialog box.
>>
>>   I can get this far:
>>
>> debug: profiledModel <- .Call("nls_iter", fittedModel, ctrl, trace,
>>     PACKAGE = "stats")
>>
>> Browse[1]> where
>> where 1: prof$getProfile()
>> where 2: profile.nls(object, which = parm, alphamax = (1 - level)/4)
>> where 3: profile(object, which = parm, alphamax = (1 - level)/4)
>> where 4: confint.nls(n1)
>> where 5: confint(n1)
>>
>>   I'm not set up to debug compiled code on Windows, and I haven't
>> been able to reproduce the problem on Linux.
>>
>> set.seed(1001)
>> x = runif(200)
>> a =1
>> b = 1
>> c = -0.1
>> y = a+b*x+c*x^2+rnorm(200,sd=0.05)
>> plot(x,y)
>> curve(a+b*x+c*x^2,add=TRUE)
>> n1 = nls(y~a+b*x+c*I(x^2),start=c(a=1,b=1,c=0.1),algorithm="port")
>> confint(n1)  ## boom
>>
>>   N.B.: It only crashes if algorithm="port" is specified.
>>
>> ## [1] "Windows 2000 Professional (build 2195) Service Pack 4.0"
>> ##
>> ## > R.version
>> ##          _
>> ## platform i386-pc-mingw32
>> ## arch     i386
>> ## os       mingw32
>> ## system   i386, mingw32
>> ## status
>> ## major    2
>> ## minor    2.0
>> ## year     2005
>> ## month    10
>> ## day      06
>> ## svn rev  35749
>> ## language R
>> ##
>> ## MASS
>> ##
>> ## Version:             7.2-23
>> ## Date:                2005-12-08
>> ##
>> ##
>>
>> ##  "Windows XP Professional (build 2600) Service Pack 2.0"
>>       ##               _
>> ##platform i386-pc-mingw32
>> ##arch     i386
>> ##os       mingw32
>> ##system   i386, mingw32
>> ##status
>> ##major    2
>> ##minor    2.0
>> ##year     2005
>> ##month    10
>> ##day      06
>> ##svn rev  35749
>> ##language R
>>
>> ##
>> ##Version:             7.2-23
>> ##Date:                2005-12-08      ## CRASH
>>
>> ##> R.version
>> ##         _
>> ##platform i386-pc-mingw32
>> ##arch     i386
>> ##os       mingw32
>> ##system   i386, mingw32
>> ##status
>> ##major    2
>> ##minor    2.1
>> ##year     2005
>> ##month    12
>> ##day      20
>> ##svn rev  36812
>> ##language R
>> ## CRASH
>>
>> ______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>

--
Brian D. Ripley,                  [hidden email]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel