Hi!
----
I'm getting the following "valgrind" hit (note that "valgrind"
requires the patch from
http://lists.research.att.com/pipermail/ast-developers/2013q2/002574.html)
with ast-ksh.2013-06-28 in an interactive shell session (locale is
"en_US.UTF-8") when I it with a non-empty history file and press
<enter> and then <backspace>:
-- snip --
$ ENV=/./nosuchfile ~/vg/bin/valgrind ~/bin/ksh -o emacs -o multiline
$ ==31606== Invalid read of size 4
==31606== at 0x477AE9: draw (emacs.c:1405)
==31606== by 0x475BDD: ed_emacsread (emacs.c:519)
==31606== by 0x426EC7: slowread (io.c:2408)
==31606== by 0x506537: sfrd (sfrd.c:259)
==31606== by 0x4FF332: _sffilbuf (sffilbuf.c:105)
==31606== by 0x5073FB: sfreserve (sfreserve.c:148)
==31606== by 0x40F12B: exfile (main.c:550)
==31606== by 0x40E72C: sh_main (main.c:375)
==31606== by 0x40D900: main (pmain.c:45)
==31606== Address 0x58f9b1c is 4 bytes before a block of size 65,537 alloc'd
==31606== at 0x4C29C83: _ast_malloc (vg_replace_malloc.c:1000)
==31606== by 0x420FF2: sh_iostream (io.c:553)
==31606== by 0x420C47: sh_ioinit (io.c:465)
==31606== by 0x41CB0D: sh_init (init.c:1552)
==31606== by 0x40DA68: sh_main (main.c:146)
==31606== by 0x40D900: main (pmain.c:45)
==31606==
-- snip --
The same happens in "vi"-mode, too:
-- snip --
$ ENV=/./nosuchfile ~/vg/bin/valgrind ~/bin/ksh -o vi -o multiline
$ ==31620== Invalid read of size 4
==31620== at 0x47A86E: getline (vi.c:1463)
==31620== by 0x4786AC: ed_viread (vi.c:585)
==31620== by 0x426EC7: slowread (io.c:2408)
==31620== by 0x506537: sfrd (sfrd.c:259)
==31620== by 0x4FF332: _sffilbuf (sffilbuf.c:105)
==31620== by 0x5073FB: sfreserve (sfreserve.c:148)
==31620== by 0x40F12B: exfile (main.c:550)
==31620== by 0x40E72C: sh_main (main.c:375)
==31620== by 0x40D900: main (pmain.c:45)
==31620== Address 0x58f9b1c is 4 bytes before a block of size 65,537 alloc'd
==31620== at 0x4C29C83: _ast_malloc (vg_replace_malloc.c:1000)
==31620== by 0x420FF2: sh_iostream (io.c:553)
==31620== by 0x420C47: sh_ioinit (io.c:465)
==31620== by 0x41CB0D: sh_init (init.c:1552)
==31620== by 0x40DA68: sh_main (main.c:146)
==31620== by 0x40D900: main (pmain.c:45)
==31620==
-- snip --
Attached (as
"astksh20130628_interactive_valgrind_enter_backspace_hit001.diff.txt")
is a patch which fixes these issues and renames |getline()| in
src/cmd/ksh93/edit/vi.c since the symbol name is a libc and libast
function and there is a naming collision which some compiler/linker
combinations dislike...
----
Bye,
Roland
--
__ . . __
(o.\ \/ /.o) [email protected]
\__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
/O /==\ O\ TEL +49 641 3992797
(;O/ \/ \O;)
diff -r -u build_i386_64bit_debug/src/cmd/ksh93/edit/emacs.c
build_i386_64bit_debug_dgksigfix1/src/cmd/ksh93/edit/emacs.c
--- src/cmd/ksh93/edit/emacs.c 2013-05-31 19:53:56.000000000 +0200
+++ src/cmd/ksh93/edit/emacs.c 2013-07-11 11:40:18.888213615 +0200
@@ -1401,8 +1401,13 @@
Then output the character and adjust the screen only.
*****************************************/
-
- i = *(logcursor-1); /* last character inserted */
+ if (logcursor==sptr)
+ {
+ /* We're at the beginning and nothing has been entered yet */
+ i = '\0';
+ }
+ else
+ i = *(logcursor-1); /* last character inserted */
#if SHOPT_EDPREDICT
if(option==FINAL)
{
diff -r -u build_i386_64bit_debug/src/cmd/ksh93/edit/vi.c
build_i386_64bit_debug_dgksigfix1/src/cmd/ksh93/edit/vi.c
--- src/cmd/ksh93/edit/vi.c 2013-05-31 20:22:36.000000000 +0200
+++ src/cmd/ksh93/edit/vi.c 2013-07-11 11:25:33.223939260 +0200
@@ -185,7 +185,7 @@
static void cursor(Vi_t*, int);
static void del_line(Vi_t*,int);
static int getcount(Vi_t*,int);
-static void getline(Vi_t*,int);
+static void vigetline(Vi_t*,int);
static int getrchar(Vi_t*);
static int mvcursor(Vi_t*,int);
static void pr_string(Vi_t*,const char*);
@@ -582,11 +582,11 @@
refresh(vp,INPUT);
}
if(viraw)
- getline(vp,APPEND);
+ vigetline(vp,APPEND);
else if(last_virt>=0 && virtual[last_virt]==term_char)
- getline(vp,APPEND);
+ vigetline(vp,APPEND);
else
- getline(vp,ESC);
+ vigetline(vp,ESC);
if(vp->ed->e_multiline)
cursor(vp, last_phys);
/*** add a new line if user typed unescaped \n ***/
@@ -1341,7 +1341,7 @@
}
-/*{ GETLINE( mode )
+/*{ VIGETLINE( mode )
*
* This routine will fetch a line.
* mode = APPEND, allow escape to cntlmode subroutine
@@ -1359,7 +1359,7 @@
*
}*/
-static void getline(register Vi_t* vp,register int mode)
+static void vigetline(register Vi_t* vp,register int mode)
{
register int c;
register int tmp;
@@ -1460,7 +1460,7 @@
/*** treat as backspace ***/
case '\b': /** backspace **/
- if( virtual[cur_virt] == '\\' )
+ if( cur_virt >= 0 && virtual[cur_virt] == '\\' )
{
cdelete(vp,1, BAD);
append(vp,usrerase, mode);
@@ -2230,7 +2230,7 @@
append(vp,mode, APPEND);
refresh(vp,INPUT);
first_virt = 1;
- getline(vp,SEARCH);
+ vigetline(vp,SEARCH);
first_virt = 0;
virtual[last_virt + 1] = '\0'; /*** make null terminated ***/
vp->direction = mode=='/' ? -1 : 1;
_______________________________________________
ast-developers mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-developers