[R] debug an error that incapacitates R?

Duncan Murdoch murdoch at stats.uwo.ca
Sun Dec 13 12:12:16 CET 2009


On 13/12/2009 5:31 AM, Liviu Andronic wrote:
> Dear all
> How should I attempt debugging this error?
>> sosInit()
> Error: invalid connection
> 
> When this happens R refuses to run anything:
>> 2+2
> Error: invalid connection
>> sessionInfo ()
> Error in stdout() : invalid connection
> 
> 
> Debugging it seems impossible.
>> options(error=recover)
>> sosInit()
> Error: invalid connection
> Error during wrapup: invalid connection
> 
> 
> The error also "crashes" browser().
> Browse[1]> n
> debug at /home/liviu/Devel/Rcmdr-dev/Rcmdr.sos/RcmdrPlugin.sos-0.1-0/R/sosInit.R#51:
> doItAndPrint(paste("## Launching RSiteSearch, please be patient.."))
> Browse[2]>
> Error in function ()  : invalid connection
> Error: invalid connection
> 
> To reproduce the example, you would need to source the following file [1]. Then
> require(Rcmdr)
> require(sos)
> sosInit()
> 
> and in the box enter a string similar to "asdf ; HTMLgrid". If you
> enter simple strings such as "asdf", the function will perform as
> expected and R will not become non-responsive.
> [1] http://s000.tinyupload.com/index.php?file_id=15379960405416742593
> 
> Please let me know of any ideas that would help tackle this one. Thank you

I think you need to go back to old-fashioned debugging methods. 
Identify the line the triggers the error, by using debug() and single 
stepping through sosInit(), or by adding print() or cat() statements to 
it (or setting tracepoints with trace()), and seeing how many succeed 
before things go bad.

Once you see the bad line, it may be obvious what's wrong with it, or 
you may need to ask for help, by putting together a minimal example that 
triggers it.

Duncan Murdoch




More information about the R-help mailing list