David, I attached a patch from Roland, which prevents a crash when a
fatal errormsg() is called during shell start up, like an out of
memory condition. This can happen if errormsg() forces an abort while
the Shell_t is not fully initialized. The patch prevents a core dump.

Olga
-- 
      ,   _                                    _   ,
     { \/`o;====-    Olga Kryzhanovska   -====;o`\/ }
.----'-/`-/     olga.kryzhanov...@gmail.com   \-`\-'----.
 `'-..-| /       http://twitter.com/fleyta     \ |-..-'`
      /\/\     Solaris/BSD//C/C++ programmer   /\/\
      `--`                                      `--`
--- src/cmd/ksh93/sh/fault.c	2012-09-08 01:58:48.000000000 +0200
+++ src/cmd/ksh93/sh/fault.c	2012-09-22 05:46:35.733792652 +0200
@@ -426,6 +426,8 @@
 			sh_exit(shp,shp->exitval);
 		}
 	}
+	if (!shp->sigflag)
+		return;
 	if(shp->sigflag[SIGALRM]&SH_SIGALRM)
 		sh_timetraps(shp);
 	if((shp->sigflag[SIGCHLD]&SH_SIGTRAP) && shp->st.trapcom[SIGCHLD])
@@ -570,7 +572,7 @@
 		savxit = SH_EXITSIG|sig;
 	if(shp->userinit)
 		(*shp->userinit)(shp, -1);
-	if(t=shp->st.trapcom[0])
+	if(shp->st.trapcom && (t=shp->st.trapcom[0]))
 	{
 		shp->st.trapcom[0]=0; /*should free but not long */
 		shp->oldexit = savxit;
@@ -583,7 +585,8 @@
 		sh_offstate(shp,SH_ERREXIT);
 		sh_chktrap(shp);
 	}
-	nv_scan(shp->var_tree,array_notify,(void*)0,NV_ARRAY,NV_ARRAY);
+	if (shp->var_tree)
+		nv_scan(shp->var_tree,array_notify,(void*)0,NV_ARRAY,NV_ARRAY);
 	sh_freeup(shp);
 #if SHOPT_ACCT
 	sh_accend();
@@ -595,7 +598,7 @@
 		job_walk(shp,sfstderr,job_terminate,SIGHUP,NIL(char**));
 #endif	/* JOBS */
 	job_close(shp);
-	if(nv_search("VMTRACE", shp->var_tree,0))
+	if(shp->var_tree && nv_search("VMTRACE", shp->var_tree,0))
 		strmatch((char*)0,(char*)0);
 	sfsync((Sfio_t*)sfstdin);
 	sfsync((Sfio_t*)shp->outpool);
_______________________________________________
ast-developers mailing list
ast-developers@research.att.com
https://mailman.research.att.com/mailman/listinfo/ast-developers

Reply via email to