Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   NetworkTable crash in unmodified SimpleRobot template (http://www.chiefdelphi.com/forums/showthread.php?t=110627)

IBeMad 07-01-2013 01:07

NetworkTable crash in unmodified SimpleRobot template
 
I'm getting a null pointer exeption in
Code:

NetworkTable::Initialize()
on the following line:

Code:

staticProvider = new NetworkTableProvider(*(mode->CreateNode(ipAddress.c_str(), port, threadManager)));
This crash occurs in unmodified SimpleRobotTemplate code. How does something like this even get through QA, or is there even any QA to begin with? Sure seems like there isn't any...

Earlier on in the call stack, the crash stems from
Code:

SimpleRobot::StartCompetition()
when it calls

Code:

LiveWindow *lw = LiveWindow::GetInstance();
which creates a new instance of LiveWindow since it's the first time GetInstance() is called, which results in it calling
Code:

NetworkTable::GetTable("LiveWindow")
.

When will this be fixed in WPILib, and how can I work around it in the meantime?

mitchellweb1 07-01-2013 10:38

Re: NetworkTable crash in unmodified SimpleRobot template
 
Hi,

Are you sure that this is unmodified. We just ran the template project again and it worked fine. If you are still having issues would it be possible to do a little more debugging and figure out exactly what is null on that line.

--Mitchell

IBeMad 07-01-2013 13:39

Re: NetworkTable crash in unmodified SimpleRobot template
 
Quote:

Originally Posted by mitchellweb1 (Post 1209778)
Hi,

Are you sure that this is unmodified. We just ran the template project again and it worked fine. If you are still having issues would it be possible to do a little more debugging and figure out exactly what is null on that line.

--Mitchell

Yes, I'm sure that it's umodified. I guess I'll just have to fix the bug in WPILib myself and submit it.

Alan Anderson 07-01-2013 15:58

Re: NetworkTable crash in unmodified SimpleRobot template
 
I suggest that you reinstall the WindRiver update before blaming the library itself.

IBeMad 07-01-2013 21:47

Re: NetworkTable crash in unmodified SimpleRobot template
 
Quote:

Originally Posted by Alan Anderson (Post 1210029)
I suggest that you reinstall the WindRiver update before blaming the library itself.

No luck reinstalling everything, however it does work on other computers. Just not mine. Any other ideas?

mitchellweb1 07-01-2013 22:32

Re: NetworkTable crash in unmodified SimpleRobot template
 
If you could run the debugger and determine what value on that line is null then I may be able to try to help a little more.

Fifthparallel 08-01-2013 01:48

Re: NetworkTable crash in unmodified SimpleRobot template
 
Code:

staticProvider = new NetworkTableProvider(*(mode->CreateNode(ipAddress.c_str(), port, threadManager)));
Out of curiosity, why is there an asterisk in the argument for NetworkTableProvider? (I always get hazy around dereference operators)

Anyway, a null pointer exception would seem to indicate that something on that line is an uninitialized pointer. How/where did you declare staticProvider?

nightpool 08-01-2013 09:30

Re: NetworkTable crash in unmodified SimpleRobot template
 
Quote:

Originally Posted by Fifthparallel (Post 1210498)
Code:

staticProvider = new NetworkTableProvider(*(mode->CreateNode(ipAddress.c_str(), port, threadManager)));
Out of curiosity, why is there an asterisk in the argument for NetworkTableProvider? (I always get hazy around dereference operators)

Anyway, a null pointer exception would seem to indicate that something on that line is an uninitialized pointer. How/where did you declare staticProvider?

Well, not looking at the lib or anything, but it seems pretty clear that CreateNode returns a pointer, but the NetworkTableProvider constructor expects a value.

Fifthparallel 08-01-2013 10:08

Re: NetworkTable crash in unmodified SimpleRobot template
 
It looks like it expects an address to a node -- and if createNode returns a pointer, he has an asterisk in there that he doesn't need. I think that's the cause of his null pointer exception -- that asterisk creates an uninitialized pointer.

mitchellweb1 08-01-2013 11:39

Re: NetworkTable crash in unmodified SimpleRobot template
 
createNode will always return a non-null pointer. The NetworkTableProvider constructor takes a reference to the pointer type returned by createNode. This code has run fine on under linux and the crio so it is weird that it is failing here.

staticProvider is declared in NetworkTable.h

StephenNutt 08-01-2013 14:03

Re: NetworkTable crash in unmodified SimpleRobot template
 
Could ipAddress contain the null string? If so, ipAddress.c_str() would return nullptr.

nightpool 08-01-2013 14:21

Re: NetworkTable crash in unmodified SimpleRobot template
 
Quote:

Originally Posted by StephenNutt (Post 1210753)
Could ipAddress contain the null string? If so, ipAddress.c_str() would return nullptr.

This may be the issue. It probably stems from misconfiguration of the cRio or laptop. You should double check what team number you formatted it with.

masoug 08-01-2013 23:59

Re: NetworkTable crash in unmodified SimpleRobot template
 
We were running into the same exact problem with our code but instead of WindRiver we were using makefiles similar to UCPP to compile our code (we don't have problems if we compile with WindRiver).

Quote:

Originally Posted by StephenNutt (Post 1210753)
Could ipAddress contain the null string? If so, ipAddress.c_str() would return nullptr.

We tried setting the ipAddress variable to our robot's ip address manually, but that didn't fix the problem and since the its a server, the ipAdress seems meaningless.

Quote:

Originally Posted by nightpool (Post 1210767)
This may be the issue. It probably stems from misconfiguration of the cRio or laptop. You should double check what team number you formatted it with.

We double-check the same thing too, but the error is still there. Did you have a particular configuration in mind?

When we were debugging the same issue, we found that both the mode and threadManager store non-null addresses. But whenever mode->CreateNode() was called, the null pointer error resurfaces. The variable mode is of type NetworkTableMode, so we replaced the code with
Code:

staticProvider = new NetworkTableProvider(NetworkServerMode::Server.CreateNode(ipAddress.c_str(), port, threadManager));
which still results in an error.

We are totally baffled; we just commented the livewindow stuff out as workaround but ultimately we need to figure out why this happens. Any additional suggestions? I remember there being a debugger that runs on the cRIO, but I'm not sure how that works.

Thanks!
-Masoug

PaulDavis1968 09-01-2013 01:00

Re: NetworkTable crash in unmodified SimpleRobot template
 
Is there documentation that explains how the c++ networktable stuff works?

mitchellweb1 09-01-2013 16:08

Re: NetworkTable crash in unmodified SimpleRobot template
 
I have been unable to reproduce this problem. Try replacing ipAddress.c_str() with just "". It is actually ignored when in server mode (which it is always when running on the crio)


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

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