473,396 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Segmentation fault in gdb

Hi,

i get this segmentation fault in my c++ program:

My question is 'it shows inMethodStr is not null, how come this can
have *inMethodStr.Ptr segmentation fault?

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1229927536 (LWP 16203)]
0x0806a1ee in RTSPProtocol::GetMethod (inMethodStr=@0xb6b0b6b0)
at Protocol.cpp:58
58 switch(*inMethodStr.Ptr)

Thank you for any help.

Jul 11 '07 #1
4 3367
On Jul 11, 10:56 am, "ying...@gmail.com" <ying...@gmail.comwrote:
Hi,

i get this segmentation fault in my c++ program:

My question is 'it shows inMethodStr is not null, how come this can
have *inMethodStr.Ptr segmentation fault?

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1229927536 (LWP 16203)]
0x0806a1ee in RTSPProtocol::GetMethod (inMethodStr=@0xb6b0b6b0)
at Protocol.cpp:58
58 switch(*inMethodStr.Ptr)

Thank you for any help.
inMethodStr is not null doesnot mean it points to the properly
initialized object or object containing valid data.
Posting relevant piece of code might help.
Jul 11 '07 #2
yi*****@gmail.com wrote:
Hi,

i get this segmentation fault in my c++ program:

My question is 'it shows inMethodStr is not null, how come this can
have *inMethodStr.Ptr segmentation fault?

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1229927536 (LWP 16203)]
0x0806a1ee in RTSPProtocol::GetMethod (inMethodStr=@0xb6b0b6b0)
at Protocol.cpp:58
58 switch(*inMethodStr.Ptr)

Thank you for any help.
In inMethodStr is something that can have . applied to it
(that is a class). It won't be null. Chances are
inMethodStr.Ptr is either a null pointer or points to
something other than a valid object.
Jul 11 '07 #3
"yi*****@gmail.com" <yi*****@gmail.comwrote in
news:11**********************@k79g2000hse.googlegr oups.com:
Hi,

i get this segmentation fault in my c++ program:

My question is 'it shows inMethodStr is not null, how come this can
have *inMethodStr.Ptr segmentation fault?

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1229927536 (LWP 16203)]
0x0806a1ee in RTSPProtocol::GetMethod (inMethodStr=@0xb6b0b6b0)
at Protocol.cpp:58
58 switch(*inMethodStr.Ptr)

Thank you for any help.
How would we know? We can't see the rest of the code. Please post a
minimal, compilable example that shows the problem.

Offhand the address of inMethodStr is suspicious because it has a repeating
pattern (0xb6b0b6b0). This may suggest that you are using and/or passing
an uninitialized variable into GetMethod. Then you use the . operator on
that object, and Undefined Behaviour occurs (effectively dereferencing a
pointer to who-knows-where).
Jul 11 '07 #4
* Ron Natalie:
>58 switch(*inMethodStr.Ptr)

Thank you for any help.

In inMethodStr is something that can have . applied to it
(that is a class). It won't be null.
It *shouldn't* be NULL, but if I would do something like

struct SomeStruct
{
int foo;
int bar;
};

void SomeFunction (SomeStruct &pInStruct)
{
switch (pInStruct.foo)
{
[...]
}
};

int main(void)
{
SomeStruct *SueMe = 0;
SomeFunction(*SueMe);
}

Then 'pInStruct' *WILL* be NULL. And yes, I know, undefined behaviour, which
most definately *includes* being caught in a debugger.

--
Martijn van Buul - pi**@dohd.org
Jul 12 '07 #5

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

Similar topics

2
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...
3
by: diyanat | last post by:
i am writing a cgi script in C using the CGIC library, the script fails to run, i am using apache on linux error report from apache : internal server error Premature end of script headers:...
16
by: laberth | last post by:
I've got a segmentation fault on a calloc and I don'tunderstand why? Here is what I use : typedef struct noeud { int val; struct noeud *fgauche; struct noeud *fdroit; } *arbre; //for those...
3
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...
5
by: Fra-it | last post by:
Hi everybody, I'm trying to make the following code running properly, but I can't get rid of the "SEGMENTATION FAULT" error message when executing. Reading some messages posted earlier, I...
18
by: Digital Puer | last post by:
Hi, I'm coming over from Java to C++, so please bear with me. In C++, is there a way for me to use exceptions to catch segmentation faults (e.g. when I access a location off the end of an array)?...
27
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! ...
7
by: pycraze | last post by:
I would like to ask a question. How do one handle the exception due to Segmentation fault due to Python ? Our bit operations and arithmetic manipulations are written in C and to some of our...
3
by: madunix | last post by:
My Server is suffering bad lag (High Utlization) I am running on that server Oracle10g with apache_1.3.35/ php-4.4.2 Web visitors retrieve data from the web by php calls through oci cobnnection...
6
by: DanielJohnson | last post by:
int main() { printf("\n Hello World"); main; return 0; } This program terminate just after one loop while the second program goes on infinitely untill segmentation fault (core dumped) on...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
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...

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.