473,698 Members | 2,571 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 1937
In article <5e************ *************** *******@d1g2000 hsg.googlegroup s.com>,
Ajay <aj***********@ gmail.comwrote:
>{
bitfieldItemStr uct *BFVecHead, *currBFVec, *tmpBFVec;
[snip]
BFVecHead = (bitfieldItemSt ruct *) calloc(1,
sizeof(bitfiel dItemStruct *));
This looks suspicious.
You allocate room for one pointer instead of room for one struct.
Also, the cast is unnecessary.

Regards,
Ike
Jul 30 '08 #11
On Jul 29, 8:22*pm, Ben Bacarisse <ben.use...@bsb .me.ukwrote:
Ajay <ajay.todim...@ gmail.comwrites :
Thanks for your replay!
I was using malloc but after the error appeared, I tried using calloc.
I changed back the code to using malloc.
The Seg. fault error still persists.
The new code is posted below:

Are you sure you are posting code you have compiled?
int
checkBFVectorLi st(bitfieldItem Struct **BFVecList, unsigned int BFlen)
int
buildBFVectorLi st(char *BFStr, bitfieldItemStr uct **BFVecList)

elsewhere you posted:

| main()
| {
| * ****
| *buildBFVectorL ist(currPeerDet ailItem->bitfieldStr,
| &(currPeerDetai lItem->bitfieldVector ));
| *checkBFVectorL ist(currPeerDet ailItem->bitfieldVector ,
| currPeerDetailI tem->bitfieldLength );
|
| ****
|
| }

The types here do not match up -- the compiler should reject it.

--
Ben.
Yes, you are right. The compiler did gave warning which I did not
notice.

Thanks a lot!
-Ajay.
Jul 30 '08 #12
Ajay wrote:
I am posting the code here.
What you posted isn't anywhere close to compilable.
I started trying to turn this mess into something that I could address,
but gave up.
That means it cannot possibly exhibit the problem you claim.
Please try again, and actually try compiling it and checking to see if
it exhibits the problem before posting.
Jul 30 '08 #13
On 29 Jul 2008 at 22:29, Richard Heathfield wrote:
Ajay said:
>I got a segmentation fault while accessing a structure element.
I pasted the output from gdb and the backtrace.

There's a guy around here somewhere who can debug your problem (no matter
what it is) using only the debugger. Impressive. But if by some strange
chance he doesn't have time to answer your question, you'll have to rely
on the rest of us, and I'm afraid we tend to need to see the source code.
Yes Heathfield, very amusing, how we all admire your cleverness and wit.

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. I call bullshit on that.

Jul 30 '08 #14
Antoninus Twink <no****@nospam. invalidwrites:
On 29 Jul 2008 at 22:29, Richard Heathfield wrote:
>Ajay said:
>>I got a segmentation fault while accessing a structure element.
I pasted the output from gdb and the backtrace.

There's a guy around here somewhere who can debug your problem (no matter
what it is) using only the debugger. Impressive. But if by some strange
chance he doesn't have time to answer your question, you'll have to rely
on the rest of us, and I'm afraid we tend to need to see the source code.

Yes Heathfield, very amusing, how we all admire your cleverness and
wit.
He really is an arrogant twit.
>
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
Exactly.
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. I call bullshit on that.
Me too. Now cue one of his sycophantic friends to quote Kernighan or
somesuch telling us how much more difficult it is to debug a system than to
program it correctly the first time. Sigh.

Jul 30 '08 #15
Richard wrote, On 30/07/08 19:18:
Antoninus Twink <no****@nospam. invalidwrites:
>On 29 Jul 2008 at 22:29, Richard Heathfield wrote:
>>Ajay said:
I got a segmentation fault while accessing a structure element.
I pasted the output from gdb and the backtrace.
<snip>
>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. I call bullshit on that.

Me too. Now cue one of his sycophantic friends to quote Kernighan or
somesuch telling us how much more difficult it is to debug a system than to
program it correctly the first time. Sigh.
Obviously the person who managed to identify the bugs from just a couple
of snippets in this thread really managed to get hold of the entire
source without the rest of us seeing it.
--
Flash Gordon
Yes, I know, I should not reply to trolls.
Jul 30 '08 #16
Flash Gordon <sp**@flash-gordon.me.ukwri tes:
Richard wrote, On 30/07/08 19:18:
>Antoninus Twink <no****@nospam. invalidwrites:
>>On 29 Jul 2008 at 22:29, Richard Heathfield wrote:
Ajay said:
I got a segmentation fault while accessing a structure element.
I pasted the output from gdb and the backtrace.

<snip>
>>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. I call bullshit on that.

Me too. Now cue one of his sycophantic friends to quote Kernighan or
somesuch telling us how much more difficult it is to debug a system than to
program it correctly the first time. Sigh.

Obviously the person who managed to identify the bugs from just a
couple of snippets in this thread really managed to get hold of the
entire source without the rest of us seeing it.
I'm not sure what your point is. This is usenet. The code needed was
small. It in no way invalidates the benefits a debugger brings. Or in
this case paying attention to compiler warnings. of course some people
pulled the "can't compile it so cant help" line. others read the
code. Which was not insurmountable since it was about 20 lines.

Jul 30 '08 #17
Antoninus Twink wrote:
On 29 Jul 2008 at 22:29, Richard Heathfield wrote:
>Ajay said:
>>I got a segmentation fault while accessing a structure element.
I pasted the output from gdb and the backtrace.

There's a guy around here somewhere who can debug your problem (no matter
what it is) using only the debugger. Impressive. But if by some strange
chance he doesn't have time to answer your question, you'll have to rely
on the rest of us, and I'm afraid we tend to need to see the source code.

Yes Heathfield, very amusing, how we all admire your cleverness and wit.

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.

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

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

Jul 31 '08 #18
Chris Dollin said:
Antoninus Twink wrote:
>On 29 Jul 2008 at 22:29, Richard Heathfield wrote:
>>Ajay said:
I got a segmentation fault while accessing a structure element.
I pasted the output from gdb and the backtrace.

There's a guy around here somewhere who can debug your problem (no
matter what it is) using only the debugger. Impressive. But if by some
strange chance he doesn't have time to answer your question, you'll
have to rely on the rest of us, and I'm afraid we tend to need to see
the source code.

Yes Heathfield, very amusing, how we all admire your cleverness and wit.

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, he can't, Chris, can he? The best he can do is quote himself or some
other troll pretending that I made such a claim.

Incidentally, I find it very strange that the trolls have no objection to
extending other people's positions, but don't like their own positions to
be extended.

Yes, I did extend the position held by one of the trolls that the debugger
is an essential tool - I forget whether it's Twink or Noname - to the
position that it *suffices* in all cases, and source code is never
required, which I think we can all agree is an untenable proposition. Of
course, this would have been dishonest, had I not pointed out what I had
done in that very same article.

Conclusions:

(1) our resident trolls either can't or won't read an entire article for
comprehension;
(2) they don't like being trolled;
(3) they can't grasp simple facts;
(4) they can't reason very well.

It's just as well I have them killfiled, really, or I'd waste huge amounts
of time arguing with them. I know they don't believe I've killfiled them,
but that's just another demonstration of (3).

--
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
Jul 31 '08 #19
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?

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jul 31 '08 #20

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
8683
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
8610
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
9031
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8902
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
8873
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
5862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4372
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...
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
2
2339
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.