LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-27-2012, 09:09 AM   #1
aspiring_stellar
LQ Newbie
 
Registered: May 2011
Distribution: Fedora, ubuntu
Posts: 18

Rep: Reputation: Disabled
segmentation fault inet_ntop()


Hi all,
I am getting segmentation fault in
inet_ntop(AF_INET6, &src, source, 40);

variables are declared as:
char *source;
struct in6_addr src;

Using g++ compiler to compile c++ source.
Any help?
 
Old 02-28-2012, 10:10 PM   #2
lisle2011
Member
 
Registered: Mar 2011
Location: Surrey B.C. Canada (Metro Vancouver)
Distribution: Slackware 2.6.33.4-smp
Posts: 183
Blog Entries: 1

Rep: Reputation: 25
Segfault

A piece of code is trying to use the same chunk of memory as another piece if code. You need to debug it. Configure GCC with --enable-checking . Compile it with -g -O0 so that you can use gdb. There are lots of pieces of advice on this particular subject as almost no-one who learns C or C++ doesn't get segfaults. You should track it down and if you compile it so gdb can do it's work you will have a 'Eureka' moment. But just a moment. The snippet of code, although well intentioned is not helpful. Good luck because you will overcome this hurdle.



If I helped at all give me a pat on the back (add to my reputation)
 
Old 02-29-2012, 03:43 AM   #3
aspiring_stellar
LQ Newbie
 
Registered: May 2011
Distribution: Fedora, ubuntu
Posts: 18

Original Poster
Rep: Reputation: Disabled
I have already tried gdb and got the exact location of seg fault using this only. gdb traceback shows seg fault in the line inet_ntop(AF_INET6, &src, source, 40);

Strangely, the same code works fine with gcc but not with g++. I need to get it working in c++.
 
Old 02-29-2012, 11:49 AM   #4
lisle2011
Member
 
Registered: Mar 2011
Location: Surrey B.C. Canada (Metro Vancouver)
Distribution: Slackware 2.6.33.4-smp
Posts: 183
Blog Entries: 1

Rep: Reputation: 25
Segfault in internet address function

Here is a page with examples and explanation, perhaps you see what is wrong with your code. More code would have been better.

the objective is turn the machine readable address into human readable.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Segmentation Fault? Help!! jcdlvsrbld Linux - Software 4 06-11-2009 10:48 AM
What is a segmentation fault? 144419855310001 Fedora 1 04-28-2006 08:39 AM
segmentation fault! sharath patil Debian 5 04-22-2006 05:57 AM
yast segmentation fault, system freezing - nvidia driver at fault? BaltikaTroika SUSE / openSUSE 2 12-02-2005 10:34 AM
segmentation fault Linh Programming 6 11-03-2003 09:25 AM


All times are GMT -5. The time now is 11:16 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration