bugThe GNU Hurd - Bugs: bug #17644, glibc: support for TLS


bug #17644: glibc: support for TLS

Submitted by:  Thomas Schwinge <tschwinge>
Submitted on:  Fri Sep 8 08:27:38 2006  
Category: glibcSeverity: 5 - Blocker
Priority: 7 - HighItem Group: Standard Compliance
Status: NonePrivacy: Public
Assigned to: NoneOriginator Name: 
Open/Closed: OpenReproducibility: Every Time
Size (loc): NonePlanned Release: None
Effort: 0.00
Wiki-like text discussion box: 

Add a New Comment (Rich MarkupRich Markup):

You are not logged in

Please log in, so followups can be emailed to you.


(Jump to the original submission Jump to the original submission)

Thu Jul 19 20:39:40 2007, comment #15:

Here are updated patches. I don't have any issue any more, other people don't seem to have either.

(file #13404, file #13405, file #13406)

Samuel Thibault <sthibaul>
Project Member
Tue Jul 17 22:24:22 2007, comment #14:

There's one thing I'm not sure how to tackle when fork()+exec()'ing: when fork()'ing, descriptors are correctly set, etc. but when exec()'ing a new program, the descriptors should probably be cleared, because else the new program will inherit them. This should probably be done in hurd/exec/exec.c:do_exec(), at the time when vm areas are cleared. However, while clearing LDT is easy (just set it all to 0), clearing GDT is not: userspace doesn't have access to the USER_GDT and USER_GDT_SLOTS macros. Making 8191 trap calls for clearing them one by one would be quite long. A heuristic would be to try clearing from 0 and then until it starts succeeding, and then continue until it fails again, at which point we can consider every user entries where cleared, but that's far from pretty.

Should we export these two macros, export a new trap call for clearing all at once, something else?

Samuel Thibault <sthibaul>
Project Member
Sun Jun 24 22:34:59 2007, comment #13:

Oops, symbol versioning wasn't working as I expected. Unfortunately, that means that linking a libpthread against a TLS-enabled glibc will produce a TLS-only libpthread.

That said, the -transitional patch will still be useful for Debian's transition.

(file #13156)

Samuel Thibault <sthibaul>
Project Member
Sun Jun 24 14:09:12 2007, comment #12:

Here are updated patches, ext2fs.static now works. mach-defpager doesn't, however.

(file #13147, file #13148, file #13149)

Samuel Thibault <sthibaul>
Project Member
Wed Jun 13 22:02:06 2007, comment #11:

After recompilation of the Hurd servers with the TLS glibc, static binaries don't work any more, that's because we need to call __libc_setup_tls when libc is statically linked, see glibc-2.5/nptl/init.c.

We also have to do exactly the same for libthread.so too, because any piece of code that use create_thread() for starting a thread that uses __thread-enabled glibc should allocate TLS for glibc to work.

Samuel Thibault <sthibaul>
Project Member
Wed Jun 13 05:59:35 2007, comment #10:

Mmm, actually, the unstability I'm getting might be related to my Xen environment. When running natively I don't have any problem and seem for instance to be able to recompile the hurd package without trouble.

Samuel Thibault <sthibaul>
Project Member
Wed Jun 13 05:50:56 2007, comment #9:

I had forgotten that it's up to the thread library to initialize the tcb field of the tcb head.

(file #13034, file #13035)

Samuel Thibault <sthibaul>
Project Member
Wed Jun 13 04:37:11 2007, comment #8:

Here is a different patch for making the transition: the problem is that non-TLS glibc doesn't have _dl_allocate_tls, and thus the TLS libpthread.so can't be used with the old glibc. And non-TLS libpthread.so can't work with a TLS glibc as soon as an application with TLS data starts a thread. Thus the weak symbols for letting TLS-enabled libpthread work with non-TLS glibc.

Debian packages are available on http://dept-info.labri.fr/~thibault/debian-hurd/tls/ : I could install them (hurd first, then libc) and work (apt-get update etc), but now my box is pretty much unstable, it usually doesn't make it through the boot process.

Samuel Thibault <sthibaul>
Project Member
Wed Jun 13 02:43:01 2007, comment #7:

I ran make check in glibc/elf/, only tst-tls9-static failed (it just dlopens() libraries with tls).

Here is the Hurd's libpthread part. A very simple example seems to work just fine.

(file #13032)

Samuel Thibault <sthibaul>
Project Member
Tue Jun 12 00:11:01 2007, comment #6:

Here is a probably better patch for the fork issue. Almost all place should actually save/restore registers, and only new contexts need to let gnumach set initial values of registers.

(file #13021)

Samuel Thibault <sthibaul>
Project Member
Mon Nov 6 15:39:26 2006, comment #5:

Note that since 2006-10-27 tls has been enabled on the glibc trunk unconditionally: <http://sourceware.org/ml/glibc-cvs/2006-q4/msg00177.html>.

Thomas Schwinge <tschwinge>
Project Administrator
Mon Nov 6 15:22:43 2006, comment #4:

Roland's plan was / is to first make `--without-__thread' builds work (i.e. both compile and runtime-wise) before attemping anything else.

Thomas Schwinge <tschwinge>
Project Administrator
Mon Nov 6 15:13:41 2006, comment #3:

The `i386_set_gdt' and `i386_get_gdt' functions (which are --- if available --- used by the glibc tls code instead of the ldt ones) have been back-ported from OSKit Mach to GNU Mach and have been installed on gnumach-1-branch on 2006-11-05: <http://lists.gnu.org/archive/html/commit-hurd/2006-11/msg00007.html>, also see the threads starting at <http://lists.gnu.org/archive/html/bug-hurd/2006-10/msg00095.html>, <http://lists.gnu.org/archive/html/bug-hurd/2006-11/msg00017.html> and <http://lists.gnu.org/archive/html/bug-hurd/2006-11/msg00033.html>.

Thomas Schwinge <tschwinge>
Project Administrator
Fri Sep 8 08:34:48 2006, comment #2:

Jeroen Dekkers has been working on this, but stopped his efforts.

| <Jeroen> http://www.dekkers.cx/hurd/glibc-tls.patch
| <Jeroen> the fork fix isn't the right one
| <Jeroen> because the define is i386-specific
| <Jeroen> we should probably define a MACHINE_THREAD_STATE_FLAVOR2 to
| i386_REGS_SEGS_STATE or something, roland will probably know the
| cleanest solution
| <Jeroen> with that patch you can run programs
| <Jeroen> but dlopen() doesn't work
| <Jeroen> maybe other things don't work either
| <Jeroen> but the basic TLS things work :)

Thomas Schwinge <tschwinge>
Project Administrator
Fri Sep 8 08:29:55 2006, comment #1:

Some links:


Thomas Schwinge <tschwinge>
Project Administrator
Fri Sep 8 08:27:38 2006, original submission:

We currently have to build glibc with ``--without-tls'' because there are bugs in the Hurd-specific parts of glibc that deal with support for TLS.

However, this doesn't work for glibc 2.4 anymore, as thread local storage is being used internally by glibc and thus building with ``--without-tls'' fails.

Thomas Schwinge <tschwinge>
Project Administrator


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):

Attached Files
file #13405:  patch-hurd-tls-transitional added by sthibaul (14kB - application/octet-stream)
file #13404:  patch-glibc-2.5-tls added by sthibaul (13kB - application/octet-stream)
file #13406:  patch-hurd-tls added by sthibaul (13kB - application/octet-stream)
file #10712:  glibc-tls.patch added by tschwinge (2kB - text/x-patch - Uncompleted patch for glibc.)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by sthibaul (Updated the item)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 22 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu Jul 19 20:39:40 2007sthibaulAttached File-=>Added patch-glibc-2.5-tls, #13404
      Attached File-=>Added patch-hurd-tls-transitional, #13405
      Attached File-=>Added patch-hurd-tls, #13406
    Thu Jul 19 20:38:04 2007sthibaulAttached File#13156=>Removed
    Thu Jul 19 20:37:59 2007sthibaulAttached File#13147=>Removed
    Thu Jul 19 20:37:55 2007sthibaulAttached File#13149=>Removed
    Sun Jun 24 22:34:59 2007sthibaulAttached File-=>Added patch-hurd-tls-transitional, #13156
    Sun Jun 24 22:32:48 2007sthibaulAttached File#13148=>Removed
    Sun Jun 24 14:09:12 2007sthibaulAttached File-=>Added patch-glibc-2.5-tls, #13147
      Attached File-=>Added patch-hurd-tls-transitional, #13148
      Attached File-=>Added patch-hurd-tls, #13149
    Sun Jun 24 14:07:33 2007sthibaulAttached File#13034=>Removed
    Sun Jun 24 14:07:29 2007sthibaulAttached File#13035=>Removed
    Sun Jun 24 14:07:24 2007sthibaulAttached File#13021=>Removed
    Wed Jun 13 05:50:56 2007sthibaulAttached File-=>Added patch-hurd-tls-transitional, #13034
      Attached File-=>Added patch-hurd, #13035
    Wed Jun 13 05:49:37 2007sthibaulAttached File#13033=>Removed
    Wed Jun 13 05:49:31 2007sthibaulAttached File#13032=>Removed
    Wed Jun 13 04:38:21 2007sthibaulAttached File-=>Added patch-hurd-tls-transitional, #13033
    Wed Jun 13 02:43:01 2007sthibaulAttached File-=>Added patch-hurd, #13032
    Tue Jun 12 00:11:01 2007sthibaulAttached File-=>Added patch-glibc, #13021
    Fri Sep 8 08:34:48 2006tschwingeAttached File-=>Added glibc-tls.patch, #10712

    Back to the top

    Powered by Savane 3.1-cleanup1