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

Hard force a crash on a failure for SetupNowRio() and wpi::Now() when not configured #6417

Merged
merged 4 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions hal/src/main/native/athena/HAL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,14 @@ HAL_Bool HAL_Initialize(int32_t timeout, int32_t mode) {
});

if (!SetupNowRio()) {
fmt::print(stderr,
"Failed to run SetupNowRio(). This is a fatal error. The "
"process is being terminated.\n");
std::fflush(stderr);
Copy link
Member

@calcmogul calcmogul Mar 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we set stderr to buffered somewhere? It's unbuffered by default, which would make std::fflush() redundant.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doubt it, but it also doesn't hurt to do it...

// Attempt to force a segfault to get a better java log
*reinterpret_cast<int*>(0) = 0;
// If that fails, terminate
std::terminate();
return false;
}

Expand Down
17 changes: 8 additions & 9 deletions wpiutil/src/main/native/cpp/timestamp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,15 +273,14 @@ uint64_t wpi::Now() {
if (nowUseDefaultOnFailure.test()) {
return timestamp() - offset_val;
} else {
static uint64_t last = 0;
uint64_t cur = timestamp();
if ((cur - last) > 100000) {
last = cur;
fmt::print(stderr,
"FPGA not yet configured in wpi::Now(). Time will not be "
"correct.\n");
std::fflush(stderr);
}
fmt::print(stderr,
"FPGA not yet configured in wpi::Now(). This is a fatal "
"error. The process is being terminated.\n");
std::fflush(stderr);
// Attempt to force a segfault to get a better java log
*reinterpret_cast<int*>(0) = 0;
// If that fails, terminate
std::terminate();
return 1;
}
}
Expand Down
Loading