LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-06-2023, 02:19 AM   #16
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,030

Rep: Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344

Yes, I can't see any socket related error, but a null pointer in that gdb stack trace.
How did you compile your code on linux? What flags do you use at all?
 
Old 12-06-2023, 09:06 AM   #17
jyoravirisi
LQ Newbie
 
Registered: Dec 2023
Posts: 14

Original Poster
Rep: Reputation: 1
Hi NevemTeve,

When I compile my code using the flag '-W -Wall -Werror -pedantic' along with the flag '-g' in linux, it is giving me more errors and i am in the process of resolving these issues. Once i resolve these issues, i will re-run my code and let you know if face more challenges. When i pre-compile the Pro*C files, earlier in linux, i didn't face any kind issues and below is my ProC version.

ccpvlnwht302 ESTRNT6 [918]: proc --v

Pro*C/C++: Release 19.0.0.0.0 - Production on Wed Dec 6 09:05:52 2023
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.

System default option values taken from: /u01/home/dba/oracle/product/19.0.0/db_2/precomp/admin/pcscfg.cfg

Thanks a lot.

RK
 
Old 12-07-2023, 12:16 AM   #18
jyoravirisi
LQ Newbie
 
Registered: Dec 2023
Posts: 14

Original Poster
Rep: Reputation: 1
Hi pan64,

Here is all my flags, i used -ggdb for debugging purposes.

