Skip to content

fix: cope with failure checking client status#2298

Merged
frankiejol merged 1 commit intomainfrom
fix/2293_status
Feb 27, 2026
Merged

fix: cope with failure checking client status#2298
frankiejol merged 1 commit intomainfrom
fix/2293_status

Conversation

@frankiejol
Copy link
Member

closes #2293

@frankiejol frankiejol added this to the v2.4.6 milestone Feb 27, 2026
Copilot AI review requested due to automatic review settings February 27, 2026 11:33
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to prevent script/rvd_back from crashing during nightly hibernation when verifying a VM’s viewer connection status, addressing issue #2293.

Changes:

  • Wraps client_status(1) calls in _verify_connection with an eval block.
  • Defaults status to 'disconnected' on failure and emits a warning when an exception occurs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +825 to +828
eval {
$status = $domain->client_status(1);
};
warn "Error checking ".$domain_f->name." $@" if $@;
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

The issue report indicates a segmentation fault (core dump). Wrapping client_status in eval will only catch Perl exceptions (die/confess) and will not prevent a true segfault in XS/C code; the process would still crash. If the crash is a real segfault, consider moving the status check into a separate child process (fork/IPC) or fixing/guarding the underlying XS call path so a failure can be handled without taking down rvd_back.

Copilot uses AI. Check for mistakes.
eval {
$status = $domain->client_status(1);
};
warn "Error checking ".$domain_f->name." $@" if $@;
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

On exception, this code leaves $status as 'disconnected', which makes _verify_connection likely return 0 and allow shutdown/hibernate to proceed even though the connection status could not be verified. To avoid mistakenly acting on a VM when the check is failing, consider treating an exception as "unknown/connected" (eg return 1 to dismiss shutdown) or short-circuiting to skip the domain with a warning so the caller doesn’t interpret a failed check as a confirmed disconnect.

Suggested change
warn "Error checking ".$domain_f->name." $@" if $@;
if ($@) {
warn "Error checking ".$domain_f->name." $@";
print "\n" if $VERBOSE;
# Treat exceptions as "unknown/connected" to avoid unsafe shutdown.
return 1;
}

Copilot uses AI. Check for mistakes.
Comment on lines +824 to +828
my $status = 'disconnected';
eval {
$status = $domain->client_status(1);
};
warn "Error checking ".$domain_f->name." $@" if $@;
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

warn "Error checking ... $@" is inside the retry loop, so a persistent failure will emit up to $TIME_CONNECTION warnings per domain; also $@ is global and can leak/clobber other error handling. Consider localizing $@ (eg local $@;) and only warning once per domain (or only under $VERBOSE) to keep logs actionable.

Copilot uses AI. Check for mistakes.
@frankiejol frankiejol merged commit 63e1392 into main Feb 27, 2026
5 checks passed
@frankiejol frankiejol deleted the fix/2293_status branch February 27, 2026 11:51
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

Successfully merging this pull request may close these issues.

Verify client status core dumped

2 participants