Originally posted by: SystemAdmin
C program ran in xlC version 6 (32 bit). We are moving to a 64 bit environment. In version 8, the C program compiles with no errors. At runtime, we get a segmentation fault (coredump) error at strcpy. A section of the code is included below along with the results of a dbx "where" command.
[b]Code:[/b]
code int main(int argc, char *argv[])
{
int iLoggerType;
char *szPathName;
int fdPipe;
char *szBuffer;
int ierr;
if (argc < 3)
{
fprintf(stderr, "usage: %s <a|b> <log_directory>
<error_file>\n",
argv[0]);
fprintf(stderr, " a - audit logger\n");
fprintf(stderr, " b - batch logger\n");
exit(1);
}
switch (argv[1][0])
{
case 'a':
iLoggerType = AUDIT;
break;
case 'b':
iLoggerType = BATCH;
break;
default:
fprintf(stderr, "%s: invalid logger type - must be a or b.\n", argv[0]);
exit(1);
}
/* we haven't changed directories yet, so we need a full path to open
** the error log. this buffer will hold it */
if (((szPathName = (char *)malloc(sizeof(char) *
(strlen(argv[2]) + FILENAME_MAX + 2)))
== NULL) ||
((szBuffer = (char *)malloc(BUF_SIZE)) == NULL))
{
fprintf(stderr, "%s: cannot allocate sufficient memory.\n", argv[0]);
exit(3);
}
strcpy(szPathName, argv[2]);
[/code]
[b]Debug info:[/b]
code :> carclogr b /psoft/ps849/upg/logs LOGR
Segmentation fault(coredump)
:> dbx carclogr core
Type 'help' for help.
warning: The core file is not a fullcore. Some info may
not be available.
using memory image in core reading symbolic information ...
Segmentation fault in strcpy.strcpy
carclogr at 0x10000170c
0x10000170c (strcpy+0x2c) 98c50000 stb r6,0x0(r5)
(dbx) where
strcpy.strcpy() at 0x10000170c
main(argc = 4, argv = 0x0ffffffffffff220), line 511 in "carclogr.c"
[/code]