gcl-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gcl-devel] read-char-no-hang


From: Peter Wood
Subject: Re: [Gcl-devel] read-char-no-hang
Date: Wed, 16 Feb 2005 07:47:44 +0100
User-agent: Mutt/1.4i

Hi again,

As previously reported, the patch fixed the LISTEN bug, however it
seems to have introduced a new one.  When I do (SI::SAVE-SYSTEM
"test") and run ./test I get a segfault.  I commented out one of the
changes from the patch and that seems to have fixed the problem.  Here
is what it looks when I run ./test

Current directory is ~/Projects/gcl-2.6.6/
GNU gdb 6.0
Copyright 2003 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 "i686-pc-linux-gnu"...
(gdb) run
Starting program: /home/prw/Projects/gcl-2.6.6/test 
GCL (GNU Common Lisp)  2.6.6 ANSI    Feb 16 2005 07:24:24
Source License: LGPL(gcl,gmp), GPL(unexec,bfd)
Binary License:  GPL due to GPL'ed components: (READLINE BFD UNEXEC)
Modifications of this banner must retain notice of a compatible license
Dedicated to the memory of W. Schelter

Use (help) to get some basic information on how to use GCL.

>
Program received signal SIGSEGV, Segmentation fault.
0x080d1b91 in rl_getc_em (f=0x401e3540) at gcl_readline.d:286
(gdb) l
281     
282             if (line[linepos]==0) {
283                     free(line);
284                     line = NULL;
285                     linepos = 0;
286                     *rl_line_buffer=0;
287                     return '\n';
288             }
289     
290             return line[linepos++];
(gdb) backtrace
#0  0x080d1b91 in rl_getc_em (f=0x401e3540) at gcl_readline.d:286
#1  0x080b7799 in stream_at_end (strm=0x853f4c8) at file.d:1114
#2  0x08064dae in read_object (in=0x853f45c) at read.d:433
#3  0x08064b73 in read_object_non_recursive (in=0x853f45c) at read.d:257
#4  0x080694ba in Lread () at read.d:2002
#5  0x080aee59 in simple_symlispcall (sym=0x854cdec, base=0x839a424, narg=3)
    at eval.c:658
#6  0x08171c25 in LI1 () at gcl_top.c:130
#7  0x080acba8 in quick_call_sfun (fun=0x853c050) at eval.c:117
#8  0x080ad732 in funcall (fun=0x853c050) at eval.c:178
#9  0x080518f4 in IapplyVector (fun=0x853c050, nargs=0, base=0x839a3fc)
    at nfunlink.c:239
#10 0x080afc0c in fLfuncall (fun=0x853c050) at eval.c:1140
#11 0x080c2cce in c_apply_n (fn=0x80afb7c <fLfuncall>, n=1, x=0x839a3f8)
    at funlink.c:271
#12 0x080517a7 in IapplyVector (fun=0x853ce4c, nargs=1, base=0x839a3f8)
    at nfunlink.c:229
#13 0x080ad7c0 in funcall (fun=0x853ce4c) at eval.c:190
#14 0x080ae1e2 in funcall_no_event (fun=0x853ce4c) at eval.c:381
#15 0x080af96c in eval (form=0x8521640) at eval.c:1092
#16 0x080adef7 in funcall (fun=0x91d3fd8) at eval.c:327
#17 0x080ae1e2 in funcall_no_event (fun=0x930378c) at eval.c:381
#18 0x080af96c in eval (form=0x8521640) at eval.c:1092
#19 0x080adef7 in funcall (fun=0x91d3fe0) at eval.c:327
#20 0x080af0ce in super_funcall (fun=0x9303ff0) at eval.c:743
#21 0x0804b9f9 in main (argc=1, argv=0xbffff994, envp=0xbffff99c) at main.c:369
(gdb) kill
Kill the program being debugged? (y or n) y
(gdb) quit

Debugger finished

I commented out line 286 in gcl_readline.d (rl_line_buffer=0) and
recompiled and that seems to have fixed things.

Regards,
Peter

