mockingbirdnest / Principia

𝑛-Body and Extended Body Gravitation for Kerbal Space Program
MIT License
746 stars 67 forks source link

Fix a race between the code and the test for Vessel #4013

Closed pleroy closed 1 month ago

pleroy commented 1 month ago

The scenario is this:

  1. The test thread calls RefreshPrediction here.
  2. It gets suspended after calling Start here but before calling Get.
  3. The prognosticator thread executes FlowPrognostication here, and consumes the WillOnce expectation here. This results in a proper prognostication, but that one is not picked up because the test thread is still suspended.
  4. The prognosticator thread re-executes FlowPrognostication, but it now consumes the WillRepeatedly expectation here.
  5. The test thread finally wakes up and calls Get here. It now picks a prognostication to which nothing was appended, and is unable to make progress. It loops forever.

Fix #4010.