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:
* Loading FRC_UserProgram.out: FRC_UserProgram
[NT] NetworkTable::GetTable()...
[NT] Initializing...
[NT] NetworkTable::CheckInit()...
[NT] NetworkTable::Initialize()...
program
Exception current instruction address: 0x00000000
Machine Status Register: 0x0008b012
Condition Register: 0x24004282
Task: 0xb6ec60 "Main Application Thread"
0xb6ec60 (Main Application Thread): task 0xb6ec60 has had a failure and has been stopped.
0xb6ec60 (Main Application Thread): fatal kernel task-level exception!
|
That last message before the exception comes right before this function call in the NetworkTables code:
Code:
staticProvider = new NetworkTableProvider(*(staticNode = mode->CreateNode(ipAddress.c_str(), port, threadManager, streamFactory, streamDeleter, typeManager)));
Which is called because a NetworkTable::GetTable() call in LiveWindow::LiveWindow() called by LiveWindow::GetInstance() checks to see if NetworkTable::staticProvider is NULL, and if so, creates it. Moving the initialization to the RobotInit() function fixes the problem, and the messages related to setting NetworkTable::staticProvider are not displayed. So basically, my question is this: Where does NetworkTable::staticProvider get set, and is there a way around this, short of intializing in RobotInit?