On Tue, Feb 15, 2005 at 04:16:47PM -0500, Camm Maguire wrote:
> Greetings!
> 
> Please try this patch, which is now posted to the errata page.
> 
> =============================================================================
> diff -ru gcl/h/protoize.h gcl-2.6.6/h/protoize.h
> --- gcl/h/protoize.h  2005-01-16 00:36:20.000000000 +0000
> +++ gcl-2.6.6/h/protoize.h    2005-02-15 16:35:37.000000000 +0000
> @@ -547,6 +547,7 @@
>  
>  
>  /*  readline.d */
> +extern int readline_on;
>  void
>  gcl_init_readline_function(void);
>  
> diff -ru gcl/o/file.d gcl-2.6.6/o/file.d
> --- gcl/o/file.d      2004-05-07 21:48:58.000000000 +0000
> +++ gcl-2.6.6/o/file.d        2005-02-15 17:52:20.000000000 +0000
> @@ -39,6 +39,7 @@
>  #include "include.h"
>  
>  #ifdef HAVE_READLINE
> +#include <readline/readline.h>
>  #define kclgetc(FP)          rl_getc_em(FP)
>  #define kclungetc(C, FP)     rl_ungetc_em(C, FP)
>  #define kclputc(C, FP)               rl_putc_em(C, FP)
> @@ -1210,6 +1211,8 @@
>       case smm_input:
>       case smm_io:
>  
> +       if (readline_on && strm->sm.sm_fp==rl_instream)
> +         return *rl_line_buffer ? TRUE : FALSE;
>  
>               if (strm->sm.sm_fp == NULL)
>                       closed_stream(strm);
> diff -ru gcl/o/gcl_readline.d gcl-2.6.6/o/gcl_readline.d
> --- gcl/o/gcl_readline.d      2004-03-09 02:15:42.000000000 +0000
> +++ gcl-2.6.6/o/gcl_readline.d        2005-02-15 17:51:56.000000000 +0000
> @@ -51,7 +51,7 @@
>  #include <history.h>
>  #endif
>  
> -static int readline_on = 0;          /* On (1) or off (0) */
> +int readline_on = 0;         /* On (1) or off (0) */
>  static int rl_ungetc_em_char = -1;
>  static unsigned char *rl_putc_em_line = NULL;
>  
> @@ -283,6 +283,7 @@
>               free(line);
>               line = NULL;
>               linepos = 0;
> +             *rl_line_buffer=0;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

>               return '\n';
>       }
>  
> =============================================================================
> 
> Your test functions appear to work under readline with these installed
> for me at least.
> 
> Take care,
> 
> James Amundson <address@hidden> writes:
> 
> > On Mon, 2005-02-14 at 10:04, Camm Maguire wrote:
> > > Greetings!
> > 
> > Thanks for looking into this.
> > 
> > > I can't reproduce this, but rather get:
> > 
> > On my system, read-char-no-hang and listen always return nil. I attached
> > my output from foo and foo2 to the end of this message. I'm afraid it
> > must be a gcc and/or libc issue. Here are my versions:
> > 
> > |abacus3>gcc --version
> > gcc (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-42)
> > Copyright (C) 2002 Free Software Foundation, Inc.
> > This is free software; see the source for copying conditions.  There is
> > NO
> > warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
> > PURPOSE.
> > 
> > |abacus3>/lib/libc.so.6 --version
> > GNU C Library stable release version 2.3.2, by Roland McGrath et al.
> > Copyright (C) 2003 Free Software Foundation, Inc.
> > This is free software; see the source for copying conditions.
> > There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
> > PARTICULAR PURPOSE.
> > Compiled by GNU CC version 3.2.3 20030502 (Red Hat Linux 3.2.3-42).
> > Compiled on a Linux 2.4.20 system on 2004-12-20.
> > Available extensions:
> >         GNU libio by Per Bothner
> >         crypt add-on version 2.1 by Michael Glad and others
> >         linuxthreads-0.10 by Xavier Leroy
> >         The C stubs add-on version 2.1.2.
> >         BIND-8.2.3-T5B
> >         NIS(YP)/NIS+ NSS modules 0.19 by Thorsten Kukuk
> >         Glibc-2.0 compatibility add-on by Cristian Gafton
> >         libthread_db work sponsored by Alpha Processor Inc
> > Thread-local storage support included.
> > For bug reporting instructions, please see:
> > <http://www.gnu.org/software/libc/bugs.html>.
> > 
> > I'm not sure what debugging steps to try next. I tried to understand how
> > read-char-no-hang and listen are implemented in the gcl source, but I
> > couldn't see it. Any pointers?      
> > 
> > Thanks,
> > Jim
> > 
> > P.S.
> > 
> > GCL (GNU Common Lisp)  2.6.6 ANSI    Feb 14 2005 21:03:12
> > Source License: LGPL(gcl,gmp), GPL(unexec,bfd)
> > Binary License:  GPL due to GPL'ed components: (READLINE BFD UNEXEC)
> > Modifications of this banner must retain notice of a compatible license
> > Dedicated to the memory of W. Schelter
> > 
> > Use (help) to get some basic information on how to use GCL.
> > 
> > >(defun foo ()
> >   (format t "normal: '~a'~%" (read-char))
> >   (format t "normal: '~a'~%" (read-char))
> >   (format t "no-hang: '~a'~%" (read-char-no-hang))
> >   (format t "normal: '~a'~%" (read-char))
> >   (read-line))
> > 
> > FOO
> > 
> > >(foo)
> > normal: '
> > '
> > abcde
> > normal: 'a'
> > no-hang: 'NIL'
> > normal: 'b'
> > "cde"
> > NIL
> > 
> > >(defun foo2 ()
> >   (do ()
> >       ((not (listen)))
> >     (read-char-no-hang))
> >   (foo))
> > 
> > FOO2
> > 
> > >(foo2)
> > normal: '
> > '
> > abcdef
> > normal: 'a'
> > no-hang: 'NIL'
> > normal: 'b'
> > "cdef"
> > NIL
> > 
> > >
> > 
> > 
> > 
> > 
> > 
> 
> -- 
> Camm Maguire                                          address@hidden
> ==========================================================================
> "The earth is but one country, and mankind its citizens."  --  Baha'u'llah




reply via email to

[Prev in Thread] Current Thread [Next in Thread]