|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Calling LiveWindow::GetInstance() during static initialization causes program crash
I've been trying out a new way of organizing my team's code, which involves initializing subsystems during static initialization. Unfortunately, if I initialize a Talon statically in a namespace, the program crashes. Monitoring the output via netconsole gives this:
Quote:
Code:
staticProvider = new NetworkTableProvider(*(staticNode = mode->CreateNode(ipAddress.c_str(), port, threadManager, streamFactory, streamDeleter, typeManager))); |
|
#2
|
||||||
|
||||||
|
Re: Calling LiveWindow::GetInstance() during static initialization causes program cra
This sounds similar to the following bug, although no details are given: http://firstforge.wpi.edu/sf/go/artf1653 or maybe this one: http://firstforge.wpi.edu/sf/go/artf1644
Last edited by Joe Ross : 13-01-2014 at 20:34. |
|
#3
|
|||
|
|||
|
Re: Calling LiveWindow::GetInstance() during static initialization causes program cra
Yeah, it looks like those are the same issue. I wonder if there's any plan to address that in the near future.
|
|
#4
|
||||
|
||||
|
Re: Calling LiveWindow::GetInstance() during static initialization causes program cra
None of the initialization rules are documented as far as I can tell. If anyone comes across something that says what they are I would love to know too.
|
|
#5
|
|||
|
|||
|
Re: Calling LiveWindow::GetInstance() during static initialization causes program cra
There's an issue where statically initialized classes are not created in any specific order. So that means that variables, in particular, lists of the sensors and speed controllers might not have been initialized when the static classes are created.
The best solution is to try to not create WPILib objects statically and instead make them class members. Then you can initialize them from the heap using new or as class members. This makes sure that they don't get initialized before the underlying WPILib code starts up. But we're looking at the problem now. May be an update. |
|
#6
|
|||
|
|||
|
Re: Calling LiveWindow::GetInstance() during static initialization causes program cra
Just curious, what variables are actually being initialized statically to cause this bug? I couldn't seem to track them down.
|
|
#7
|
|||
|
|||
|
Re: Calling LiveWindow::GetInstance() during static initialization causes program cra
Quote:
SimpleRobot's constructor invokes base class RobotBase constructor, which invokes DriverStation::GetInstance(), which ultimately leads to NetworkTables::Initialize() which crashes for the reasons described herein. So unless I'm missing something obvious, the current C++ RobotBase is unusable, since it has to be statically initialized via START_ROBOT_CLASS. I'd love to know if there's a work around for this; it seems like a pretty serious problem that's got me stopped in my tracks.... |
|
#8
|
|||
|
|||
|
Re: Calling LiveWindow::GetInstance() during static initialization causes program cra
Quote:
|
|
#9
|
|||
|
|||
|
Re: Calling LiveWindow::GetInstance() during static initialization causes program cra
Quote:
I believe this was happening because I was using a project created with last year's Sample Project creator in WindRiver, even though I'd updated to the latest 2014 release of the FRC C++ Update. When I recreated the project (same process, but it was created after the 2014 update was installed into windriver), I'm not seeing this issue. My apologies if I've wasted anyone's energy or time. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|