Skip to content

libvncserver: fix HTTP shutdown without httpDir#705

Open
marcofortina wants to merge 1 commit into
LibVNC:masterfrom
marcofortina:fix/http-shutdown-without-httpdir
Open

libvncserver: fix HTTP shutdown without httpDir#705
marcofortina wants to merge 1 commit into
LibVNC:masterfrom
marcofortina:fix/http-shutdown-without-httpdir

Conversation

@marcofortina

@marcofortina marcofortina commented May 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes an HTTP shutdown crash when rfbShutdownServer(screen, TRUE) is called after server startup with screen->httpDir == NULL and no client has connected.

The HTTP init path marked httpInitDone = TRUE before returning early for a missing httpDir, but the HTTP client mutexes were initialized only later. Shutdown then tried to lock/destroy mutexes that had never been initialized, which is especially visible on Windows CRITICAL_SECTION.

Changes

  • Initialize the HTTP client mutexes immediately after HTTP init is marked done.
  • Make rfbHttpShutdownSockets() return early when HTTP was never initialized.
  • Reset httpInitDone during HTTP shutdown to avoid repeated shutdown work on already-destroyed HTTP mutexes.
  • Add a regression test covering rfbInitServer() followed by rfbShutdownServer() with httpDir == NULL and no connected clients.

Validation

cmake -S . -B build-704-patch \
  -DWITH_EXAMPLES=OFF \
  -DWITH_TESTS=ON \
  -DWITH_OPENSSL=OFF \
  -DWITH_GNUTLS=OFF \
  -DWITH_GCRYPT=OFF \
  -DWITH_SDL=OFF \
  -DWITH_GTK=OFF \
  -DWITH_QT=OFF \
  -DWITH_FFMPEG=OFF \
  -DWITH_XCB=OFF \
  -DWITH_LIBSSHTUNNEL=OFF \
  -DWITH_SYSTEMD=OFF \
  -DCMAKE_BUILD_TYPE=Debug

cmake --build build-704-patch --parallel 1
ctest --test-dir build-704-patch --output-on-failure

Result:

100% tests passed, 0 tests failed out of 6

Notes

Closes #704

@marcofortina marcofortina force-pushed the fix/http-shutdown-without-httpdir branch from 1b08b96 to 9ea8d7f Compare June 6, 2026 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash on rfbShutdownServer() when no client has connected

2 participants