473,387 Members | 1,585 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,387 software developers and data experts.

gcb output

Hello.

I wrote a litte program, that generates a SIGSEGV after a while.
parse_umfeld is my method. It runs through about 330 times without error,
but the next time, call to strlen (from within parse_umfeld) generates a
SIGSEGV.

How could I find out, why exactly the problem occures?

gdb bt gives:

Program received signal SIGSEGV, Segmentation fault.
0xb7e30173 in strlen () from /lib/tls/i686/cmov/libc.so.6
(gdb) bt
#0 0xb7e30173 in strlen () from /lib/tls/i686/cmov/libc.so.6
#1 0x0804a20a in c_Parser::parse_umfeld (this=0x8050050,
buffer=0x8053c8b
"<Feld><Boden>Rasen</Boden><Ameise><Typ>Rot</Typ><ID>1</ID><Blickrichtung>NO</Blickrichtung><Angegriffen>0</Angegriffen></Ameise></Feld><Feld><Boden>Rasen</Boden></Feld><Feld><Boden>Rasen</Boden></Feld"...)
at c_Parser.cpp:69
<snip>

What does entry #0 mean?

Regards,
Flo
Jul 22 '05 #1
2 1955
Florian Quetting wrote:

Hello.

I wrote a litte program, that generates a SIGSEGV after a while.
parse_umfeld is my method. It runs through about 330 times without error,
but the next time, call to strlen (from within parse_umfeld) generates a
SIGSEGV.

The problem with things like that is, that the actual program crash
is only lousy connected with the real problem. In other words: you
see the symptoms, but not the cause. You can bet your ass, that
nothing is wrong with strlen, but with the pointer you feed
to it.
How could I find out, why exactly the problem occures?

gdb bt gives:

Program received signal SIGSEGV, Segmentation fault.
0xb7e30173 in strlen () from /lib/tls/i686/cmov/libc.so.6
(gdb) bt
#0 0xb7e30173 in strlen () from /lib/tls/i686/cmov/libc.so.6
#1 0x0804a20a in c_Parser::parse_umfeld (this=0x8050050,
buffer=0x8053c8b
"<Feld><Boden>Rasen</Boden><Ameise><Typ>Rot</Typ><ID>1</ID><Blickrichtung>NO</Blickrichtung><Angegriffen>0</Angegriffen></Ameise></Feld><Feld><Boden>Rasen</Boden></Feld><Feld><Boden>Rasen</Boden></Feld"...)
at c_Parser.cpp:69
<snip>

What does entry #0 mean?


Forget it.
Concentrate on the string you feed to strlen().
It obviously is not '\0' terminated. The question is: Why?
You need to start with that problem. Eg. you could:
for testing purposes assume that this string is never longer
then eg. 1024 characters. You then could write your own
version of strlen, which checks for that and alert you.

Things like that are hard to diagnose. This is why professionals
recommend a different way of development: development in small
steps. Only add small code sections at a time and test them until
you are very certain that they work ok. If you discover a bug you
can be very sure that it is somehow related to the last additions
you made. Since the last additions are relatively small (remember:
small steps), it is far easier to find the problem.

Also: Why are you using C-style strings instead of std::string ?

Also: You are aware that there are working XML readers available
for free?

--
Karl Heinz Buchegger
kb******@gascad.at
Jul 22 '05 #2
Florian Quetting wrote:
Hello.

I wrote a litte program, that generates a SIGSEGV after a while.
parse_umfeld is my method. It runs through about 330 times without error,
but the next time, call to strlen (from within parse_umfeld) generates a
SIGSEGV.

How could I find out, why exactly the problem occures?

gdb bt gives:

Program received signal SIGSEGV, Segmentation fault.
0xb7e30173 in strlen () from /lib/tls/i686/cmov/libc.so.6
(gdb) bt
#0 0xb7e30173 in strlen () from /lib/tls/i686/cmov/libc.so.6
#1 0x0804a20a in c_Parser::parse_umfeld (this=0x8050050,
buffer=0x8053c8b
"<Feld><Boden>Rasen</Boden><Ameise><Typ>Rot</Typ><ID>1</ID><Blickrichtung>NO</Blickrichtung><Angegriffen>0</Angegriffen></Ameise></Feld><Feld><Boden>Rasen</Boden></Feld><Feld><Boden>Rasen</Boden></Feld"...)
at c_Parser.cpp:69
<snip>

What does entry #0 mean?

Regards,
Flo


You should find some gdb references online that explain this in more
detail. Briefly, as your program runs, the function main() runs, which
calls other functions, which may in turn call still other functions, and
so forth. #0 shows where the error occured: strlen(), #1 shows where
the call was made to strlen() in parse_umfeld, #2 shows where
parse_umfeld was called, and so forth. You can use the gdb commands
"up" and "down" to move between these "frames" and, within any given
frame, you can examine variables with the "print" command.

Like I said, though, you'll probably need to find some sort of tutorial
to get you started using gdb effectively.
Jul 22 '05 #3

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

Similar topics

4
by: Mark Wilson CPU | last post by:
This must be easy, but I'm missing something... I want to execute a Perl script, and capture ALL its output into a PHP variable. Here are my 2 files: -------------------------------------...
3
by: edgekaos | last post by:
Is method 2 valid? Method 1: wstring input = L"STRING"; wstring output = input; transform(output.begin(), output.end(), output.begin(), towupper); Method 2: wstring input = L"STRING";...
4
by: Kevin Mansel via .NET 247 | last post by:
Ok, basically this is my problem. I'm building a console app tocall a dos program. So i'm using the Shell command to call theprogram, now depending on what happens, I want to read theoutput that...
24
by: kalamantina | last post by:
#include "stdafx.h" #include <stdio.h> #define output( x ) printf( #x "\r\n" );fflush( stdout ) class CMyBase { public: CMyBase() { output( CMyBase() ); f(*this);
0
by: newbie | last post by:
i'm a newbie of c language. can anyone help me to implement the code so that I can get the ciphertext from the output. thanks. #ifndef _3DES_H #define _3DES_H #ifndef uint8 #define uint8 ...
32
by: spibou | last post by:
Is the output of the C preprocessor deterministic ? What I mean by that is , given 2 compilers which conform to the same standard, will their preprocessors produce identical output given as input...
3
by: MatsL | last post by:
Hi, This is seriously driving me crazy, could anyone explain to me why neither of these doesn't produce XHTML compliant output (it is being called in Render() btw): output.WriteLine("<img...
3
by: undshan | last post by:
I am writing a code that needs to open a file, create an output file, run through my function, prints the results to the output file, and closes them within a loop. Here is my code: #include...
5
by: amit.uttam | last post by:
Hey everyone, I've recently jumped big time into python and I'm working on a software program for testing automation. I had a question about proper logging of output. What I would like is: 1....
2
by: gabosom | last post by:
Hi! I've been breaking my head trying to get the output variables from my Stored Procedure. This is my SP code CREATE PROCEDURE GetKitchenOrderDetail( @idService int, --outPut Variables ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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?
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
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,...
0
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,...
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...

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.