WINE vs. FreeBSD

Tijl Coosemans tijl at ulyssis.org
Tue Jul 25 01:58:36 UTC 2006


On Monday 24 July 2006 18:49, Daniel Eischen wrote:
> On Mon, 24 Jul 2006, Tijl Coosemans wrote:
> > On Monday 24 July 2006 17:39, Daniel Eischen wrote:
> >> On Mon, 24 Jul 2006, Tijl Coosemans wrote:
> >>> I've attached two patches that accomplish this, but this seems to
> >>> trigger other problems, so use at your own risk. If you want to
> >>> try them, place them in the port's files/ directory and add a
> >>> line containing "USE_AUTOTOOLS= autoconf:259" to the Makefile.
> >>> This seems to break wine+libpthread, so I've also changed the
> >>> port to use libthr instead.
> >>>
> >>> For the libpthread experts, I haven't investigated that much
> >>> further yet, but libpthread seems to fail in create_stack() from
> >>> _pthread_create() from _thr_start_sig_daemon().
> >>
> >> See my response to this in a previous reply to this thread. 
> >> libthr and libpthread use LDT's for TLS.  WINE is stomping on them
> >> because it doesn't properly create LDTs.  This is not a problem
> >> with either of the thread libraries and this issue has been known
> >> ever since we implemented TLS years ago.
> >
> > And as I stated later on in that thread, I don't see where
> > libpthread and libthr still use LDT entries. As far as I understand
> > the code, instead of using an LDT entry per thread (as it sure used
> > to be), only one single GDT entry is used whose base address is
> > updated during a context switch. Looking at the cvs history, it has
> > been working like this since a couple commits of Peter Wemm about a
> > year ago.
> >
> > And if nothing but Wine uses the LDT, Wine's static allocation of
> > LDT entries can't be the problem.
>
> Look, we use %gs for TLS, period.  Go see
> libpthread/arch/i386/i386/pthread_md.c for how libpthread does it. 
> TLS would not work without setting aside a register for the threads
> library (and rtld) to use.

Aaarrrrgghhh :)

What you say is true of course, but %gs points to a GDT entry, not LDT. 
libpthread and libthr no longer use LDT entries...

There would be a problem of course if Wine or Windows programs 
change %gs. Wine does seem to touch %gs but I've never actually seen it 
change. It's always 0x001B, which is the correct value (GUGS_SEL).

However, Wine/Windows uses %fs for TLS and it appears that the FreeBSD 
kernel doesn't preserve it. It always ends up pointing to GUDATA_SEL.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20060725/9eadceaf/attachment.pgp


More information about the freebsd-hackers mailing list