[comp.unix.questions] csh core dump

schung@cory.Berkeley.EDU (Stephen the Greatest) (01/01/70)

In article <3565@zen.berkeley.edu> I wrote:
>
>Csh bomber:
>
>mkdir x x/y
>set home = x/y
>cd x/y			<==== Typo
>cd ../..
>*** BOOM! ***
>core dumped
>

Oh, my mistake.  It should be a mere 'cd' that goes to $home instead of
'cd x/y'.  :-(

After the command 'cd', the working directory will be set to $home which
is x/y.  The *shell variable* 'cwd' is also set to $home, which is x/y.
Note that the string in cwd is not a full directory path, so when you
do a cd .., it first goes up one directory and sets cwd to x.  The next
cd .. you do, it goes up yet another directory and tries to set cwd 
right...... Oops!  BOOM!  The variable becomes undefined because it was
not a full path to begin with!  Therefore, to prevent such a core-dump,
do not set home to something other than a full path.

- Stephen

usenet@calyx.UUCP (USENET admin) (01/01/70)

In article <3565@zen.berkeley.edu> schung@cory.Berkeley.EDU.UUCP (Stephen the 
Greatest) writes:

>mkdir x x/y
>set home = x/y
>cd x/y
>cd ../..
>*** BOOM! ***
>core dumped
>
>I also tried it on a VAX 750, 8650 and 785 running 4.2, 4.3 BSD, and Ultrix.
>They *ALL* died.  Well, UNIX is portable is that sense..... :-)

But I tried this on our uVax II under Ultrix V1.2A... and it worked just
fine!  On the other hand, the following sequence *does* fail:

(I had already made x, x/y before doing this.)

38 cd
39 set home=x/y
40 cd x/y
41 cd ../..
42 cd
43 cd
cd: Can't change to home directory.
44 cd
cd: Can't change to home directory.
45 cd ../..

(It is just past eight o-clock, and time for the csh on your tty to Explode!)
___
Ariel Glenn   {rutgers,ihnp4}!uwvax!uwmcsd1!calyx!ariel      (UUCP)
							calyx!ariel@csd1.milw.wisc.edu             (Internet)

randy@umn-cs.UUCP (Randy Orrison) (08/29/87)

on the side, this dumps core on an Encore running UMAX 4.2:

	mkdir x
	mkdir y
	set home=x/y	# not absolute!
	cd
	cd ../..	# reference to $home?
	***BOOM***

I know it's a stupid thing to do, but it shouldn't dump core.  actually, the
cd ../.. should work, it's cd by itself that should have trouble, though just
with not being able to find $home.
	-randy
(Just tried it on our vanilla [for now] 4.3 VAX - another core dump!)
-- 
Randy Orrison, University of Minnesota School of Mathematics
UUCP:	{ihnp4, seismo!rutgers!umnd-cs, sun}!umn-cs!randy
ARPA:	randy@ux.acss.umn.edu		 (Yes, these are three
BITNET:	randy@umnacvx			 different machines)

jbuck@epimass.UUCP (08/30/87)

In article <2133@umn-cs.UUCP> randy@umn-cs.UUCP (Randy Orrison) writes:
>on the side, this dumps core on an Encore running UMAX 4.2:
>
>	mkdir x
>	mkdir y

I think you meant "mkdir x/y" here.

>	set home=x/y	# not absolute!
>	cd
>	cd ../..	# reference to $home?
>	***BOOM***

This core dumps csh on a Masscomp running RTU v3.1 also.

>(Just tried it on our vanilla [for now] 4.3 VAX - another core dump!)

That's the beauty of Unix: it's portable!  :-)


-- 
- Joe Buck    jbuck@epimass.epi.com
	      {uunet,ucbvax,sun,decwrl,<smart-site>}!epimass.epi.com!jbuck
	      Old arpa mailers: jbuck%epimass.epi.com@uunet.uu.net

mark@aoa.UUCP (Mark Reynolds) (08/30/87)

In article <1454@epimass.EPI.COM> jbuck@epimass.EPI.COM (Joe Buck) writes:
>In article <2133@umn-cs.UUCP> randy@umn-cs.UUCP (Randy Orrison) writes:
>
>
>>	set home=x/y	# not absolute!
>>	cd
>>	cd ../..	# reference to $home?
>>	***BOOM***
>
>This core dumps csh on a Masscomp running RTU v3.1 also.
>
>>(Just tried it on our vanilla [for now] 4.3 VAX - another core dump!)
>
On our VAX8650 running Ultrix 2.0-1 the "first" cd command fails with a
"cannot change to home directory"!

	Mark Reynolds
	...!{wjh12,mit-vax}!biomed!aoa!mark
	...!{harvard,ima}!bbn!aoa!mark

gwyn@brl-smoke.UUCP (08/31/87)

In article <406@aoa.UUCP> mark@aoa.UUCP (Mark Reynolds) writes:
>On our VAX8650 running Ultrix 2.0-1 the "first" cd command fails with a
>"cannot change to home directory"!

That's because there indeed was no directory x/y.
The mkdir should have made x then x/y, not x then y.

joel@intelisc.UUCP (09/01/87)

In article <1454@epimass.EPI.COM> jbuck@epimass.EPI.COM (Joe Buck) writes:
>In article <2133@umn-cs.UUCP> randy@umn-cs.UUCP (Randy Orrison) writes:
>>on the side, this dumps core on an Encore running UMAX 4.2:
>>
>>	mkdir x
>>	mkdir y
>I think you meant "mkdir x/y" here.
>>	set home=x/y	# not absolute!
>>	cd
>>	cd ../..	# reference to $home?
>>	***BOOM***
>
>This core dumps csh on a Masscomp running RTU v3.1 also.
>>(Just tried it on our vanilla [for now] 4.3 VAX - another core dump!)

I just tried it on a Intel 310/286 box with Xenix 3.4 with csh.......
  It worked OK there putting me back in the directory I started from.
	mkdir x x/y
	set home=x/y
	cd ..
	cd
  Causes the error message:   'x/y: No such file or directory'

What so hard about that?


Joel Clark
Intel Scientific Computers			joel%isc.intel.com
(503) 629-7732				{tektronix}!ogcvax!intelisc!joel
My employer will disavow any knowledge of my actions....Hi Ollie.

schung@cory.Berkeley.EDU.UUCP (09/03/87)

Csh bomber:

mkdir x x/y
set home = x/y
cd x/y
cd ../..
*** BOOM! ***
core dumped

I also tried it on a VAX 750, 8650 and 785 running 4.2, 4.3 BSD, and Ultrix.
They *ALL* died.  Well, UNIX is portable is that sense..... :-)

I guess the thing is that, when you say cd ../.., $home cannot go that
far, and the pointer runs off the head of the string 'x/y'.  (First ..,
go to 'x' and next .., where? Oops!)

I hope you guys keep posting interesting things like this..... (:->

- Stephen

hansm@cwi.nl (Hans Mulder) (09/04/87)

A quicker way to get csh to drop core:

$ HOME='xxx???yyy' csh
(null): No match.
Illegal instruction
$ 

Also works with PATH, TERM and USER.

For a change, you could try:

$ HOME='`/bin/date >/dev/tty`' csh
Fri Sep  4 17:50:22 MET DST 1987

This causes csh to hang.  It also leaves you a zombie process.  Apparently
csh does not wait for the child process it just forked off.
Note that you have to specify a full path name, because $path has not yet
been set, as you can observe by trying HOME='`set >/dev/tty`'.

					Hans Mulder
					hansm@cwi.nl