zsh-workers
 help / color / mirror / code / Atom feed
* trap handling segfault
@ 2000-06-09 14:02 Clint Adams
  2000-06-09 14:38 ` PATCH: " Clint Adams
  2000-06-09 14:48 ` Bart Schaefer
  0 siblings, 2 replies; 4+ messages in thread
From: Clint Adams @ 2000-06-09 14:02 UTC (permalink / raw)
  To: zsh-workers


The following snippet will cause 3.1.9 to die with a SEGV (in gdb it dumps
at the blank line just before the declaration of periodic(), without gdb
it dumps when periodic is actually called).

I haven't looked at this in depth, but it's dying in endtrapscope()
when it tries to dereference st->list->funcdef (when st->list happens to
be NULL).  Reversing 11736 smoothes things out.


----8<----
function TRAPEXIT ()
{
  /bin/rm -f /tmp/jobs$HOST$$
}


function set-title ()
{
  if [[ "$1" = "-k" ]]
  then
    shift
    KEPT_TITLE="$* "
  else
    TITLE=$*
  fi
  [[ "$TERM" = "xterm" ]] && print -n -D -P "\033]2;${KEPT_TITLE}${TITLE}\007"
}

function accept-line {
  local cmd=${BUFFER%%" "*}
  local oldtitle=$TITLE

  [[ -n "$cmd" ]] && set-title $TITLE "->" $cmd
  TITLE=$oldtitle
  zle .accept-line
}
zle -N accept-line

function periodic () { }
----8<----


^ permalink raw reply	[flat|nested] 4+ messages in thread

* PATCH: trap handling segfault
  2000-06-09 14:02 trap handling segfault Clint Adams
@ 2000-06-09 14:38 ` Clint Adams
  2000-06-09 14:48 ` Bart Schaefer
  1 sibling, 0 replies; 4+ messages in thread
From: Clint Adams @ 2000-06-09 14:38 UTC (permalink / raw)
  To: zsh-workers

This patch doesn't crash the snippet I posted, and it prints
BYE after the script in 11735.  I'm going to commit this under the
assumption that someone with a better understanding  will reverse it
if there are horrible side effects.

Index: signals.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/signals.c,v
retrieving revision 1.6
diff -u -r1.6 signals.c
--- signals.c	2000/06/03 16:26:47	1.6
+++ signals.c	2000/06/09 14:35:34
@@ -853,7 +853,7 @@
 	    if (sigtrapped[sig])
 		unsettrap(sig);
 	    sigtrapped[sig] = st->flags;
-	    if (st->flags) {
+	    if (st->flags && (st->list != NULL)) {
 		Eprog prog = (st->flags & ZSIG_FUNC) ?
 		    ((Shfunc) st->list)->funcdef : (Eprog) st->list;
 		/* prevent settrap from saving this */


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: trap handling segfault
  2000-06-09 14:02 trap handling segfault Clint Adams
  2000-06-09 14:38 ` PATCH: " Clint Adams
@ 2000-06-09 14:48 ` Bart Schaefer
  2000-06-09 14:54   ` Clint Adams
  1 sibling, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2000-06-09 14:48 UTC (permalink / raw)
  To: Clint Adams, zsh-workers

On Jun 9, 10:02am, Clint Adams wrote:
} Subject: trap handling segfault
}
} I haven't looked at this in depth, but it's dying in endtrapscope()
} when it tries to dereference st->list->funcdef (when st->list happens to
} be NULL).  Reversing 11736 smoothes things out.

If you have a compiled shell with 11736 reversed, please try adding a
`setopt localtraps' at the top level (i.e. above `function TRAPEXIT')
in your snippet and then see if it still dumps core.  I don't think
11736 can really be the cause of this crash.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: trap handling segfault
  2000-06-09 14:48 ` Bart Schaefer
@ 2000-06-09 14:54   ` Clint Adams
  0 siblings, 0 replies; 4+ messages in thread
From: Clint Adams @ 2000-06-09 14:54 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

> If you have a compiled shell with 11736 reversed, please try adding a
> `setopt localtraps' at the top level (i.e. above `function TRAPEXIT')
> in your snippet and then see if it still dumps core.  I don't think
> 11736 can really be the cause of this crash.

Tried with both standard 3.1.9 and 3.1.9 minus 11736: the former crashes,
the latter doesn't.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2000-06-09 14:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-06-09 14:02 trap handling segfault Clint Adams
2000-06-09 14:38 ` PATCH: " Clint Adams
2000-06-09 14:48 ` Bart Schaefer
2000-06-09 14:54   ` Clint Adams

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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).