Skip to content

seemingly random "nesting of readline input" warnings

8 messages · Peter Dalgaard, Roger D. Peng, Luke Tierney +2 more

#
Recently, while using R-patched and now R-1.6.1 (on RedHat Linux 7.1) I've
been getting the following warning in the course of everyday activity:

[... some R activity ...]

In addition: Warning message: 
An unusual circumstance has arisen in the nesting of readline input.
Please report using bug.report()
The warning is difficult to reproduce because it seems to appear at random
times, usually after I enter about 100 or so commands into the console.

I noticed that the function which produces this warning, `pushReadline' in
src/unix/sys-std.c, was modified on October 16, 2002 in regards to bug
report PR#2165.  I can't tell if this change is the source of the warning
bit I don't ever recall seeing this warning on earlier versions.

I build R from source using the readline-devel-4.1-9 package which came
with my system.
_                
platform i686-pc-linux-gnu
arch     i686             
os       linux-gnu        
system   i686, linux-gnu  
status                    
major    1                
minor    6.1              
year     2002             
month    11               
day      01               
language R                


-roger
_______________________________
UCLA Department of Statistics
rpeng@stat.ucla.edu
http://www.stat.ucla.edu/~rpeng

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Roger Peng <rpeng@stat.ucla.edu> writes:
Hmm. We haven't heard that one before... The way this stuff is done,
there's always a risk that you end up with more pushes than pops. As
far as I remember the change, it was a pretty simple index off-by-one
thing, and clearly needed fixing on 64-bit systems, but you never know. 

If you get a bit closer to what exactly you need to do to trigger this
please let us know. It might be something involving non-local returns,
i.e. error conditions or hittin ctr-C. One thing you could do fairly
easily would be to run R with the debugger: "R -d gdb", set a
breakpoint at the warning, and tell us whether it's
ReadlineStack.current that is getting too large or perhaps
ReadlineStack.max getting zeroed by something.
#
Okay, I think I can reproduce this warning:  I startup R --vanilla,
then type Ctrl-C 11 times.  On my machine (RedHat Linux 7.1, Athlon 1.2Ghz
chip) the 11th Ctrl-C produces the warning.  Again, this is R 1.6.1.

When I ran R in gdb I set a break point at line 393 of src/unix/sys-std.c.
It got triggered after the 10th Ctrl-C and when I printed ReadlineStack, I
got

Breakpoint 1, pushReadline (prompt=0x8255dd8 "> ", 
    f=0x813ed70 <readline_handler>) at sys-std.c:393
393          warning("An unusual circumstance has arisen in the nesting of
readline input. Please report using bug.report()");

(gdb) print ReadlineStack
$4 = {current = 9, max = 9, fun = {0x813ed70 <readline_handler>, 
    0x813ed70 <readline_handler>, 0x813ed70 <readline_handler>, 
    0x813ed70 <readline_handler>, 0x813ed70 <readline_handler>, 
    0x813ed70 <readline_handler>, 0x813ed70 <readline_handler>, 
    0x813ed70 <readline_handler>, 0x813ed70 <readline_handler>, 
    0x813ed70 <readline_handler>}}

I hope this helps.

-roger
_______________________________
UCLA Department of Statistics
rpeng@stat.ucla.edu
http://www.stat.ucla.edu/~rpeng
On 2 Nov 2002, Peter Dalgaard BSA wrote:

            
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Roger Peng <rpeng@stat.ucla.edu> writes:
Argh. Yes, the ReadlineStack.current needs to be reset to zero by
something when you break out. A pragmatic temporary fix is to increase
the maximum to be large enough that you don't bump into it this
easily.

Duuuuncan! Come and fix this!
#
On 2 Nov 2002, Peter Dalgaard BSA wrote:

            
Looks like another case where our expedient but unfortunately too
crude approach of handling Control-C on UNIX-likes with longjmp is
biting us.  We really do need to bite the bullet and fix this properly.
Maybe Duncan and I can coordinate getting a handle on this.

luke
1 day later
#
Luke Tierney wrote:

            
please do! It still affects Mosix systems, since the signal handling 
in longjmp causes a system call on the home machine. Mosix tries to 
migrate processes to less-loaded machines, but R's constant setjmp'ing 
means the processes get stuck on the machines where they are started from.

  When I install a new version of R on our mosix cluster, I also compile 
a binary with setjmp/longjmp defined as the versions that do not 
preserve signal state. This produces a binary that migrates better under 
Mosix but has broken Ctrl-C handling. I then alter the R script so that 
my modified binary runs if and only if you do "R BATCH". Seems a fair 
solution at the moment.

  Barry Rowlingson
  Maths and Stats
  Lancaster University

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Luke Tierney wrote:
Done using a local signal handler that pops the readline stack and
then calls the regular handler. This should work for pretty much all
the cases of interest. There are issues with the very unusual cases.

Fix committed to R-devel. (Do we want it also on R-patches?)
Yes, indeed.

  
    
#
Duncan Temple Lang <duncan@research.bell-labs.com> writes:
Eventually, provided it works. Let it ferment in R-devel for a
while till we're sure. Call me paranoid...

Btw, did this fix the noecho-tty-after-exit problem as well?