canonical / canonical/multipass
The HCS integration tests teardown code is racy
- Dominant language
- C++
- Stars
- 9.2k
- Forks
- 828
- Avg merge
- 3d 1h
- Merged PRs (30d)
- 44
Description
```
void TearDown() override
{
if (handle)
{
std::promise exited;
auto fut = exited.get_future();
ASSERT_TRUE(HCS().set_compute_system_callback(
handle,
&exited,
[](HCS_EVENT* event, void* context) {
ASSERT_NE(nullptr, event);
ASSERT_NE(nullptr, context);
if (hyperv::hcs::parse_event(event) == hyperv::hcs::HcsEventType::SystemExited)
{
static_cast*>(context)->set_value();
}
}));
const auto d_result = HCS().terminate_compute_system(handle);
ASSERT_TRUE(d_result);
std::wprintf(L"%s\n\n", d_result.status_msg.c_str());
handle.reset();
ASSERT_EQ(std::future_status::ready, fut.wait_for(std::chrono::seconds(180)))
<< "SystemExited callback not received within timeout";
}
}
```
Sometimes the fut.wait_for throws even though the callback is invoked, pointing to a potential race condition between the set/terminate calls.
Contributor guide
Research direction
Start with the HCS integration-test TearDown shown in the issue and trace the set_compute_system_callback and terminate_compute_system calls. Reproduce or inspect the fut.wait_for behavior around SystemExited callbacks. Done means teardown reliably waits for the callback without the race or timeout.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100