Skip to content

SIGSEGV on SIGTERM: Crow's Server::stop() runs on two threads at once #249

Closed

Description

@jrosskopf

main's integration run on 3d20f55 (the v26.11.23 release commit) failed once: test_graceful_shutdown.py::TestShutdownWithAnAsyncTaskInFlight exited -11 after SIGTERM. Blocks the v26.11.23 tag.

Evidence: the server log shows Closing acceptor. 0x…4098 twice for the same acceptor, then the IO services, then nothing (no Exiting., no DuckLake detach).

Cause: APIServer::run polls the serving future every 20 ms and calls app.stop() once stop_requested_ is set, without stop_mutex_. APIServer::stop() sets that flag first and later calls app.stop() under the mutex. When both land together, two threads run Crow's Server::stop() concurrently (not thread-safe: both see the acceptor open and close the same socket, and stop the io_contexts in parallel).

Fix: the poll calls app.stop() only while holding stop_mutex_ (try_lock: if stop() holds it, that call issues app.stop() itself; the next tick retries, so the startup-window guarantee stays).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions