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

Check failure in the protector #2159

Closed
eggrobin opened this issue May 11, 2019 · 0 comments · Fixed by #2161
Closed

Check failure in the protector #2159

eggrobin opened this issue May 11, 2019 · 0 comments · Fixed by #2161
Labels
Milestone

Comments

@eggrobin
Copy link
Member

No journal; I was investigating another issue when this happened.

Log line format: [IWEF]mmdd hh:mm:ss.uuuuuu threadid file:line] msg
    @   00007FFBCB7A86B0  	principia::physics::internal_ephemeris::Ephemeris<principia::geometry::internal_frame::Frame<enum principia::serialization::Frame_PluginTag,7,1> >::Guard::~Guard [0x00007FFBCB7A86AF+31] (c:\users\robin\projects\mockingbirdnest\principia\physics\ephemeris_body.hpp:817)
    @   00007FFBA238FDC0  	principia::ksp_plugin::internal_vessel::Vessel::FlowPrognostication [0x00007FFBA238FDBF+1279] (c:\users\robin\projects\mockingbirdnest\principia\ksp_plugin\vessel.cpp:526)
    @   00007FFBA2391CB2  	principia::ksp_plugin::internal_vessel::Vessel::RepeatedlyFlowPrognostication [0x00007FFBA2391CB1+865] (c:\users\robin\projects\mockingbirdnest\principia\ksp_plugin\vessel.cpp:477)
    @   00007FFBA238699C  	std::_LaunchPad<std::unique_ptr<std::tuple<std::_Binder<std::_Unforced,void (__cdecl principia::base::ThreadPool<principia::base::Status>::*)(void),principia::base::ThreadPool<principia::base::Status> *> >,std::default_delete<std::tuple<std::_Binder<std:: [0x00007FFBA238699B+107] (c:\program files (x86)\microsoft visual studio\preview\community\vc\tools\msvc\14.15.26608\include\thr\xthread:230)
    @   00007FFBA231D099  	std::_Pad::_Call_func [0x00007FFBA231D098+8] (c:\program files (x86)\microsoft visual studio\preview\community\vc\tools\msvc\14.15.26608\include\thr\xthread:208)
    @   00007FFC0A23E3FE  	o_strcat_s [0x00007FFC0A23E3FD+93]
    @   00007FFC0B9D4034  	BaseThreadInitThunk [0x00007FFC0B9D4033+19]
    @   00007FFC0D433691  	RtlUserThreadStart [0x00007FFC0D433690+32]
F0511 12:22:45.519395 17088 protector.cpp:33] Check failed: 1 == protection_start_times_.erase(t_min) (1 vs. 2) 

Decoded stack trace:

void Vessel::RepeatedlyFlowPrognostication() {
std::optional<PrognosticatorParameters> previous_prognosticator_parameters;
for (;;) {
// No point in going faster than 50 Hz.
std::chrono::steady_clock::time_point const wakeup_time =
std::chrono::steady_clock::now() + std::chrono::milliseconds(20);
// The thread is only started after the parameters have been set, so we
// should always find parameters here.
std::optional<PrognosticatorParameters> prognosticator_parameters;
{
absl::ReaderMutexLock l(&prognosticator_lock_);
CHECK(prognosticator_parameters_);
prognosticator_parameters = prognosticator_parameters_;
}
if (prognosticator_parameters->shutdown) {
break;
}
// Do not reflow if the parameters have not changed: the same causes would
// produce the same effects.
if (!previous_prognosticator_parameters ||
*previous_prognosticator_parameters != prognosticator_parameters) {
std::unique_ptr<DiscreteTrajectory<Barycentric>> prognostication;
Status const status = FlowPrognostication(*prognosticator_parameters,
std::unique_ptr<DiscreteTrajectory<Barycentric>>& prognostication) {
// This function may be run in a separate thread, and bad things will happen
// if |EventuallyForgetBefore| runs in parallel with it: the ephemeris'
// |t_min| may end up being after the time that |FlowWithAdaptiveStep| tries
// to integrate, causing various check failures.
Ephemeris<Barycentric>::Guard g(ephemeris_);
prognostication = std::make_unique<DiscreteTrajectory<Barycentric>>();
prognostication->Append(
prognosticator_parameters.first_time,
prognosticator_parameters.first_degrees_of_freedom);
Status status;
status = ephemeris_->FlowWithAdaptiveStep(
prognostication.get(),
Ephemeris<Barycentric>::NoIntrinsicAcceleration,
ephemeris_->t_max(),
prognosticator_parameters.adaptive_step_parameters,
FlightPlan::max_ephemeris_steps_per_frame,
/*last_point_only=*/false);
bool const reached_t_max = status.ok();
if (reached_t_max) {
// This will prolong the ephemeris by |max_ephemeris_steps_per_frame|.
status = ephemeris_->FlowWithAdaptiveStep(
prognostication.get(),
Ephemeris<Barycentric>::NoIntrinsicAcceleration,
InfiniteFuture,
prognosticator_parameters.adaptive_step_parameters,
FlightPlan::max_ephemeris_steps_per_frame,
/*last_point_only=*/false);
}
LOG_IF(INFO, !status.ok())
<< "Prognostication from " << prognosticator_parameters.first_time
<< " finished at " << prognostication->last().time() << " with "
<< status.ToString() << " for " << ShortDebugString();
return status;
Ephemeris<Frame>::Guard::~Guard() {
ephemeris_->protector_->Unprotect(t_min_);

void Protector::Unprotect(Instant const& t_min) {
std::vector<Callback> callbacks_to_run;
{
absl::MutexLock l(&lock_);
CHECK_EQ(1, protection_start_times_.erase(t_min));

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

Successfully merging a pull request may close this issue.

2 participants