help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: I get a segmentation fault if I dont use printf


From: aamir
Subject: Re: I get a segmentation fault if I dont use printf
Date: 6 Jun 2006 14:23:34 -0700
User-agent: G2/0.2

> You have an error on line 42.  What is your program doing?  Post some
> sample code.

LOL. In fact my program is about more than 6000 lines and I really
don't know which part may have the problem but  I am quite surprised
that it runs normally if i put a printf statement.

Anyways, after using a debugger it showed me some memory leaks but I am
unable to understand this one. Debugger message is

==11474== Use of uninitialised value of size 8
==11474==    at 0x804F03B: FindTree(AnswerPoint, AvlNode*)
(avltree.cc:65)
==11474==    by 0x8049BED: main (prog2.cc:652)

And the part of avltree.cc looks like

=======================================================
        Position_tree
        FindTree( AnswerPoint X, AvlTree T )
        {
            if( T == NULL )
            {
                return NULL;
            }
            if( X.distance < T->Element.distance )  //  ==>debugger is
talking about this line
                return FindTree( X, T->Left );

            if( X.distance > T->Element.distance )
                return FindTree( X, T->Right );
            if(X.distance==T->Element.distance)
            {
                    if(X.pid==T->Element.pid)
                            return T;
                    else
                    {
                            if(X.pid>T->Element.pid)
                                    return FindTree(X,T->Right);
                            else
                                  return FindTree(X,T->Left);
                    }
            }
            return T;
        }
================================================

The line about which debugger is talking is shown in the above code.
But I have made it pretty sure that in prog.cc at line 652 , the
distance value is not unitialized.

Do you get some idea of where the error may be?

Regards,
Aamir



reply via email to

[Prev in Thread] Current Thread [Next in Thread]