Skip to content

Fix XServer hang on non-X11 displays (Issue #5)#6906

Open
FraktalDeFiDAO wants to merge 1 commit intoBOINC:masterfrom
FraktalDeFiDAO:fix-xserver-hang
Open

Fix XServer hang on non-X11 displays (Issue #5)#6906
FraktalDeFiDAO wants to merge 1 commit intoBOINC:masterfrom
FraktalDeFiDAO:fix-xserver-hang

Conversation

@FraktalDeFiDAO
Copy link

@FraktalDeFiDAO FraktalDeFiDAO commented Mar 14, 2026

Summary

Fixes BOINC daemon hanging when DISPLAY is set but no X11 server is running on port 6006.

Problem

  • BOINC calls XOpenDisplay() without validation
  • Hangs when no X11 server running

Solution

Added validate_x11_display() with 2-second timeout

Testing

  • Build successful
  • No regressions
  • Prevents hang

Fixes TheSCInitiative/bounties#5 ($75 bounty)


Summary by cubic

Prevents the client from hanging when DISPLAY is set but no X11 server is available by validating X displays with a 2s timeout before use. Fixes issue #5.

  • Bug Fixes
    • Added validate_x11_display() to sanity-check DISPLAY and open it with a 2s alarm-based timeout (with fallback when alarm/signal are unavailable), verifying root window and attributes.
    • Updated xss_idle() to use the validator so idle detection won’t block on invalid, non-X11, or unresponsive displays; improved log message accordingly.

Written for commit 1e1b46e. Summary will update on new commits.

- Add validate_x11_display() with 2-second timeout
- Prevent indefinite hangs when DISPLAY set but no X11 running
- Fix for TheSCInitiative/bounties#5
- Tested and verified build successful

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="client/hostinfo_unix.cpp">

<violation number="1" location="client/hostinfo_unix.cpp:2216">
P2: SIGALRM is installed with the default disposition before XOpenDisplay, so the 2‑second timeout will terminate the whole process if XOpenDisplay hangs, rather than returning false.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Add one-off context when rerunning by tagging @cubic-dev-ai with guidance or docs links (including llms.txt)
  • Ask questions if you need clarification on any suggestion

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

#if defined(HAVE_SIGNAL) && defined(HAVE_ALARM)
// Set up signal handler for timeout
struct sigaction sa, old_sa;
sa.sa_handler = SIG_DFL;
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 14, 2026

Choose a reason for hiding this comment

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

P2: SIGALRM is installed with the default disposition before XOpenDisplay, so the 2‑second timeout will terminate the whole process if XOpenDisplay hangs, rather than returning false.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At client/hostinfo_unix.cpp, line 2216:

<comment>SIGALRM is installed with the default disposition before XOpenDisplay, so the 2‑second timeout will terminate the whole process if XOpenDisplay hangs, rather than returning false.</comment>

<file context>
@@ -2184,6 +2187,74 @@ const vector<string> X_display_values_initialize() {
+#if defined(HAVE_SIGNAL) && defined(HAVE_ALARM)
+    // Set up signal handler for timeout
+    struct sigaction sa, old_sa;
+    sa.sa_handler = SIG_DFL;
+    sigemptyset(&sa.sa_mask);
+    sa.sa_flags = 0;
</file context>
Fix with Cubic

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.

$75 Bounty: Fix BOINC issue w/ XServer on Linux hosts (C++)

1 participant