Go to Post The 3 probably stands for the number of years this season will take off your life - JohnSchneider [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 12-10-2010, 04:10 PM
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
random segfault

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
Attached Files
File Type: zip debug stuff.zip (3.91 MB, 7 views)
__________________
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
  #2   Spotlight this post!  
Unread 12-11-2010, 04:27 PM
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
  #3   Spotlight this post!  
Unread 12-11-2010, 05:55 PM
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

Ah! Copy constructors! gotta love (read: hate) them!
__________________
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
  #4   Spotlight this post!  
Unread 12-11-2010, 10:44 PM
jhersh jhersh is offline
National Instruments
AKA: Joe Hershberger
FRC #2468 (Appreciate)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 1997
Location: Austin, TX
Posts: 1,006
jhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond repute
Re: random segfault

Quote:
Originally Posted by byteit101 View Post
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
Reply With Quote
  #5   Spotlight this post!  
Unread 12-12-2010, 02:39 AM
jhersh jhersh is offline
National Instruments
AKA: Joe Hershberger
FRC #2468 (Appreciate)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 1997
Location: Austin, TX
Posts: 1,006
jhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond repute
Re: random segfault

Quote:
Originally Posted by jhersh View Post
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.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Random? TexasFederation Programming 1 09-16-2007 01:47 PM
Random Stuff Brm789 Chit-Chat 11 11-20-2003 04:13 PM
How random is random???? archiver 1999 0 06-23-2002 09:59 PM
Random Marc P. Chit-Chat 138 02-13-2002 03:11 PM
Random Question... Jessica Boucher Chit-Chat 26 07-02-2001 09:37 PM


All times are GMT -5. The time now is 10:31 AM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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