473,698 Members | 2,602 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Seg fault even though address space is accessible

Hi All,

I got a segmentation fault while accessing a structure element.
I pasted the output from gdb and the backtrace.

However if I am able successfully access the structure using the
address from the gdb output
after it seg faulted. Output from gdb also give below.

Any idea y this is happening?
yes I am trying to access the structure element from where it seg
faulted.

I am surely missing something.
Any help is appreciated!

Thanks,
Ajay.

$$$$$$$$$$$$$ SEG FAULT $$$$$$$$$$$$$$$ $$

Program received signal SIGSEGV, Segmentation fault.
checkBFVectorLi st (BFVecList=0x84 187a0, BFlen=699)
at compute_sticky_ IP_per_ASN.c:77 6
776 vector = vector->nextVector;

$$$$$$$$$$$$$$$ $ BT $$$$$$$$$$$$$$$ $$$$$

(gdb) bt
#0 checkBFVectorLi st (BFVecList=0x84 187a0, BFlen=699)
at compute_sticky_ IP_per_ASN.c:77 6
#1 0x08051bb3 in buildPeerDetail StructFromLine (line=0x8418dd0 "566",
peerStruct=0x80 47124) at compute_sticky_ IP_per_ASN.c:75 2
#2 0x080522c1 in main (argc=11, argv=0x8047348)
at compute_sticky_ IP_per_ASN.c:17 9

$$$$$$$$$$$$$$$ $$$$$ ACCESSING STRUCTURE $$$$$$$$$$$$$$$ $$$$

(gdb) p *(bitfieldItemS truct *) 0x84187a0
$1 = {BFVector = 3309413121, nextVector = 0x84187b0}
(gdb) p ((bitfieldItemS truct *) 0x84187a0)->nextVector
$2 = (struct bitfieldItem *) 0x84187b0
(gdb) p ((struct bitfieldItem *) 0x84187a0)->nextVector
$3 = (struct bitfieldItem *) 0x84187b0
Jul 29 '08
36 1936
Keith Thompson wrote:
Chris Dollin <ch**********@h p.comwrites:
>Antoninus Twink wrote:
[more of the same]
>Cite three instances that fit this claim.

Chris, why on Earth would you ask a troll to post *more* crap?
Paranoid terror that some poor sod will believe their
hysterically extreme claims.

(Additional evidence suggests I'm on a downer at the moment.)

--
'It changed the future .. and it changed us.' /Babylon 5/

Hewlett-Packard Limited registered no:
registered office: Cain Road, Bracknell, Berks RG12 1HN 690597 England

Jul 31 '08 #21
Chris Dollin wrote:
Antoninus Twink wrote:
.... snip ...
>
>Fact is, *noone* has claimed to be able to debug code using only
a debugger and not seeing the source code. *You* on the other
hand (and many of your lackeys and lickspittles) have claimed on
many occasions that you can debug any problem using only a
printout of the source code and never a debugger.

Cite three instances that fit this claim.
Well, answering the twinkletroll is pointless. However, many have
performed this awesome feat of legerdomain and successfully patched
the object code. It does require understanding machine code. It
may also require understanding the structure of the loadable code
module.

Admittedly, it is somewhat harder than reading source.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home .att.net>
Try the download section.
Jul 31 '08 #22
On Jul 31, 9:58*am, CBFalconer <cbfalco...@yah oo.comwrote:
Chris Dollin wrote:
Antoninus Twink wrote:

... snip ...
Fact is, *noone* has claimed to be able to debug code using only
a debugger and not seeing the source code. *You* on the other
hand (and many of your lackeys and lickspittles) have claimed on
many occasions that you can debug any problem using only a
printout of the source code and never a debugger.
Cite three instances that fit this claim.

Well, answering the twinkletroll is pointless. *However, many have
performed this awesome feat of legerdomain and successfully patched
the object code. *It does require understanding machine code. *It
may also require understanding the structure of the loadable code
module.

Admittedly, it is somewhat harder than reading source.

--
*[mail]: Chuck F (cbfalconer at maineline dot net)
*[page]: <http://cbfalconer.home .att.net>
* * * * * * Try the download section.
Thanks for all your replays and time.
The Seg fault is now resolved. Just a summary.

I was making two big blunders.
1. I was passing pointer to a structure instead of pointer to pointer
of a structure.
2. I was allocating memory to a pointer to structure instead of
structure.

They just creeped in due to my 'lazy programming'.

I am posting gcc compiled code.
Since I was using strict compiler options (including -ansi -pedantic)
and throwing out all the warnings.
So I was ignoring the argument mis-match warnings along with other
warnings.

I haven't figured out what are best compiler options yet.
But I can make sure next time that I go thru the list warning msgs.

Thanks,
Ajay.



Jul 31 '08 #23
Ajay wrote:
I haven't figured out what are best compiler options yet.
I can't help you there (and the options may change for
each translation unit), but maybe you'd like to try
gcc -Werror ...

-Werror
Make all warnings into errors.

:P
Jul 31 '08 #24
On 31 Jul 2008 at 6:45, Chris Dollin wrote:
Antoninus Twink wrote:
>Fact is, *noone* has claimed to be able to debug code using only a
debugger and not seeing the source code. *You* on the other hand (and
many of your lackeys and lickspittles) have claimed on many occasions
that you can debug any problem using only a printout of the source code
and never a debugger.

Cite three instances that fit this claim.
Happily. In fact, here are five.

Malcolm Maclean, <Xq************ *************** ***@bt.com>
My view on this is that the debugger creates a very intimate
relationship with the programmer. When I first learnt C I used one.
The run / debug cycle becomes a natural way of working. Then In my
first job I got a Unix box and suddenly the debugger was taken away.
Then I got another one for a games console, but it wasn't well
designed. I decided at that point that even a good debugger was too
seductive. So now I use diagnostics almost exclusively.
Bartc, <MP************ ******@text.new s.virginmedia.c om>
I've never used debuggers either, for either hardware or software.
Tracking down an elusive bug is more like a sport; a proper debugger
would spoil the fun.

Ian Collins, <63************ *@mid.individua l.net>
As I've said here before, spend some time (at least a year) working in
a language without a debugger, you will very quickly adapt to life
without it.

Ed Prochik,
<50************ *************** *******@e39g200 0hsf.googlegrou ps.com>
>1500-2000 lines is the maximum the brain can handle.

So then keep you code size below that limit and you will not need the
debugger.

And the Prince Of Lies himself, Richard Heath Field,
<mq************ *************** ***@bt.com>
I have certainly debugged what you consider to be impossibly large
code bases without using a debugger.
>nobody believes this "I can debug without a debugger" stuff.

...except those who've done it, of course, which seems to be most of
us.

Once again, I call bullshit on Heathfield's claims to be a superhero.

We've all seen Heathfield spew out lie after lie to undermine Jacob and
try to destroy his reputation. It's no surprise that he tries to blacken
the "trolls" who've got the measure of him with the same sort of slurs.

Heathfield is a liar, morning, noon and night.

Jul 31 '08 #25
On 1 Aug, 00:54, Antoninus Twink <nos...@nospam. invalidwrote:
On 31 Jul 2008 at *6:45, Chris Dollin wrote:
Antoninus Twink wrote:
Fact is, *noone* has claimed to be able to debug code using only a
debugger and not seeing the source code. *You* on the other hand (and
many of your lackeys and lickspittles) have claimed on many occasions
that you can debug any problem using only a printout of the source code
and never a debugger.
Cite three instances that fit this claim.

Happily. In fact, here are five.
the key sentence in your quote is:

"You [Richard Heathfield] [...] have claimed on many occasions that
you can
debug any problem using ONLY a printout of the source code and NEVER
a
debugger"

I do not believe my elision or change in emphasis has distorted
what you say. The original is still available above.

1. RCH never said he nver used a debugger
2. none of the quotes below claim to only use a printout.
Many use diagnostics.

