[buildd-tools-devel] Bug#584831: Bug#584831: schroot: please add an option to avoid fork()

Roger Leigh rleigh at codelibre.net
Wed Jun 30 19:22:11 UTC 2010


On Mon, Jun 28, 2010 at 08:47:17AM +0300, Timo Lindfors wrote:
> Roger Leigh <rleigh at codelibre.net> writes:
> > Is this with or without your fork patch?
> 
> Without. With the patch it exec()s Xorg and of course does not execute
> any schroot code after that.
> 
> > Right.  From the console, I can start X with
> >   schroot -c sid -p -q -- X :1
> > or
> >   schroot -c sid -p -q -- xinit :1
> >
> > and then run X applications in both directly from the console without
> > any trouble, or from with the X session.
> 
> Yes that works fine. As I described also using xdm works. But gdm just
> somehow detects the extra fork.

I've attached a complete trace you can take a look at (strace -f).

> > Now, when you start X, it creates a socket in /tmp/.X11-unix/Xn, where
> > n is the display number.  Do you have the same /tmp inside and outside
> > the chroot (i.e. is it bind mounted)?  If not, you'll need to do that.
> 
> Yes sure that is bind mounted.

You also need /var/lib/gdm bind mounted as well.

> > you are running with type=plain and not type=directory which would
> > have done this setup for you.  Please see the "should I use the
> > plain or directory chroot type?" section in the attached FAQ.
> 
> I prefer not using setup or exec scripts since I don't fully understand
> how they work.

Just run with --verbose and they will all explain what they do.
It's the recommended way to use schroot.  It's all documented in
detail in schroot-setup(5) if you want to know more, and you can
of course just look at the scripts in /etc/schroot/setup.d to
look at what they do directly.  It's completely open to do whatever
you like with.


Now, I've replicated your problem, and it's not something that
schroot can fix.  i.e. it's a bug in gdm.  Taking the attached
chrootX script which runs X:

  /usr/bin/schroot -c sid -p -q -- /usr/bin/X "$@"

This fails.

  exec /usr/bin/schroot -c sid -p -q -- /usr/bin/X "$@"

This also fails.

  /usr/bin/X "$@"

This also fails.

  exec /usr/bin/X "$@"

This works.  The reason for this oddness is not clear.  Certainly
it's misbehaving if X isn't the direct child of gdm.  If you look
at the attached trace, you'll see this pattern

   23319     gdm
    |
   23320     gdm
,--'| 
|  23322     gdm
|    `----------23329     chrootX
|                 `----------23330     schroot
`--.                           `----------23438     /usr/bin/X
   23445     gdm
     `----------23448     chrootX
                  `----------23449     schroot
                               `----------23438     /usr/bin/X

gdm forks twice on startup to make itself a dæmon and then
starts X using our chrootX script (which invokes schroot which
invokes X).  So far, so good.  However, for reasons which aren't
entirely clear, the second gdm process then decides to start
a fourth gdm process, which then runs the process for a second
time.  This creates a /second/ instance of X, which is where the
errors about X already running are coming from.

So, for some reason, gdm thinks X didn't start up the first time,
even though it's running and ready for use.  It's not clear why
looking at the trace, though I may have missed something.

If something the X server creates something that's not visible on
the host system, then it's just a matter of making that available,
but only the lockfiles and sockets in /tmp are created, and those
/are/ definitely visible.


I've tested running X through schroot without gdm in the picture,
and it's entirely functional.  I'm afraid I can't do much more to
help here; I would suggest getting in touch with the gdm developers,
since it's clearly an issue with gdm since even the shell script
without schroot being in the picture is failing.


Regards,
Roger

-- 
  .''`.  Roger Leigh
 : :' :  Debian GNU/Linux             http://people.debian.org/~rleigh/
 `. `'   Printing on GNU/Linux?       http://gutenprint.sourceforge.net/
   `-    GPG Public Key: 0x25BFB848   Please GPG sign your mail.
-------------- next part --------------
#!/bin/sh

/usr/bin/schroot -c sid -p -q -- /usr/bin/X "$@"
#exec /usr/bin/schroot -c sid -p -q -- /usr/bin/X "$@"
#/usr/bin/X "$@"
#exec /usr/bin/X "$@"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gdm-trace.bz2
Type: application/octet-stream
Size: 323478 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/buildd-tools-devel/attachments/20100630/88bb2256/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.alioth.debian.org/pipermail/buildd-tools-devel/attachments/20100630/88bb2256/attachment-0001.pgp>


More information about the Buildd-tools-devel mailing list