Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ SmartDashboard::init() isn't called until StartCompetition #427

Closed
PeterJohnson opened this issue Dec 30, 2016 · 2 comments
Closed

C++ SmartDashboard::init() isn't called until StartCompetition #427

PeterJohnson opened this issue Dec 30, 2016 · 2 comments
Milestone

Comments

@PeterJohnson
Copy link
Member

While other globals are initialized prior to user class construction, SmartDashboard is not, so if the user class (or any of its instance variables) try to call a SmartDashboard function from within their constructors (rather than e.g. from RobotInit() or later), a crash will result.

The fix should be straightforward: move the SmartDashboard::init() call to either START_ROBOT_CLASS or the RobotBase constructor.

@PeterJohnson PeterJohnson added this to the 2017 milestone Dec 30, 2016
calcmogul added a commit to calcmogul/allwpilib that referenced this issue Dec 30, 2016
calcmogul added a commit to calcmogul/allwpilib that referenced this issue Dec 30, 2016
calcmogul added a commit to calcmogul/allwpilib that referenced this issue Dec 30, 2016
@bradamiller
Copy link
Contributor

Does this solution still work if someone creates a static (global) instance of an object? Those constructors run before any other code is run, and in random order.

@PeterJohnson
Copy link
Member Author

No. A static global instance will run even before HAL_initialize gets called. There's really not much we can do about that case, other than to document "don't do that", unless we want to add initialization checks everywhere that pessimize performance for everyone just to fix that corner case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants