Different behaviour of programs in different OS version (223 Views)
Reply
Honored Contributor
Mohanasundaram_1
Posts: 558
Registered: ‎08-18-2003
Message 1 of 7 (223 Views)

Different behaviour of programs in different OS version

Hi Folks,

I received the below query from my customer and the problem is well explained by customer's example and scenario below, Please help me to understand why there is a difference in the program behaviour across different OS versions.

The problem details are as below:

-----------------------------------------------------



Problem: The potline programs compiled on HP UX 10.20 are crashing when it is run on HP-UX11.23.



Here is the sample program to illustrate the problem with "basename" function call:



File :dispka.c





#include

#include



main(int argc, char *argv[])

{

char *pname;



printf("Entering=%s\n", argv[0]);

pname = basename(argv[0]);

printf("Base name=%s\n", pname);

}







TEST 1:



Compilation:



Program is compiled on HP-UX 10.20 with following option,



cc -Aa dispka.c -o dispka



This executable is run on a different HP-UX versions and the following results were observed.





HP-UX10.20 and HP-UX 11.11



potline7 {line7} /home/line7 $ uname -a

HP-UX potline7 B.11.11 U 9000/800 2056943722 unlimited-user license



potline7 {line7} /home/line7 $ dispka

Entering=dispka

Base name=dispka



potline7 {line7} /home/line7 $ ./dispka

Entering=./dispka

Base name=dispka







HP-UX 11.23



dubal73 {line7} /home/line7 $ uname -a

HP-UX dubal73 B.11.23 U 9000/800 2377613077 unlimited-user license



dubal73 {line7} /home/line7 $ dispka

Entering=dispka

Memory fault(coredump)



dubal73 {line7} /home/line7 $ ./dispka

Entering=./dispka

Base name=dispka



In HPUX-11.23, if program is executed with prefix "./" , then it works. If it is removed it crashes with coredump.



In older versions (like 10.20 & 11.11) with or without prefix("./") it works.







TEST 2:



Compiler option:



cc dispka -o dispka compiled on HP-UX 11.23





If the same program is compiled on HP-UX 11.23 and executed on the same machine. It works with both the options(i.e with or without prefix "./");



From the above tests, it concludes that the executables generated on HP-UX10.20 may have some limitations when run on the HPUX11.11 version.

-------------------------------------------------------------

With regards,
Mohan.
Attitude, Not aptitude, determines your altitude
Exalted Contributor
Steven E. Protter
Posts: 33,806
Registered: ‎08-15-2002
Message 2 of 7 (223 Views)

Re: Different behaviour of programs in different OS version

Shalom Mohan,

The header files and compilers may be different in the various OS's. They need to be compared for consistency.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Honored Contributor
Mohanasundaram_1
Posts: 558
Registered: ‎08-18-2003
Message 3 of 7 (223 Views)

Re: Different behaviour of programs in different OS version

Hi Steven,

Thanks for your reply. They are using the same compiler on all the OS versions. Of course the compiler version itself is different.

I have to check about the header file. But customer had indicated if the same program is compiled on 11.23 the problem does not arise. The problem comes only when the program is compiled on the lower version of OS and executed on 11.23. Do you still think the header could be an issue?
I am really dumb in this area, so forgive me if it was a silly question.

With regards,
Mohan.
Attitude, Not aptitude, determines your altitude
Honored Contributor
Steve Lewis
Posts: 725
Registered: ‎05-18-2000
Message 4 of 7 (223 Views)

Re: Different behaviour of programs in different OS version

It might be the search path when you execute it. If you use the HP-UX 'type' command:
$ type dispka
on 11.23 make sure it returns the version that is in your current directory and not some other (old) version that you copied across.
So you see it may not be anything to do with the compilation, just the way that you run it.

So, check $PATH across operating systems.


Acclaimed Contributor
Dennis Handly
Posts: 25,291
Registered: ‎03-06-2006
Message 5 of 7 (223 Views)

Re: Different behaviour of programs in different OS version

The last time I saw this issue was where basename(3) was scanning backwards and went off the beginning of the data segment. I found this in 1999 with dirname(3), JAGaa62439.
Your problem should have been fixed in 1998 with JAGaa06034. It appears this fix was never made to the 10.20 libc.1, in any following OS releases?

Looking at the machine code in libc.1, I don't see how it would work on 10.20, 11.00, 11.11, 11.23 or 11.31?

It may be related to your shell. On 10.20, when I execute a.out in a "real" (ksh) shell, I get the full absolute path. Same as on 11.23.
Honored Contributor
Mohanasundaram_1
Posts: 558
Registered: ‎08-18-2003
Message 6 of 7 (223 Views)

Re: Different behaviour of programs in different OS version

Hi,

It looks like there is a patch for this issue.
PHCO_33710 - 11.23 cumulative 10.20 libc compatibility support


I am going to install this patch and check. I will then assign points to you all. Please be patient.

With regards,
Mohan.
Attitude, Not aptitude, determines your altitude
Honored Contributor
Mohanasundaram_1
Posts: 558
Registered: ‎08-18-2003
Message 7 of 7 (223 Views)

Re: Different behaviour of programs in different OS version

THe above mentioned patch resolved the issue. Thanks to all who replied.
Attitude, Not aptitude, determines your altitude
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.