Skip to content

Commit

Permalink
(console/core) auth-chld dms ignore-race
Browse files Browse the repository at this point in the history
Thanks to Amadan-Pobretano-LaBoon for reporting.

This was only really visible from the context of authoritative launch
of a client that thereafter quite voluntarily. This is the case for
decode when you watch a clip to the end without enabling looping, and
when a terminal is exit through 'exit'. Normally, durden, pipeworld et
al. just flat out kills the client so this scenario would not occur.

When the primary segment shuts down and sets the dms, it was not chained
to arcan_frameserver_free correctly, as well as waitpid not handling the
case where the monitored child process do not exist. The later check is
one that still should be considered for removal, or making the contract
for authoritative/trusted launches that if the primary segment pid dies
we sever the connection.

This also fixes a problem with console.lua not respecting origo_ll
texture coordinates (this old story), e.g. when launching an arcan_lwa
client from the console.
  • Loading branch information
letoram committed Jun 19, 2021
1 parent 80f32d3 commit 8fc192b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
9 changes: 6 additions & 3 deletions data/appl/console/console.lua
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,13 @@ end
-- e.g. arcan_db add_appl_kv console terminal env=LC_ALL=C:palette=solarized
function spawn_terminal()
local term_arg = (
get_key("terminal") or "tpack:palette=solarized") ..
get_key("terminal") or "palette=solarized") ..
":env=ARCAN_CONNPATH=" .. connection_point

return launch_avfeed(term_arg, "terminal", client_event_handler)
return launch_avfeed(term_arg, "terminal",
function(source, status)
return client_event_handler(source, status)
end)
end

local function scale_client(ws, w, h)
Expand Down Expand Up @@ -241,6 +244,7 @@ function client_event_handler(source, status)
local w, h = scale_client(ws, status.width, status.height)
resize_image(source, w, h)
center_image(source, workspaces.anchor)
image_set_txcos_default(source, status.origo_ll)
ws.aid = status.source_audio
else
delete_image(source)
Expand Down Expand Up @@ -270,7 +274,6 @@ function client_event_handler(source, status)

wayland_connection(source,
function(source, status)
print("new client on connection", source)
local _, wl_cl = new_client(source, {block_mouse = true})
local cfg = wayland_config(wl_cl)
local cl = wayland_client(source, status, cfg)
Expand Down
5 changes: 2 additions & 3 deletions src/engine/arcan_frameserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ bool arcan_frameserver_control_chld(arcan_frameserver* src){
/* bunch of terminating conditions -- frameserver messes with the structure to
* provoke a vulnerability, frameserver dying or timing out, ... */
bool cookie_match = true;
bool alive = src->flags.alive && src->shm.ptr;
bool alive = src->flags.alive && src->shm.ptr && src->shm.ptr->dms;

/* specifically track the cookie failing issue so that we can forward that as an
* important failure reason since it is indicative of something more than just a
Expand Down Expand Up @@ -1366,8 +1366,7 @@ bool arcan_frameserver_tick_control(
arcan_frameserver* src, bool tick, int dst_ffunc)
{
bool fail = true;
if (!arcan_frameserver_control_chld(src) || !src || !src->shm.ptr ||
!src->shm.ptr->dms || src->playstate == ARCAN_PAUSED)
if (!arcan_frameserver_control_chld(src) || src->playstate == ARCAN_PAUSED)
goto leave;

/* Same event-queue transfer issues as marked elsewhere, if xfer-sat goes to
Expand Down
3 changes: 2 additions & 1 deletion src/platform/posix/frameserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,9 +421,10 @@ bool platform_fsrv_validchild(arcan_frameserver* src){
* to monitor as hint to what the state of a child is, the child is free to
* redirect to anything (heck, including init)..
*/
errno = 0;
int ec = waitpid(src->child, &status, WNOHANG);

if (ec == src->child){
if (ec == src->child || errno == ECHILD){
errno = EINVAL;
return false;
}
Expand Down

0 comments on commit 8fc192b

Please sign in to comment.