LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 09-28-2012, 01:03 PM   #1
hooxs
LQ Newbie
 
Registered: Sep 2012
Posts: 18

Rep: Reputation: 0
Exclamation +++ Segmentation fault !


!!!!!!!!!!!!

Last edited by hooxs; 09-28-2012 at 07:40 PM.
 
Old 09-28-2012, 01:52 PM   #2
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,541

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Debug your application!

Compile it like this:
Code:
gcc -g juno.c -o juno
Then put it in the debugger:
Code:
gdb ./juno
Once you see the gdb prompt, enter "run".
Code:
(gdb) run
When it crashes with the segfault, perform a back-trace:
Code:
(gdb) backtrace
Let us know what you find.
 
1 members found this post helpful.
Old 09-28-2012, 01:57 PM   #3
JohnGraham
Member
 
Registered: Oct 2009
Posts: 467

Rep: Reputation: 139Reputation: 139
When compiling, I get one warning that may cause a segfault. With -Wall I get other warnings. Fix them before doing anything else, or you're just wasting your time.
 
1 members found this post helpful.
Old 09-28-2012, 02:14 PM   #4
hooxs
LQ Newbie
 
Registered: Sep 2012
Posts: 18

Original Poster
Rep: Reputation: 0
!!!!!!!!!!!!

Last edited by hooxs; 09-28-2012 at 07:40 PM.
 
Old 09-28-2012, 02:18 PM   #5
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,541

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Quote:
Originally Posted by hooxs View Post
Syntax: /root/juno <target ip> <target port>

Program exited with code 01.
That warning is coming from this bit of code:
Code:
   if(argc<TARGET_IP_INDEX+2) {
  fprintf(stderr,"Syntax: %s ",argv[0]);
#ifndef RANDOMIZE_SOURCE_IP
  fprintf(stderr,"<source ip> ");
#endif
#ifndef RANDOMIZE_SOURCE_PORT
  fprintf(stderr,"<source port> ");
#endif
  fprintf(stderr,"<target ip> <target port>\n");
  exit(1);
   }
You will need to supply gdb with the run-time arguments. For example:
Code:
(gdb) run 192.168.1.10 8000
In other words, supply an IP address and a Port Number.
 
1 members found this post helpful.
Old 09-28-2012, 02:22 PM   #6
hooxs
LQ Newbie
 
Registered: Sep 2012
Posts: 18

Original Poster
Rep: Reputation: 0
!!!!!!!!!!!!

Last edited by hooxs; 09-28-2012 at 07:41 PM.
 
Old 09-28-2012, 03:34 PM   #7
hooxs
LQ Newbie
 
Registered: Sep 2012
Posts: 18

Original Poster
Rep: Reputation: 0
!!!!!!!!!!!!

Last edited by hooxs; 09-28-2012 at 07:41 PM.
 
Old 09-28-2012, 04:18 PM   #8
hooxs
LQ Newbie
 
Registered: Sep 2012
Posts: 18

Original Poster
Rep: Reputation: 0
!!!!!!!!!!!!

Last edited by hooxs; 09-28-2012 at 07:41 PM.
 
Old 09-28-2012, 05:00 PM   #9
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
I assume you didn't write this program, someone else did.

I assume whoever that was, only tested the program on a 32 bit OS.

I see you are compiling it on a 64 bit OS. Fixing the bugs that cause it to fail when compiled for 64 bits would be appropriate if it were you own program. But that might not be the best approach for your current needs.

If decent 32 bit support is installed in your 64 bit Linux system, I think you can get the program to work by compiling it as a 32 bit program, which may be as simple as using
Code:
gcc -m32 -O2 juno.c -o juno
instead of
Code:
gcc -O2 juno.c -o juno
I'm pretty sure the bug symptoms are only driven the architecture of the program itself, not by the architecture of the OS. So as a 32 bit program on a 64 bit OS, I think the program is likely to work.

