Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   random segfault (http://www.chiefdelphi.com/forums/showthread.php?t=87871)

byteit101 10-12-2010 16:10

random segfault
 
1 Attachment(s)
I appear to be encountering a very odd segfault. I have this method, and some odd output.
Methods:
Code:

string ZomBDashboard::GetString(string name)
{
    if (src != NULL)
    {
        debugf("Getting string.. (Deref: %p;", src);
        System451::Communication::Dashboard::ZomBTCPSource &ts = *((System451::Communication::Dashboard::ZomBTCPSource*)src);
        debugf(" deref OK, con: %d)", ts.connected);
        return ts.Get(name);//or, src->Get(name)
    }
    return "";
}
...
const char* System451::Communication::Dashboard::ZomBTCPSource::Get(string name)
{
    debugf(". in, \n");
    Synchronized sync (sink);
    return curvalues[name];
}

Output:
Code:

Getting string.. (Deref: 0xsomememoryaddressthatappearsvalid; deref OK, con: 4)

data access
(generic vxworks error info)

and sometimes
Code:

Getting string.. (Deref: 0xsomememoryaddressthatappearsvalid;

data access
(generic vxworks error info)

I tried using Debug Kernel Task, but WR just paused updating all the panels to new info, so it was essentially useless.

The robot code is attached in MyRobot.cpp and the C++ Bindings folder. The dashboard is Dashboard.exe and ZomB.dll (you might have to launch it twice), and when all is working, moving the slider on the left should move the slider on the right.

if you feel like compiling ZomB, download all the code (in the trunk) at http://firstforge.wpi.edu/integratio...ystem=exsy1002 and copy the DashboardDataHub.cs in the zip into ZomBdll\NetAndDataProcessing

byteit101 11-12-2010 16:27

Re: random segfault
 
1 Attachment(s)
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 "";
}


byteit101 11-12-2010 17:55

Re: random segfault
 
Ah! Copy constructors! gotta love (read: hate) them!

jhersh 11-12-2010 22:44

Re: random segfault
 
Quote:

Originally Posted by byteit101 (Post 984951)
Output attached (how does one copy and paste the text from the NetConsole? I could not get a sticking selection)

Just select the text... when you let go, it's copied. To paste, middle click.

-Joe

jhersh 12-12-2010 02:39

Re: random segfault
 
Quote:

Originally Posted by jhersh (Post 985003)
Just select the text... when you let go, it's copied. To paste, middle click.

-Joe

By the way, the reason for this is so that you can hit <ctrl-c> and it will send that code to the cRIO instead of being processed by the console window.


All times are GMT -5. The time now is 13:36.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi