Skip to content

Commit

Permalink
Merge pull request #1183 from dogbert17/fix-segv-in-procops
Browse files Browse the repository at this point in the history
Fix possible SEGV in async_spawn_on_exit
  • Loading branch information
niner committed Sep 27, 2019
2 parents acb04a4 + 5dfed00 commit 1546c8c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/io/procops.c
Expand Up @@ -472,6 +472,7 @@ static void async_spawn_on_exit(uv_process_t *req, MVMint64 exit_status, int ter
MVMObject *done_cb = MVM_repr_at_key_o(tc, si->callbacks,
tc->instance->str_consts.done);
MVMOSHandle *os_handle;
uv_mutex_t *mutex;
if (!MVM_is_null(tc, done_cb)) {
MVMROOT(tc, done_cb, {
/* Get status. */
Expand All @@ -494,10 +495,11 @@ static void async_spawn_on_exit(uv_process_t *req, MVMint64 exit_status, int ter

/* when invoked via MVMIOOps, close_stdin is already wrapped in a mutex */
os_handle = (MVMOSHandle *) si->handle;
uv_mutex_lock(os_handle->body.mutex);
mutex = os_handle->body.mutex;
uv_mutex_lock(mutex);
si->state = STATE_DONE;
close_stdin(tc, os_handle);
uv_mutex_unlock(os_handle->body.mutex);
uv_mutex_unlock(mutex);

/* Close handle. */
uv_close((uv_handle_t *)req, spawn_async_close);
Expand Down

0 comments on commit 1546c8c

Please sign in to comment.