So you have made two untrue statements. Since you have done
this repeatedly this makes you a liar.
>
Malcolm Maclean, <XqGdnSZI96q0oH 3anZ2dneKdnZydn ...@bt.com>
My view on this is that the debugger creates a very intimate
relationship with the programmer. When I first learnt C I used one.
The run / debug cycle becomes a natural way of working. *Then In my
first job I got a Unix box and suddenly the debugger was taken away.
Then I got another one for a games console, but it wasn't well
designed. I decided at that point that even a good debugger was too
seductive. So now I use diagnostics almost exclusively.

Bartc, <MPDCj.23573$XI .16...@text.new s.virginmedia.c om>
I've never used debuggers either, for either hardware or software.
Tracking down an elusive bug is more like a sport; a proper debugger
would spoil the fun.

Ian Collins, <63tdlsF29bcn.. .@mid.individua l.net>
As I've said here before, spend some time (at least a year) working in
a language without a debugger, you will very quickly adapt to life
without it.

Ed Prochik,
<50ecfc19-f365-406a-a19e-14a44995c...@e3 9g2000hsf.googl egroups.com>
1500-2000 lines is the maximum the brain can handle.
So then keep you code size below that limit and you will not need the
debugger.

And the Prince Of Lies himself, Richard Heath Field,
<mqidnVWaxKTFDk TanZ2dnUVZ8saon ...@bt.com>
I have certainly debugged what you consider to be impossibly large
code bases without using a debugger.
nobody believes this "I can debug without a debugger" stuff.
...except those who've done it, of course, which seems to be most of
us.

Once again, I call bullshit on Heathfield's claims to be a superhero.

We've all seen Heathfield spew out lie after lie to undermine Jacob and
try to destroy his reputation. It's no surprise that he tries to blacken
the "trolls" who've got the measure of him with the same sort of slurs.

Heathfield is a liar, morning, noon and night.

--
Nick Keighley

"Anyone attempting to generate random numbers by deterministic
means is, of course, living in a state of sin."
-- John Von Neumann

Aug 1 '08 #26
[Sadly, this seems to be one of those times when snippage is likely to be
misinterpreted. Hence, no snippage.]

Nick Keighley said:
On 1 Aug, 00:54, Antoninus Twink <nos...@nospam. invalidwrote:
>On 31 Jul 2008 at 6:45, Chris Dollin wrote:
Antoninus Twink wrote:
>Fact is, *noone* has claimed to be able to debug code using only a
debugger and not seeing the source code. *You* on the other hand (and
many of your lackeys and lickspittles) have claimed on many occasions
that you can debug any problem using only a printout of the source
code and never a debugger.
Cite three instances that fit this claim.

Happily. In fact, here are five.
In fact, none of the five quotes fit the claim.
the key sentence in your quote is:

"You [Richard Heathfield] [...] have claimed on many occasions that
you can
debug any problem using ONLY a printout of the source code and NEVER
a
debugger"