Even if the program runs apparently correctly (free of seg faults or other of what I am calling bug symptoms) when compiled for 32 bit, that does not mean the program is free of actual bugs under those conditions. This program has enough bugs it is hard to even judge the intent well enough to fix the bugs. But the bugs might be symptom free in a 32 bit build. I wouldn't know without trying and I don't know whether you posted enough for me to try nor whether trying would be wise if I could.

Last edited by johnsfine; 09-28-2012 at 05:13 PM.
 
1 members found this post helpful.
Old 09-28-2012, 05:17 PM   #10
hooxs
LQ Newbie
 
Registered: Sep 2012
Posts: 18

Original Poster
Rep: Reputation: 0
!!!!!!!!!!!!

Last edited by hooxs; 09-28-2012 at 07:41 PM.
 
Old 09-28-2012, 05:27 PM   #11
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by johnsfine View Post
If decent 32 bit support is installed in your 64 bit Linux system
Quote:
Originally Posted by hooxs View Post
Code:
[root@vps ~]# gcc -m32 -O2 juno.c -o juno
In file included from /usr/include/features.h:352,
                 from /usr/include/string.h:26,
                 from juno.c:15:
/usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h: No such file or directory
!!!
OK, you have dis-proven my guess that decent 32 bit support is installed on your Linux system.

I previously read a lot of facts you didn't state into some of the obscure details you did post.

But suddenly I'm failing to notice the hooks from which to deduce other such facts. So maybe you can give us some background such as what distribution you are using, what package manager you use (and whether you actually know how to use it etc.) that might be relevant to the question of whether installing some 32 bit support is worth your trouble.

I still think a 32 bit build of your program is likely to work. But I can't promise that. I don't know how hard it would be for you to install 32 bit support or your system in order to find out.

Last edited by johnsfine; 09-28-2012 at 05:40 PM.
 
1 members found this post helpful.
Old 09-28-2012, 05:33 PM   #12
hooxs
LQ Newbie
 
Registered: Sep 2012
Posts: 18

Original Poster
Rep: Reputation: 0
!!!!!!!!!!!!

Last edited by hooxs; 09-28-2012 at 07:41 PM.
 
Old 09-28-2012, 05:47 PM   #13
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
For example, if your distribution is Ubuntu, there is a web site (which I just checked) for finding the package for any missing file. For the first file whose absence caused -m32 to fail for you, I found:

http://packages.ubuntu.com/search?se...ecise&arch=any

That says you need the package libc6-dev-i386

I think there is some meta package of 32 bit support that includes that package plus several related ones you might also need. But I never remember the name of that meta package nor how to look it up. If any Debian or Ubuntu experts are reading this, I expect one of them will remember what I mean.

Last edited by johnsfine; 09-28-2012 at 05:48 PM.
 
Old 09-28-2012, 05:49 PM   #14
hooxs
LQ Newbie
 
Registered: Sep 2012
Posts: 18

Original Poster
Rep: Reputation: 0
!!!!!!!!!!!!

Last edited by hooxs; 09-28-2012 at 07:41 PM.
 
Old 09-28-2012, 05:54 PM   #15
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by hooxs View Post
Sir I'm Using Centos - 5.5 - x86_64 !
I don't have admin control of my Centos systems, so I can't check this. But I think the command to install what you need is:
Code:
yum install glibc.i386 glibc-devel.i386
If any Centos or RHEL experts are reading this, they might comment on that.
 
  


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
[SOLVED] What is segmentation fault? aniketmeshram Programming 14 04-22-2011 04:18 AM
Segmentation fault AndeAnderson Linux - Laptop and Netbook 2 03-21-2007 08:10 AM
yast segmentation fault, system freezing - nvidia driver at fault? BaltikaTroika SUSE / openSUSE 2 12-02-2005 09:34 AM
segmentation fault ntduongntd Linux - General 4 11-29-2004 12:00 PM
Segmentation Fault XPediTioN Slackware 2 09-18-2003 08:16 AM

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

All times are GMT -5. The time now is 09:29 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