sam-fans - fans of the sam editor
 help / color / mirror / Atom feed
From: mhw@minster.york.ac.uk
To: haertel@ichips.intel.com, sam-fans@hawkwind.utcs.toronto.edu
Cc: bobf@research.att.com
Subject: Re: Sam crash
Date: Sat, 1 Jul 1995 13:18:59 -0400	[thread overview]
Message-ID: <swordfish.804615710@minster.york.ac.uk> (raw)
In-Reply-To: haertel@ichips.intel.com's message, dated Jun 30,  4:17pm

haertel@ichips.intel.com wrote:
> Subject: Sam crash
> 
> Running sam under AIX 3.2, I get a samterm panic from the following
> sequence of commands typed in the command window:
> 
> B /etc/termcap
> ,x/:am/ {
> 	/:am/
> 	/:am/
> 	c/FOO/
> }
> 
> Does anybody else observe this behavior?
> [end of included message]

Yes, I've seen this. What's probably happening is that sam core dumps
and samterm panics because the pipe to sam dries up.

The reason sam core dumps is that there's a bug in the execution of
brace commands in cmdexec() in xec.c. It calls lookup() (in cmd.c) to
get the command number of a command character then uses the returned
value as an index into cmdtab (also in cmd.c). '{' isn't in cmdtab
though so lookup() returns -1 and so the array access looks at a
potentially bad address. A patch to fix this is attached.

I've also had problems with sam core dumping in Fupdate() called from
update() in sam.c. I think there's a dubious piece of code here which
appears to delete() a file and then potentially perform operations on
the free()d memory. A patch to fix this is also attached.

I guess the occurence of these two bugs depends on the malloc
implementation and the compiler you're using. I've been bitten
by them though, and the fixes seem to work for me.

-Mark.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Mark H. Wilkinson <mhw@minster.york.ac.uk>  : Research student in user
University of York, England                 : interface management systems

Index: sam/sam.c
diff -c sam/sam.c:1.3 sam/sam.c:1.4
*** sam/sam.c:1.3	Mon Apr  3 12:07:11 1995
--- sam/sam.c	Wed Apr 12 16:34:40 1995
***************
*** 303,310 ****
  		f = tempfile.filepptr[i];
  		if(f==cmd)	/* cmd gets done in main() */
  			continue;
! 		if(f->deleted)
  			delete(f);
  		if(f->mod==modnum && Fupdate(f, FALSE, downloaded))
  			anymod++;
  		if(f->rasp)
--- 303,312 ----
  		f = tempfile.filepptr[i];
  		if(f==cmd)	/* cmd gets done in main() */
  			continue;
! 		if(f->deleted){
  			delete(f);
+ 			continue;
+ 		}
  		if(f->mod==modnum && Fupdate(f, FALSE, downloaded))
  			anymod++;
  		if(f->rasp)
Index: sam/xec.c
diff -c sam/xec.c:1.1.1.1 sam/xec.c:1.2
*** sam/xec.c:1.1.1.1	Sun Jul 31 17:36:14 1994
--- sam/xec.c	Wed Apr 12 16:36:33 1995
***************
*** 31,37 ****
  	    cp->cmdc!=('c'|0x100) && !(cp->cmdc=='D' && cp->ctext))
  		error(Enofile);
  	i = lookup(cp->cmdc);
! 	if(cmdtab[i].defaddr != aNo){
  		if((ap=cp->addr)==0 && cp->cmdc!='\n'){
  			cp->addr = ap = newaddr();
  			ap->type = '.';
--- 31,37 ----
  	    cp->cmdc!=('c'|0x100) && !(cp->cmdc=='D' && cp->ctext))
  		error(Enofile);
  	i = lookup(cp->cmdc);
! 	if(i >= 0 && cmdtab[i].defaddr != aNo){
  		if((ap=cp->addr)==0 && cp->cmdc!='\n'){
  			cp->addr = ap = newaddr();
  			ap->type = '.';



             reply	other threads:[~1995-07-01 16:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-07-01 17:18 mhw [this message]
  -- strict thread matches above, loose matches on Subject: below --
1995-06-30 20:17 haertel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=swordfish.804615710@minster.york.ac.uk \
    --to=mhw@minster.york.ac.uk \
    --cc=bobf@research.att.com \
    --cc=haertel@ichips.intel.com \
    --cc=sam-fans@hawkwind.utcs.toronto.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).