03-28-2011 02:06 AM
I am using 3 HP-UX PA RISC machines for testing. My binary is failing on one PA RISC machine where as others it working. Note that, even though binary is executed with version check i.e. it just print version and exit and don't perform any other operation , still binary is giving segmentation fault. what could be probable reason for Segmentation fault. It is important to me to find out root cause of the failure on one box. As program is working on 2 HP-UX, it seems that it is environment issue?
I tried to copy same peace of code (i.e. declare variables, print version and exit) in test program and build with same compilation options but it is working. Here is gdb output for the program.
Here is gdb results:
$ gdb prg_us
Detected 64-bit executable.
HP gdb 5.4.0 for PA-RISC 2.0 (wide), HP-UX 11.00
and target hppa2.0w-hp-hpux11.00.
Copyright 1986 - 2001 Free Software Foundation, Inc.
Hewlett-Packard Wildebeest 5.4.0 (based on GDB) is covered by the
GNU General Public License. Type "show copying" to see the conditions to
change it and/or distribute copies. Type "show warranty" for warranty/support.
(gdb) b 5573
Breakpoint 1 at 0x4000000000259e04: file pmgreader.c, line 5573 from /tmp/test/prg_us.
(gdb) r -v
Starting program: /tmp/test/prg_us -v
Breakpoint 1, main (argc=2, argv=0x800003ffbfff05f8) at pmgreader.c:5573
5573 if (argc >=2 && strcmp (argv, "-v") == 0)
Current language: auto; currently c++
5575 printf ("%s", VER);
Program received signal SIGSEGV, Segmentation fault
si_code: 0 - SEGV_UNKNOWN - Unknown Error.
0x800003ffbfb9e130 in real_free+0x480 () from /lib/pa20_64/libc.2
What should be probable cause? why it is working on one and not on another?
03-28-2011 11:56 AM
>What should be probable cause?
A stack trace would be helpful here.
This indicates heap corruption. Is this a C++ application?
>RickT: Have you checked to make sure that the server with the error is running a 64bit OS?
>Viktor: what is the output of getconf KERNEL_BITS
Why would you waste time doing this? Almost all recent 11.11 systems should support 64 bit. And you get a different error.
03-28-2011 09:30 PM
@Viktor : getconf return 64 for both commands.
@Dennis: It is a C++ application. I though of memory corruption, but looking at code, but it just printing version when called with -v option, it print version and exit.
secondly, no memory allocated in between and no array has been defined.
03-29-2011 12:33 AM
>no memory allocated in between and no array has been defined.
These can be contradictory. I.e a C++ static initializer can allocate and corrupt memory before main is called.
Try changing your main to just return.
Or change your printf so it doesn't allocate a buffer:
fprintf(stderr, "%s", VER);