The mysterious error message

Daniel R. Levy levy at ttrdc.UUCP
Thu Nov 27 09:50:19 AEST 1986


In article <1376 at umd5>, cgs at umd5.UUCP writes:
>The consensus of opinion is the environment is getting trashed. I'm going
>to have to see what I can do with "dbx". It's strange that the environment
>is getting trashed when I don't pass **envp to the program, and I never
>attempt to do anything to the environment via a system() call.
>Since I've received a note that I'm not the only one to have noticed this,
>I'm including the following response I received for everyone's benefit:
>
>I've tried to do system("printenv"), but that too generates the error.
>So, I'm left with poking around with "dbx" until I find out what is
>going on.
>.. And hast thou slain the Jabberwock? ..

	You could try something like replacing system() with code which
	actually prints out the environment, since printenv may filter
	out garbage even if invoked directly via execlp() (I don't have
	BSD src handy here, but SysV env filters out environment garbage).
	E.g.:

extern char **environ;
#define system(stuff) \
	{ \
	    int ep=0; \
	    while(environ[ep]) \
		(void) printf("%s\n",environ[ep++]); \
	}

Question: does the code do any writing into its argument vector?  Or question-
able indexing upon automatic arrays?  On SysV on a 3B20, the following will
evoke your "00: not an identifier" diagnostic:

main(argc,argv)
char **argv;
{
	argv[argc+1]="00";	/* messing with invalid argument */
	(void) system("echo hello, world");
}

So will this, after a few iterations (eventually core dumping):

main()
{
	auto char *c[1];
	register int i=0;
	while (1) {
		c[--i]="00";	/* messing with stack */
		(void) system("echo hello, world");
	}
}

"hope this helps"
-- 
 -------------------------------    Disclaimer:  The views contained herein are
|       dan levy | yvel nad      |  my own and are not at all those of my em-
|         an engihacker @        |  ployer or the administrator of any computer
| at&t computer systems division |  upon which I may hack.
|        skokie, illinois        |
 --------------------------------   Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa,
	   go for it!  			allegra,ulysses,vax135}!ttrdc!levy



More information about the Comp.unix.wizards mailing list