Pull up following revision(s) (requested by kre in ticket #987):

bin/sh/trap.c: revision 1.44

PR bin/36532 (perhaps)

This is more or less the same patch as provided in the PR
(just 11 years later, so changed a bit) by woods@...

Since there is no known way to actually cause the reported crash,
we may never know if this change actually fixes anything.   But
even if it doesn't it certainly cannot hurt.

There is a potential race which could possibly explain the issue
(see commentary in the PR) which is not easy to avoid - if that is
the actual cause, this should provide a defence, if not really a fix.
This commit is contained in:
martin 2018-08-25 14:41:21 +00:00
parent 29116f7de5
commit 4271cbf17b
1 changed files with 7 additions and 5 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.40.2.1 2017/07/23 14:58:14 snj Exp $ */
/* $NetBSD: trap.c,v 1.40.2.2 2018/08/25 14:41:21 martin Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)trap.c 8.5 (Berkeley) 6/5/95";
#else
__RCSID("$NetBSD: trap.c,v 1.40.2.1 2017/07/23 14:58:14 snj Exp $");
__RCSID("$NetBSD: trap.c,v 1.40.2.2 2018/08/25 14:41:21 martin Exp $");
#endif
#endif /* not lint */
@ -523,9 +523,11 @@ dotrap(void)
savestatus=exitstatus;
CTRACE(DBG_TRAP|DBG_SIG, ("dotrap %d: \"%s\"\n", i,
trap[i] ? trap[i] : "-NULL-"));
tr = savestr(trap[i]); /* trap code may free trap[i] */
evalstring(tr, 0);
ckfree(tr);
if ((tr = trap[i]) != NULL) {
tr = savestr(tr); /* trap code may free trap[i] */
evalstring(tr, 0);
ckfree(tr);
}
exitstatus=savestatus;
}
}