Thread: random segfault
View Single Post
  #2   Spotlight this post!  
Unread 11-12-2010, 16:27
byteit101's Avatar
byteit101 byteit101 is offline
WPILib maintainer (WPI)
AKA: Patrick Plenefisch
no team (The Cat Attack (Formerly))
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Worcester
Posts: 699
byteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of light
Re: random segfault

I've debugged it some more, and I am completely confused.
a variable is changing its address without being updated!
I have the src variable, which is a pointer to a interface, and is assigned either null, or a new TCPsender. I then print out the pointer address, and it looks good.
Later, after i'm enabled and in the telop function, I call GetString, and print out the address, then try to deref src, and ultimatly fail because somehow, src changed even though those are the only two active lines of code that reference src.
Output attached (how does one copy and paste the text from the NetConsole? I could not get a sticking selection)
Code:
Code:
        void OperatorControl(void)
        {
            cerr<<"IN oc"<<endl;
            int loops=0;
            while (IsEnabled())
            {
                cerr<<"looping";
                cerr<<zb.GetString("ival")<<endl;
            }
        }
Constructor
Code:
    if ((mode & RemoteData) == RemoteData)
        src = new System451::Communication::Dashboard::ZomBTCPSource();
    else
        src = 0;
    debugf("init: src=%p\r\n", src);
Code:
string ZomBDashboard::GetString(string name)
{
    if (src)
    {
        debugf("\r\ngsi: src=%p\r\n", src);
        return src->Get(name);
    }
    return "";
}
Attached Thumbnails
Click image for larger version

Name:	ncpointererr.PNG
Views:	12
Size:	26.4 KB
ID:	9489  
__________________
Bubble Wrap: programmers rewards
Watchdog.Kill();
printf("Watchdog is Dead, Celebrate!");
How to make a self aware robot: while (∞) cout<<(sqrt(-∞)/-0);
Previously FRC 451 (The Cat Attack)
Now part of the class of 2016 at WPI & helping on WPILib
Reply With Quote