Skip to content

Instantly share code, notes, and snippets.

@dogbert17
Created September 27, 2019 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dogbert17/4180fe5cfba5b863295094a73c091df0 to your computer and use it in GitHub Desktop.
Save dogbert17/4180fe5cfba5b863295094a73c091df0 to your computer and use it in GitHub Desktop.
Attempt to avoid SEGV
diff --git a/src/io/procops.c b/src/io/procops.c
index 9c23b5e..61e2f62 100644
--- a/src/io/procops.c
+++ b/src/io/procops.c
@@ -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. */
@@ -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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment