Skip to contentSkip to conversation

ctx->pipe_child bug ?

DISCUSSION Sukadev Bhattiprolu 2 participants 2 messages Jan 21, 2011 – Jan 22, 2011 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

Oren,

In usercr commit 0dd3f9dacc0a08f5fb562e385a4e4244f453b41c we have the following diff:

@@ -1868,10 +1902,16 @@ static int ckpt_fork_feeder(struct ckpt_ctx *ctx)

        close(ctx->pipe_child[0]);
        ctx->pipe_out = ctx->pipe_child[1];
+       ctx->pipe_child[0] = -1;  /* mark unused */
+       ctx->pipe_child[1] = -1;  /* mark unused */

---

ckpt_fork_feeder() creates the ->pipe_child[] pipe and clones the fork_feeder. ckpt_do_feeder() does the following:

        /* children pipe */
        close(ctx->pipe_child[1]);
        ctx->pipe_in = ctx->pipe_child[0];

        /* feeder pipe */
        close(ctx->pipe_feed[0]);

But if the fork_feeder process runs after the parent marks the fds unused, the fork feeder would end up with a -1 in ctx->pipe_in right ?

The two threads don't share the fds but they do share the same VM and hence changes to 'ctx' in one process is visible in the other right ?

Sukadev

A message that is not in the archive (sent off-list or not yet received): 20110121073918.GA15385-r/[email protected]

#2 lore raw
Quoted 26 lines · Sukadev Bhattiprolu

Oren,

In usercr commit 0dd3f9dacc0a08f5fb562e385a4e4244f453b41c we have the following diff:

(quoted diff) +2 -1
@@ -1868,10 +1902,16 @@ static int ckpt_fork_feeder(struct ckpt_ctx *ctx)
        close(ctx->pipe_child[0]);
        ctx->pipe_out = ctx->pipe_child[1];
 
+       ctx->pipe_child[0] = -1;  /* mark unused */
+       ctx->pipe_child[1] = -1;  /* mark unused */
 
---
 

ckpt_fork_feeder() creates the ->pipe_child[] pipe and clones the fork_feeder. ckpt_do_feeder() does the following:

        /* children pipe */
        close(ctx->pipe_child[1]);
        ctx->pipe_in = ctx->pipe_child[0];

        /* feeder pipe */
        close(ctx->pipe_feed[0]);
Quoted 5 lines

But if the fork_feeder process runs after the parent marks the fds unused, the fork feeder would end up with a -1 in ctx->pipe_in right ?

The two threads don't share the fds but they do share the same VM and hence changes to 'ctx' in one process is visible in the other right ?

Good catch. I'll fix that, thanks.

Oren.