[SOLVED] Porting c programming project from HP-UX to Linix.
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Porting c programming project from HP-UX to Linix.
Hi Guys,
I am currently working on a project, where I need to move the c-source code from HP-UX to Linux. I came across two wired issues, one is on the oracle side, and we were able to resolve by applying a patch (Unique Patch ID: 24128901) for that. Next one is on the socket side where I am getting and issue on socket (SockWrite: error on socket write, errno=104, Connection reset by peer). This code compile and runs good in HP-UX but compiles fine in Linux but fails at runtime in Linux. Please let me know if this is due to porting from HP-UX to Linux and how I can fix this issue in Linux.
I am currently working on a project, where I need to move the c-source code from HP-UX to Linux. I came across two wired issues, one is on the oracle side, and we were able to resolve by applying a patch (Unique Patch ID: 24128901) for that. Next one is on the socket side where I am getting and issue on socket (SockWrite: error on socket write, errno=104, Connection reset by peer). This code compile and runs good in HP-UX but compiles fine in Linux but fails at runtime in Linux. Please let me know if this is due to porting from HP-UX to Linux and how I can fix this issue in Linux.
Thanks
Ravi K
Welcome to LQ,
Debug the program you ported. Focus on the trouble spots you've identified up to this point.
Do you need help understanding how to do that? Debugging with a debugger are some blogs cited in my signature. Debugging with printf() is another way, check function returns against what the current manual pages show, and also verify functions being called, along with their arguments, perhaps there are differences between what HP-UX used and the libraries being used in your newly compiled code. Also look up errno 104 and get familiar with the library call giving that error.
Also moving this thread to Programming to give it better visibility.
Could you please help me on how to convert this from big ediness to the little ths ediness in the new environment. I am new to socket programming and i now very little on this topic. If you have any sample code please let me know.
Hi NevemTeve,
Could you please help me on how to convert this from big ediness to the little ths ediness in the new environment. I am new to socket programming and i now very little on this topic. If you have any sample code please let me know.
A bit confused as to how someone who is "new to socket programming" got a job porting code from HP/UX to Linux which specifically involves socket programming. As teckk said, you've shown us nothing about your code, told us version/distro of Linux or version of HP/UX.
As rtmistler said, have you run this through your debugger?? Also, this error could be generic in nature...which could indicate a network problem. Have you checked selinux, your Linux firewall, or any/all routers/firewalls between your Linux system and whatever you're connecting to?? You hint at Oracle, so there could be a whitelist of addresses that are allowed to connect...is your Linux box among them???
I am a c/c++ developer and we are currently moving our code base from HP-UX "HP-UX spare009 B.11.11 U 9000/800 3656892423 unlimited-user license" to Linux "Linux ccpvlnwht302 5.4.17-2136.321.4.1.el7uek.x86_64 #2 SMP Wed Jul 19 14:51:35 PDT 2023 x86_64 x86_64 x86_64 GNU/Linux". I was able to complie the code base without any issue, but once we move the binaries to the Linux and start running , it is giving me an segmentation error and generating a core file. When i debug the core file i am getting the below error....
ccpvlnwht302 ESTRNT6 [779]: gdb bubg core.6540
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-120.0.3.el7
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /u02/apps/kodiak/estrnt6/bg_deliv022317/bin/bubg...done.
[New LWP 6540]
[New LWP 6543]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Core was generated by `/u02/apps/kodiak/home/bin/bubg'.
Program terminated with signal 11, Segmentation fault.
#0 0xf7f77569 in __kernel_vsyscall ()
Missing separate debuginfos, use: debuginfo-install glibc-2.17-326.0.9.ksplice1.el7_9.i686 libaio-0.3.109-13.el7.i686
(gdb) bt
#0 0xf7f77569 in __kernel_vsyscall ()
#1 0xf4a1af56 in raise () from /lib/libpthread.so.0
#2 0xf6828593 in skgesigOSCrash () from /u01/home/dba/oracle/product/19.0.0/db_2/lib/libclntsh.so.19.1
#3 0x0000000b in ?? ()
#4 0xf71571d0 in kpeDbgSignalHandlerDeregister () from /u01/home/dba/oracle/product/19.0.0/db_2/lib/libclntsh.so.19.1
#5 0x00000000 in ?? ()
and somebody mentioned that this might be due to endiness. Please advise.....
People wouldn't you think hton() functions would already be in the code? Unless it's ancient, which HP-UX actually is, but it is still maintained. Anyways it may not be so simple as a one concept answer. Understanding the source and fixing it properly would be an important task to undertake, regardless. And if the OP is a coder, then why should they not be able to manage that?
Errno 104 can mean a few things, mainly "connection reset by peer", best to get the version and the library call involved, but also first find out if that's the first error or just a higher level error, post fault. Checking the open() and any other sock calls' returns is first what I'd do, along with verifying what it thinks it received for arguments.
Here is the server side code snippet.
---------------------Socket Initialization Function-----------------------
void SockInit(char *progNamePtr,
int family,
int socketType,
int type,
int *sockFdPtr,
struct sockaddr_in *sockAddrPtr,
int portNum,
int ioMode,
char *hostNamePtr)
{
int rc; /* local return code */
struct hostent *StructHp; /* host name */
int reuseaddr_on=1; /* SO_REUSEADDR flag */
/***********************************************************************
For the Client end, we want to use the address of the server
hostname for the subsequent connect operations.
For the SERVER end, we want to allow any valid addresses to
connect but we do want to perform the bind to allow clients
a name association.
***********************************************************************/
if (type == SOCK_CLIENT)
{
StructHp = gethostbyname(hostNamePtr);
Please wrap your code and data snippets inside [CODE]...[/CODE] tags. Doing so will preserve indentation and provide other visual clues which make it easier for others to comprehend. You may write those yourself as shown, or use the # button available with Advanced edit options. (A complete list of BBCode tags is always available via a link near the bottom of every thread view).
I am a c/c++ developer and we are currently moving our code base from HP-UX "HP-UX spare009 B.11.11 U 9000/800 3656892423 unlimited-user license" to Linux "Linux ccpvlnwht302 5.4.17-2136.321.4.1.el7uek.x86_64 #2 SMP Wed Jul 19 14:51:35 PDT 2023 x86_64 x86_64 x86_64 GNU/Linux". I was able to complie the code base without any issue, but once we move the binaries to the Linux and start running , it is giving me an segmentation error and generating a core file. When i debug the core file i am getting the below error....
Code:
ccpvlnwht302 ESTRNT6 [779]: gdb bubg core.6540
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-120.0.3.el7
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /u02/apps/kodiak/estrnt6/bg_deliv022317/bin/bubg...done.
[New LWP 6540]
[New LWP 6543]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Core was generated by `/u02/apps/kodiak/home/bin/bubg'.
Program terminated with signal 11, Segmentation fault.
#0 0xf7f77569 in __kernel_vsyscall ()
Missing separate debuginfos, use: debuginfo-install glibc-2.17-326.0.9.ksplice1.el7_9.i686 libaio-0.3.109-13.el7.i686
(gdb) bt
#0 0xf7f77569 in __kernel_vsyscall ()
#1 0xf4a1af56 in raise () from /lib/libpthread.so.0
#2 0xf6828593 in skgesigOSCrash () from /u01/home/dba/oracle/product/19.0.0/db_2/lib/libclntsh.so.19.1
#3 0x0000000b in ?? ()
#4 0xf71571d0 in kpeDbgSignalHandlerDeregister () from /u01/home/dba/oracle/product/19.0.0/db_2/lib/libclntsh.so.19.1
#5 0x00000000 in ?? ()
and somebody mentioned that this might be due to endiness. Please advise....
Ok, so you're using old RHEL 7, which is what you were asked. You say you're 'moving' the binaries to Linux...are you not COMPILING on Linux to start with?? Not very clear on this, and if you're a C developer already, and are experienced with HP/UX, again confused as to how you don't know big vs. little-endian terminology. You now say it's giving you a core dump, and when you started you said it was a 104 error. You were also advised to check the firewalls/selinux, since 104 could ALSO be a problem with basic network connectivity. You again hint at Oracle being involved, but aren't giving us the entire picture.
I moved the source code from HP-UX to Linux, compiled the code in Linux without any errors and when I run it, it core dumps on segmentation fault. When i debug using gdb as below i am getting the below messages....
-------------------
ccpvlnwht302 ESTRNT6 [779]: gdb bubg core.6540
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-120.0.3.el7
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /u02/apps/kodiak/estrnt6/bg_deliv022317/bin/bubg...done.
[New LWP 6540]
[New LWP 6543]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Core was generated by `/u02/apps/kodiak/home/bin/bubg'.
Program terminated with signal 11, Segmentation fault.
#0 0xf7f77569 in __kernel_vsyscall ()
Missing separate debuginfos, use: debuginfo-install glibc-2.17-326.0.9.ksplice1.el7_9.i686 libaio-0.3.109-13.el7.i686
(gdb) bt
#0 0xf7f77569 in __kernel_vsyscall ()
#1 0xf4a1af56 in raise () from /lib/libpthread.so.0
#2 0xf6828593 in skgesigOSCrash () from /u01/home/dba/oracle/product/19.0.0/db_2/lib/libclntsh.so.19.1
#3 0x0000000b in ?? ()
#4 0xf71571d0 in kpeDbgSignalHandlerDeregister () from /u01/home/dba/oracle/product/19.0.0/db_2/lib/libclntsh.so.19.1
#5 0x00000000 in ?? ()
(gdb)
----------------------------------------------------------------
When i looked at the log message, i do see some ERROR messages on the log file as below
-----------------Log Message---------
****ERROR: buup 15036 899757 Tue Dec 5 16:04:38 2023
ProcInit: connect returns errno=111, Connection refused
****ERROR: buup 6539 12491 Tue Dec 5 17:16:45 2023
SockRead: error on socket read, errno=104, Connection reset by peer
--------------------Log Message----------------
When i test regarding the endiness, i found that HP-UX is a Big endian and Linux is a little edinan(afer running the test script). Before that there was one ORA-01036 error was there and after we applied the patch it was taken care of and now i can see only sockets errors in the log messages.
Just a note.
From 2005 HP site.
"Which C compiler are you using on HP-UX, you will probably be using the gnu compiler on linux so you will probably have a few compiler issues from library names and differences in function call formats and names.
The perl and tcl should convert quite nicely unless you have calls to OS programs then you may have the same issues as with the ksh scripts
The korn shell stuff will mostly port with no problem. The exceptions will be any reference to hardware. Linux (or any other unix) doesn't use the same names for all the hardware. The lvol names or tape drive name or in some cases even the tty names could be different so they will have to be updated."
So Oracle is involved as well (Is it OCI or Pro*C? If the latter, make sure to perform the preprocessing on the new platform.)
I'm afraid you have to actually debug the program. Other than gdb, valgrind might be useful (though Oracle Client itself contains lot of valgrind-positive problems (at least version 12.x)).
Also make sure to compile with flags `-W -Wall -Werror -pedantic'
PS: On archaic Unix-versions (such as Aix), address 0 is readable, so you NULL-pointer problem might not manifest in same cases. On Linux, reading from address 0 causes instant segfault.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.