I do not believe my elision or change in emphasis has distorted
what you say. The original is still available above.
And I have left it in place.
1. RCH never said he nver used a debugger
Right. It is my first port of call if a program segfaults, because it's the
fastest way to find out (assuming I don't already know!) where the symptom
is manifested. Often, from there it's pretty obvious what's gone wrong.
Furthermore, I used to make heavy use of debuggers. I didn't stop because
I became a "superhero" (as if!). I stopped because I found faster, more
effective ways to debug. That doesn't mean I *won't* use a debugger. I'm
perfectly prepared to do that if I think it worthwhile - and, on occasion,
it is; just not very often, that's all.
2. none of the quotes below claim to only use a printout.
Many use diagnostics.
None of the quotes below claim to use *even* a printout. I certainly
haven't said that I use printouts. I used to, yes - I suppose many of us
did, and perhaps some still do. But again, there are faster ways to debug
than to wait for the code base to meet the dead tree.
So you have made two untrue statements. Since you have done
this repeatedly this makes you a liar.
I'm not actually sure that he's a liar. I think he's just stupid. But of
course I could be wrong about that. Why do I think he's stupid? Well, he
can't read with understanding, he doesn't appear to comprehend the
futility of micro-optimisation, he doesn't understand the purpose of a
newsgroup for discussing C despite having been told many times, and he
doesn't have the ability to deal rationally with opposing arguments,
instead resorting to invective and mockery. But perhaps you're right -
maybe he's a liar too.
>Malcolm Maclean, <XqGdnSZI96q0oH 3anZ2dneKdnZydn ...@bt.com>
My view on this is that the debugger creates a very intimate
relationship with the programmer. When I first learnt C I used one.
The run / debug cycle becomes a natural way of working. Then In my
first job I got a Unix box and suddenly the debugger was taken away.
Then I got another one for a games console, but it wasn't well
designed. I decided at that point that even a good debugger was too
seductive. So now I use diagnostics almost exclusively.
No mention of printouts here.
>>
Bartc, <MPDCj.23573$XI .16...@text.new s.virginmedia.c om>
I've never used debuggers either, for either hardware or software.
Tracking down an elusive bug is more like a sport; a proper debugger
would spoil the fun.
No mention of printouts here.
>>
Ian Collins, <63tdlsF29bcn.. .@mid.individua l.net>
As I've said here before, spend some time (at least a year) working in
a language without a debugger, you will very quickly adapt to life
without it.
No mention of printouts here.
>>
Ed Prochik,
<50ecfc19-f365-406a-a19e-14a44995c...@e3 9g2000hsf.googl egroups.com>
>1500-2000 lines is the maximum the brain can handle.
So then keep you code size below that limit and you will not need the
debugger.
No mention of printouts here.
>>
And the Prince Of Lies himself, Richard Heath Field,
A nice demonstration of begging the question (in the proper sense), and of
the inability to get people's names right. The above error is one he has
made before, and he was called on it then, so he has demonstrated, too,
that he has learning difficulties. (I strongly suspect that he can't even
get his own name right. Maybe he really is called Antoninus Twink, but
somehow I doubt it.)
><mqidnVWaxKTFD kTanZ2dnUVZ8sao n...@bt.com>
I have certainly debugged what you consider to be impossibly large
code bases without using a debugger.
>nobody believes this "I can debug without a debugger" stuff.
...except those who've done it, of course, which seems to be most of
us.
No mention of printouts here.
>>
Once again, I call bullshit on Heathfield's
Ah! Look at that! He *can* get my name right - if he tries!
>claims to be a superhero.
I have never claimed to be a superhero, and Mr Twink's apparent belief that
I have done so merely highlights the fact that he lives in some kind of
fantasy world. I don't (mostly) ignore debuggers because of any great
claim of skill - I ignore them because they're not the most effective way
for me to solve most of my debugging problems. That's common sense, not
superheroism.
>We've all seen Heathfield
And again!
>spew out lie after lie to undermine Jacob and
try to destroy his reputation.
Mr Twink seems to be making the mistake of believing his own propaganda. I
am not trying to undermine Jacob Navia or to destroy his reputation. He is
perfectly capable of doing that all by himself. I do, however,
occasionally point out errors in his articles, and it is true that I have
sometimes asked him to stop plugging his product in comp.lang.c, since it
is a technical group about the C language, not a commercial group about
implementations .
>It's no surprise that he tries to blacken
the "trolls" who've got the measure of him with the same sort of slurs.
People who can't understand what they read are bound to jump to false
conclusions on occasion, but Mr Twink seems to jump from one false
conclusion to another with the agility of a mountain goat.
>Heathfield
Well, he managed to get my name right three times out of four. I suppose I
should be grateful for small mercies.
>is a liar, morning, noon and night.
At least that leaves my afternoons free.

--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Aug 1 '08 #27
Ajay wrote:
>
.... snip ...
>
I haven't figured out what are best compiler options yet. But
I can make sure next time that I go thru the list warning msgs.
One line, probably wrapped, below:

*gcc -W -Wall -ansi -pedantic -Wwrite-strings -Wfloat-equal
-gstabs+ -ftrapv

(you may want to replace ansi with std=c99)

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home .att.net>
Try the download section.
** Posted from http://www.teranews.com **
Aug 1 '08 #28
On Fri, 01 Aug 2008 09:52:54 -0400, CBFalconer wrote:
Ajay wrote:
>I haven't figured out what are best compiler options yet. But I can
make sure next time that I go thru the list warning msgs.

One line, probably wrapped, below:

*gcc -W -Wall -ansi -pedantic -Wwrite-strings -Wfloat-equal -gstabs+
-ftrapv

(you may want to replace ansi with std=c99)
Why do you want to use -ansi if you're going to include another option
that deliberately makes the compiler fail to conform to any standard?
Aug 1 '08 #29
Harald van D?k wrote:
CBFalconer wrote:
>Ajay wrote:
>>I haven't figured out what are best compiler options yet. But
I can make sure next time that I go thru the list warning msgs.

One line, probably wrapped, below:

*gcc -W -Wall -ansi -pedantic -Wwrite-strings -Wfloat-equal
-gstabs+ -ftrapv

(you may want to replace ansi with std=c99)

Why do you want to use -ansi if you're going to include another
option that deliberately makes the compiler fail to conform to
any standard?
And what do you consider does that? A warning does not prevent
compilation.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home .att.net>
Try the download section.
** Posted from http://www.teranews.com **
Aug 1 '08 #30

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
6805
by: sivignon | last post by:
Hi, I'm writing a php script which deals with 3 ORACLE databases. This script is launch by a script shell on an linux machine like this : /../php/bin/php ./MySript.php (PHP 4.3.3) My script works fine and do all what I need. But at the end of the execution, I can read "Segmentation Fault". The segmentation fault appear at the end of my script execution,
13
22164
by: N.S. du Toit | last post by:
Just having a bit of trouble programming with C under FreeBSD 5.1 using the gcc compiler. I'm a bit new to C so my apologies if the answer to my question appear obvious :) Basically I've written a function that will check whether a string is an ip address (see the function isIP below). During my attempt at debugging this problem I inserted a printf statement before the return command from the statement, and also a printf statement...
3
11432
by: Zheng Da | last post by:
Program received signal SIGSEGV, Segmentation fault. 0x40093343 in _int_malloc () from /lib/tls/libc.so.6 (gdb) bt #0 0x40093343 in _int_malloc () from /lib/tls/libc.so.6 #1 0x40094c54 in malloc () from /lib/tls/libc.so.6 It's really strange; I just call malloc() like "tmp=malloc(size);" the system gives me Segmentation fault I want to write a code to do like a dynamic array, and the code is as
20
520
by: ramu | last post by:
Hi, int main(void) { char ch='a'; printf("%s",ch); return 0; } Why does this give segmentation fault?
27
3352
by: Paminu | last post by:
I have a wierd problem. In my main function I print "test" as the first thing. But if I run the call to node_alloc AFTER the printf call I get a segmentation fault and test is not printed! #include <stdlib.h> #include <stdio.h> typedef struct _node_t {
8
1618
by: ChristophK | last post by:
Hallo, this is my first post and I hope I'm doing well, but if not, please let me know. My problem: First all classes and a main-file (I simplified everything to get to the core of the problem): /*---------------- start of code ---------------------------*/
59
2888
by: Christian Christmann | last post by:
Hi, I'm wondering why this program does not crash with a segmentation fault: #include <malloc.h> #include <string.h> #include <stdio.h> int main()
0
1161
by: rmashukov | last post by:
Program terminated with signal 11, Segmentation fault. Environment: FreeBSD 6.2, Python 2.4.4, MySQLdb 1.2.2, SQLObject 0.9.1 I faced with an error in our multithreaded, network oriented application, wich interacts actively with MySQL database. Brief information from core dump is below (more detailed one is in the file attached). Though I am not very experienced with FreeBSD and gdb, I have still tried to collect information about the...
25
3367
by: jbholman | last post by:
I am pretty new to C and doing my first project in C. I actually read almost the entire FAQ, but can't seem to figure out this problem. I have a structure. I have a list of these structures. Inside each structure, I have two members: a list of strings, and a string. I have made a sample program below that exhibits the error I am having. I also read about Valgrind, and used it to tell me where I was getting the segmentation fault,...
0
8680
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9169
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7738
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.