/usr/bin/gcc -m32 -O2 -fPIC -DPRECOMP -I/u02/apps/kodiak/home/include -Iinclude -DLINUX -D_GNU_SOURCE -D_LARGEFILE64_SOURCE=1 -D_LARGEFILE_SOURCE=1 -DSLTS_ENABLE -DSLMXMX_ENABLE -D_REENTRANT -DNS_THREADS -
DCOMP_DIR="" -DLDAP_CM -m32 -ggdb -I/u02/apps/kodiak/home/include -Iinclude -c buin.c
/usr/bin/gcc -m32 -m32 -o buin buin.o /u02/apps/kodiak/home/lib/misc_lib.a /u02/apps/kodiak/home/lib/db_lib.a /u02/apps/kodiak/home/lib/que_lib.a /u02/apps/kodiak/home/lib/alert_lib.a /u02/apps/kodiak/home/lib
/sock_lib.a /u02/apps/kodiak/home/lib/log_lib.a /u01/home/dba/oracle/product/19.0.0/db_2/lib/libclntsh.so -L -lclntsh -lclntshcore `cat /u01/home/dba/oracle/product/19.0.0/db_2/lib/ldflags` `cat /u01/home/db
a/oracle/product/19.0.0/db_2/lib/sysliblist` -lm -lc
cp buin /u02/apps/kodiak/home/bin/
------------------------------------------

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 23277]
[New LWP 23280]
[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 0xf7f7b569 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 0xf7f7b569 in __kernel_vsyscall ()
#1 0xf4a1ef56 in raise () from /lib/libpthread.so.0
#2 0xf682c593 in skgesigOSCrash () from /u01/home/dba/oracle/product/19.0.0/db_2/lib/libclntsh.so.19.1
#3 0x0000000b in ?? ()
#4 0xf715b1d0 in kpeDbgSignalHandlerDeregister () from /u01/home/dba/oracle/product/19.0.0/db_2/lib/libclntsh.so.19.1
#5 0x00000000 in ?? ()
(gdb)
-------------------------------------------------------------
You said that you can see a null pointer exception in my above gdb messages, can you elaborate that please or pin point that....?

Thanks
RK

Last edited by jyoravirisi; 12-07-2023 at 12:22 AM.
 
Old 12-07-2023, 02:11 AM   #19
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,030

Rep: Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344
your stack is destroyed, therefore the gdb output is useless. Most probably because of a null pointer issue. You need to fix all the errors reported by the compiler first (see post #17)
This is not a null pointer exception, but stack tries to do something at 0x0 (#3 and #5), which is just illegal. That causes the segfault.
 
Old 12-07-2023, 06:23 AM   #20
jyoravirisi
LQ Newbie
 
Registered: Dec 2023
Posts: 14

Original Poster
Rep: Reputation: 1
Hi p
Sure, I will resolve all the errors after compiling using the flag '-W -Wall -Werror -pedantic' and then re-compile my code.
Thanks for the suggestion.

Thanks
RK
 
Old 12-07-2023, 12:32 PM   #21
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931
You may wish to add printf functions in and around the socket calls to verify arguments and returns
 
Old 12-07-2023, 11:20 PM   #22
jyoravirisi
LQ Newbie
 
Registered: Dec 2023
Posts: 14

Original Poster
Rep: Reputation: 1
Hi rtmistler,

Will do....

Thanks a lot for your kind suggestion.

RK
 
Old 12-08-2023, 04:15 PM   #23
jyoravirisi
LQ Newbie
 
Registered: Dec 2023
Posts: 14

Original Poster
Rep: Reputation: 1
All,

Code:
static void VerifyBubgConnection(int sockFd)
{
   int numBytes=0;                   /* Number of bytes read         */
   static struct StructIpcMsg inMsg; /* Input message transmitted    */
                                     /* from bubg process            */
   numBytes = SockRead (sockFd, &inMsg, 10);

   LogWrite(LOG_CNTL_NONE,"buin: Entering VerifyBubgConnection...",MESSAGE,FALSE,0);
   (void) sprintf(errBuf,
                  "VerifyBubgConnection:  SockRead returned numBytes=%d",numBytes);
   (void) LogWrite(LOG_CNTL_NONE,errBuf,DEBUGMESSAGE, FALSE, 0);

   if (numBytes > 0)
   {
      (void) sprintf(errBuf, "VerifyBubgConnection: received unexpected message from BUBG FD=%d",
                     sockFd);
      (void) LogWrite(LOG_CNTL_NONE,errBuf,SLERROR,TRUE,SOFTERR);
   }
   else if (numBytes == -1)
   {
      (void) sprintf(errBuf, "VerifyBubgConnection: lost connection FD=%d",
                     sockFd);
      (void) LogWrite(LOG_CNTL_NONE,errBuf,SLERROR,TRUE,SOFTERR);
   }
   LogWrite(LOG_CNTL_NONE,"buin: Existing VerifyBubgConnection...",MESSAGE,FALSE,0);

   return;
}
The above verification function works fine in HP-UX but failing in the Linux,
Any idea why it is behaving differently, please advise?

RK

Last edited by jyoravirisi; 12-08-2023 at 04:24 PM.
 
Old 12-08-2023, 04:20 PM   #24
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,269
Blog Entries: 24

Rep: Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206
@jyoravirisi: As you have been asked before, 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).
 
1 members found this post helpful.
Old 12-09-2023, 12:01 AM   #25
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,880
Blog Entries: 1

Rep: Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871
@OP What do yo mean failing? read(2) and recv(2) return -1 on error (examine errno), 0 on end-of-file, positive if daza has been received.
 
1 members found this post helpful.
Old 12-09-2023, 05:18 AM   #26
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,030

Rep: Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344
What is that SockRead function? How does that work (or implemented)?
I have no idea what do you mean by "work differently", would be nice to explain exactly what went wrong (what is the expected behavior and and what's happened instead).
 
1 members found this post helpful.
Old 12-09-2023, 08:49 AM   #27
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931
Quote:
Originally Posted by NevemTeve View Post
@OP What do yo mean failing? read(2) and recv(2) return -1 on error (examine errno), 0 on end-of-file, positive if daza has been received.
Quote:
Originally Posted by pan64 View Post
What is that SockRead function? How does that work (or implemented)?
I have no idea what do you mean by "work differently", would be nice to explain exactly what went wrong (what is the expected behavior and and what's happened instead).
Ibid. And is sockFd even any good? What is it's value?
 
Old 12-11-2023, 12:38 PM   #28
jyoravirisi
LQ Newbie
 
Registered: Dec 2023
Posts: 14

Original Poster
Rep: Reputation: 1
Hi,

This is the custom SockRead function:

Code:
int SockRead (int  sockFd,
              void *inMsgPtr,
              int  maxMsgLen)
{
  int rtnNumBytes;      /* number of bytes read    */

  rtnNumBytes=0;
  (void*) memset(inMsgPtr, NULLBYTE, maxMsgLen);

  rtnNumBytes = read(sockFd, inMsgPtr, maxMsgLen);

  if (rtnNumBytes == -1 )
  {
    if ((errno != EWOULDBLOCK) && (errno != EAGAIN))
    {
      (void) sprintf(errBuf,"SockRead:  error on socket read, errno=%d, %s",
         errno, strerror(errno));
      (void) LogWrite(LOG_CNTL_NONE, errBuf, SLERROR, FALSE, 0);
    }
    else if (errno == EWOULDBLOCK)
    {
      (void) sprintf(errBuf,"SockRead:  EWOULDBLOCK returned from socket read");
      (void) LogWrite(LOG_CNTL_NONE, errBuf, WARNING, FALSE, 0);
    }
    else if (errno == EAGAIN)
    {
      (void) sprintf(errBuf,"SockRead:  EAGAIN returned from socket read");
      (void) LogWrite(LOG_CNTL_NONE, errBuf, DEBUGMESSAGE, FALSE, 0);
    }
    rtnNumBytes = 0;
  }
  else if (rtnNumBytes == 0)   /* EOF read */
     rtnNumBytes = -1;

  return(rtnNumBytes);
}
I don't think any wrong with the above code.
Please advise.

Thanks
RK
 
Old 12-11-2023, 01:01 PM   #29
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,030

Rep: Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344
ok, now tell us how does it work, what went wrong...
 
Old 12-11-2023, 04:33 PM   #30
jyoravirisi
LQ Newbie
 
Registered: Dec 2023
Posts: 14

Original Poster
Rep: Reputation: 1
pan64,

It is still failing on the segmentation fault, still trying to debug the code.

RK
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Porting and tuning applications for Linux on Power, Part 2: 15 Porting and tuning tools for Linux on Power LXer Syndicated Linux News 0 05-18-2018 01:05 PM
new to linix I have windows 10 and want a open source linix on seperate partician Evander Linux - Newbie 3 09-07-2016 05:24 PM
Linix WIFI YourForum Linux - Wireless Networking 2 11-27-2003 09:30 AM
Upgrading Linix help joe_dejesus Linux - Hardware 0 02-26-2003 01:51 PM
Linix and p2p mikeshn Linux - General 1 04-06-2002 09:45 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration