[Rd] Update on "Shift-Return causes segfault (PR#3293)"

John W. Eaton jwe at bevo.che.wisc.edu
Fri Jun 27 13:36:43 MEST 2003

On 27-Jun-2003, Peter Dalgaard BSA <p.dalgaard at biostat.ku.dk> wrote:

| Graeme.Ambler at bristol.ac.uk writes:
| > e) The most helpful error message we can generate is:
| > 
| > Program received signal SIGSEGV, Segmentation fault.
| > 0x400dd7fe in _rl_dispatch_subseq ()
| >    from /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../../libreadline.so.4
| > 
| > implying that there is some strange interaction going on with readline, and 
| > that the bug may be in readline rather than R.
| > 
| > f) The bug does not seem to be present in R-1.6.2, though this is only my 
| > experience, not anyone elses.  Peter Dalgaard HAS reproduced the bug in 
| > R-1.7.0.
| ..and I just now found a SuSE machine still running 1.6.0 which is
| also immune to the problem.

What version of readline is linked to R 1.6.0 on that system?

The function _rl_dispatch_subseq is apparently new in readline 4.3.

When I link my copy of R (1.7.0-2.cran.3 from the Debian package) with
a copy of libreadline-4.3 (built from source obtained from
ftp.gnu.org) and enter M-Shift-O at the prompt, it goes into an
infinite loop:

  export R_HOME=/usr/lib/R
  LD_LIBRARY_PATH=/usr/local/readline/lib:${R_HOME}/bin:/usr/lib/gcc-lib/i386-linux/3.2.3:/usr/lib/gcc-lib/i386-linux/3.2.3/../../..:${R_HOME}/bin:/usr/X11R6/lib:/usr/lib:/usr/lib:/usr/X11R6/lib gdb ${R_HOME}/bin/R.bin
  GNU gdb 5.3-debian
  Copyright 2002 Free Software Foundation, Inc.
  GDB is free software, covered by the GNU General Public License, and you are
  welcome to change it and/or distribute copies of it under certain conditions.
  Type "show copying" to see the conditions.
  There is absolutely no warranty for GDB.  Type "show warranty" for details.
  This GDB was configured as "i386-linux"...(no debugging symbols found)...
  (gdb) r
  Starting program: /usr/lib/R/bin/R.bin 
  (no debugging symbols found)...(no debugging symbols found)...(no debugging symbols found)...
  (no debugging symbols found)...(no debugging symbols found)...(no debugging symbols found)...

  R : Copyright 2003, The R Development Core Team
  Version 1.7.0  (2003-04-16)

  R is free software and comes with ABSOLUTELY NO WARRANTY.
  You are welcome to redistribute it under certain conditions.
  Type `license()' or `licence()' for distribution details.

  R is a collaborative project with many contributors.
  Type `contributors()' for more information.

  Type `demo()' for some demos, `help()' for on-line help, or
  `help.start()' for a HTML browser interface to help.
  Type `q()' to quit R.


<wait a second or two, then interrupt with Control-C>
  Program received signal SIGINT, Interrupt.
  0x4031a691 in _rl_dispatch (key=256, map=0x8e53a30) at ../readline.c:528
  528	{
  (gdb) Quit
  (gdb) where
  #0  0x4031a691 in _rl_dispatch (key=256, map=0x8e53a30) at ../readline.c:528
  #1  0x4031a851 in _rl_dispatch_subseq (key=256, map=0x8e53a30, got_subseq=0) at ../readline.c:570
  #2  0x4031a6ae in _rl_dispatch (key=256, map=0x8e53a30) at ../readline.c:529
  #3  0x4031a851 in _rl_dispatch_subseq (key=256, map=0x8e53a30, got_subseq=0) at ../readline.c:570

(letting it run for a second or so generates thousands of these calls).

Making the following change in readline.c seems to avoid the infinite
loop, but I don't know whether it is the correct fix.

--- readline-4.3/readline.c~	2002-03-13 16:10:46.000000000 -0600
+++ readline-4.3/readline.c	2003-06-27 12:29:50.000000000 -0500
@@ -567,7 +567,7 @@
 	  /* Special case rl_do_lowercase_version (). */
 	  if (func == rl_do_lowercase_version)
-	    return (_rl_dispatch (_rl_to_lower (key), map));
+	    _rl_to_lower (key);
 	  rl_executing_keymap = map;


More information about the R-devel mailing list