All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Seebach <peter.seebach@windriver.com>
To: Richard Purdie <richard.purdie@linuxfoundation.org>
Cc: Paul Eggleton <paul.eggleton@linux.intel.com>, yocto@yoctoproject.org
Subject: Re: pseudo interaction issue
Date: Mon, 26 Mar 2012 22:47:08 -0500	[thread overview]
Message-ID: <20120326224708.6371085c@wrlaptop> (raw)
In-Reply-To: <1332798316.28414.138.camel@ted>

On Mon, 26 Mar 2012 22:45:16 +0100
Richard Purdie <richard.purdie@linuxfoundation.org> wrote:

> I'm still a little surprised we don't make any system() calls though.
> I just tried putting a os.system("true") call into the "breakit"
> class and it doesn't trigger the warnings. Could that be down to the
> lack of a popen wrapper?

I think that part could be, but this doesn't explain why adding the
popen() wrapper doesn't fix it.  Oh, wait.  Yes, it does.  I think I am
now happy with this, although I have a loose end or two.

So, here's what I've figured out.

We start bitbake with PSEUDO_PREFIX set.  This then gets stored in the
internal stash.  Thus, on any call we catch, we should be restoring it.
We then unset it, because it's not part of the whitelisted environment.

Now, what this means is that when we spawn child processes, they should
be getting the environment, but the parent bitbake is running with
PSEUDO_DISABLED.  Which, in turn, sets antimagic.  So most calls run
through their non-wrapped form.

The problem:  I wrote my popen() wrapper wrong.  See, I carefully
removed the check for pseudo_disabled from the top of it.  But!  That
code path is not actually the only way in which pseudo_disabled affects
behavior.  That's just an *OPTIMIZATION*.  The pseudo_disabled flag
also means that antimagic is set, and I copied that part of the wrapper
in unmodified:

        if (antimagic > 0) {
                /* call the real syscall */
                rc = (*real_popen)(command, mode);
        } else {
                /* exec*() use this to restore the sig mask */
                pseudo_saved_sigmask = saved;
                rc = wrap_popen(command, mode);
        }

And antimagic is 1, so I call real popen.  Which forks.  And even
though pseudo isn't in the LD_PRELOAD environment variable, it's still
in the process's address space, but PSEUDO_PREFIX isn't set, and for
some reason, the stashed value is missing.  Not sure I can explain that
part yet; maybe we do have a path where we wipe the stashed value.

But the underlying problem is that my popen() wrapper was never
actually doing the setupenv/dropenv, or just a setupenv.

And the other underlying problem is that calling os.popen() directly is
probably something we should discourage, because we really do want to
know, for each subprocess we plan to spawn, whether it is running in
the pseudo environment or not.  So if you call os.popen(), you get
"whatever state bitbake is in", which may not be at all what you wanted
or intended.

If I fix the popen() patch, it may actually start working again,
although I'm still not totally sure why the prefix is getting wiped out.

So... I think...

1.  We should probably whitelist PSEUDO_PREFIX because life is a heck
of a lot easier if we aren't trying to set it and unset it all the time.
2.  I need to fix my popen patch.
3.  Once I've fixed that, I can probably do a much better job of
articulating what's happening to pseudo_prefix that's causing us to end
up with a child process where both the internal stash and the
environment variable are unset.

The big thing I was missing was that PSEUDO_DISABLED implies that
everything will always have antimagic >= 1.

-s
-- 
Listen, get this.  Nobody with a good compiler needs to be justified.


  reply	other threads:[~2012-03-27  3:47 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-17 17:35 pseudo interaction issue Paul Eggleton
2012-02-17 18:50 ` Mark Hatle
2012-03-14  9:02   ` Xu, Dongxiao
2012-03-22  1:49     ` Xu, Dongxiao
2012-03-22 16:18       ` Peter Seebach
2012-03-23  1:01         ` Xu, Dongxiao
2012-03-23  2:29           ` Peter Seebach
2012-03-23  3:21             ` Xu, Dongxiao
2012-03-23  7:16               ` Peter Seebach
2012-03-23 12:20                 ` Paul Eggleton
2012-03-23 20:06                   ` Peter Seebach
2012-03-23 22:45                   ` Peter Seebach
2012-03-24 17:15                     ` Richard Purdie
2012-03-24 17:41                       ` Richard Purdie
2012-03-26 16:44                         ` Peter Seebach
2012-03-26 16:47                           ` Richard Purdie
2012-03-26 17:18                             ` Peter Seebach
2012-03-26 21:45                               ` Richard Purdie
2012-03-27  3:47                                 ` Peter Seebach [this message]
2012-03-27 14:26                                 ` Peter Seebach
2012-03-26  7:43                       ` Peter Seebach
2012-03-26  9:23                         ` Richard Purdie
2012-03-26 20:36                       ` Peter Seebach
2012-03-26 20:41                       ` Peter Seebach

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120326224708.6371085c@wrlaptop \
    --to=peter.seebach@windriver.com \
    --cc=paul.eggleton@linux.intel.com \
    --cc=richard.purdie@linuxfoundation.org \
    --cc=yocto@yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.