lib: don't abort when D-Bus send_with_reply leaves a NULL pending call - #575
Open
shawnyeager wants to merge 1 commit into
Open
shawnyeager wants to merge 1 commit into
shawnyeager wants to merge 1 commit into
Conversation
dbus_connection_send_with_reply() can return TRUE with a NULL DBusPendingCall when the connection is disconnected, or when the message carries unix fds the transport cannot send. The client then called dbus_pending_call_block(NULL), which aborts in libdbus. That is the gamescopereaper SIGABRT on exit when libgamemodeauto is preloaded: CloseAllFds closes the bus socket, UnregisterGame retries without pidfds, and the second send hits the NULL pending call. Return -1 instead of blocking on a NULL call. A meson test closes the session bus fd and calls UnregisterGame; it aborted without this change and exits 0 with it. Fixes FeralInteractive#347
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #347.
make_requestcalleddbus_pending_call_block(call)without checking thatsend_with_replyactually produced a pending call. libdbus documents thatdbus_connection_send_with_reply()can return TRUE while leaving*pending_returnNULL when the connection is disconnected, or when the message carries unix fds the transport cannot send. Blocking on that NULL handle aborts:That is the
gamescopereaperSIGABRT on process exit whenlibgamemodeautois inLD_PRELOAD(gamemoderun gamescope ...).gamescopereapercloses every fd except stdio (CloseAllFds) after the GameMode constructor has already opened the session bus. The destructor then callsUnregisterGame:send_with_replycreates a real pending call. The write hits the dead fd, libdbus disconnects, andmake_requestreturns -1.use_pidfs = 0) callsmake_requestagain. The connection is now known-disconnected, sosend_with_replyleavescall == NULL, anddbus_pending_call_block(NULL)aborts.Checking only the boolean return is not enough. This change also rejects
call == NULLand returns -1.meson testincludes a regression test that closes the session-bus socket withoutdbus_connection_close()and then callsUnregisterGame. Without the guard it dies with SIGABRT and the assertion above. With the guard it exits 0.Verified locally: