Newsgroups: comp.os.parix
From: e9282@tc.hsa.nl (D. Wapstra)
Subject: bug in getcwd?
Organization: Hogeschool Alkmaar, The Netherlands.
Date: 8 Feb 1996 15:34:07 +0100
Message-ID: <4fd1kv$4ku@mimas.tc.hsa.nl>

[using PARIX 1.3.1]

This gives a coredump when running on a PowerXplorer. It runs just fine
on the host (SUN4):

#include <stdio.h>

void main()
{
	char *cwd, *getcwd();
	cwd = getcwd((char *)NULL,64);
	printf("%s\n", cwd);
}

Error(c0000000)-Node 0, Context 2, Thread 0, Function _PX_DefaultTrapHandler:
 DATA ACCESS exception:
  illegal access to virtual address #00000000 (Rel.IP:#0000c690 / #0075f300)
   ---> Possible NULL pointer assignment!
    core dumped to file 'core.n0.c2.t0'

debug output:

Program terminated with signal 11, Segmentation fault.
#0  0x75f300 in strcpy ()
(gdb) backtrace
#0  0x75f300 in strcpy ()
#1  0x76225c in OS_getcwd ()
#2  0x7621b4 in getcwd ()
#3  0x761c70 in text ()
#4  0x752ff8 in ParixMain ()
#5  0x7b3e78 in _PX_CheckAlign ()

This is what the manual page gives as an example:

EXAMPLE
char *cwd, *getcwd();
.
.
.
if ((cwd = getcwd((char *)NULL, 64)) == NULL) {
perror(``pwd'');
exit(1);
}
printf(``%s\n'', cwd);


I am wondering... is this a bug, or am I doing something wrong?

Dave.


