csh core dumping

Michael Greim greim at sbsvax.UUCP
Tue Dec 20 22:38:32 AEST 1988


In article <2294 at bucsb.UUCP>, jbw at bucsb.UUCP (Joe Wells) writes:
> Thanks to everyone who sent me a message.  I at least found what the
> real problems was.  Here is how to trigger it:
> 
> 	alias foo '`cat`'
> 	`foo`
> 
> This causes a subshell (or something) to dump core.  Originally, I
> thought the problem was with `(cd)`.  I was under the illusion that
> aliases were not expanded when sourcing a file or running a script.
> That was not true.
> 
> In any case, it causes an error on every version of the csh that I
> could try it on.  Does anyone know why?
I just took a look at the source of csh.
In the routine dobackp it tests for a pointer pargv. If this is set
it aborts with a core dump. This pointer is set as long as command
substitution is done. This mechanism effectively prevents recursive
command substitution. But don't ask me what for :-)
I consider this behaviour a bug. When I have time and nobody else
has offered a (valid) fix, I will have a look into it.

When you do
	alias abc '`echo ls`'
	`abc`
on a VAX 11/780 with 4.3BSD you get:
	Illegal instruction (core dumped)
	: Permission denied.

The reason for the first line is the bug in csh, which I have mentioned
above: it tries to do a command substitution inside of a command substitution,
so it dump core.
The result of the command substitution is empty, but csh packs this 'empty'
into a word and tries to call the file named 'empty'. When you issue an
open or exec with an empty string, you succeed and get the first file in your
current directory, which almost certainly is '.', the directory itself.
Thus csh tries to execute '.', fails and reports the error using errno.
(You can repeat this by just calling 'execl ("", "abc", 0); perror ("HEY");')

	-mg
-- 
email : greim at sbsvax.informatik.uni-saarland.dbp.de
  (some mailers might not like this. Then use greim at sbsvax.uucp)
  or  : ...!uunet!unido!sbsvax!greim
# include <disclaimers/std.h>



More information about the Comp.unix.questions mailing list