mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Jens Gustedt <jens.gustedt@inria.fr>
To: musl@lists.openwall.com
Subject: Re: [PATCH v3] move the definition of __pthread_tsd_main to the only compilation unit that references it
Date: Mon, 11 Feb 2013 13:24:07 +0100	[thread overview]
Message-ID: <1360585447.9132.70.camel@eris.loria.fr> (raw)
In-Reply-To: <20130211111417.GA6181@port70.net>

[-- Attachment #1: Type: text/plain, Size: 1764 bytes --]

Am Montag, den 11.02.2013, 12:14 +0100 schrieb Szabolcs Nagy:
> * Jens Gustedt <Jens.Gustedt@inria.fr> [2013-02-11 11:44:21 +0100]:
> >  - Avoids a const cast that doesn't seem to be very useful.
> >  - Remove unused __pthread_tsd_size
> > 
> 
> sorry i was wrong, __pthread_tsd_size is used in pthread_create
> (i haven't read all the mails yet)

oops, somehow I must have got my grep for it wrong then, sorry for the
noise.


> the logic is that it is 0 when pthread_key_create is not
> linked to your code so you avoid all the tsd stack overhead
> (which is reasonable: in small tools where size and memory
> usage matters most you don't often use thread specific data..
> especially now that c11 has tls)
> 
> same for pthread_self: you only want non-dummy tsd if
> pthread_key_create is used
> 
> with your change you break pthread_create (now __pthread_tsd_size
> is always 0 there) and pthread_create always pulls in the tsd buf

Ok, now I see the idea.

In case of dynamic linking, this sounds a bit dangerous to me. Suppose
I have a program that runs fine, without linking to the key stuff. Say
it launches a new thread which then has the key table invalid.

Then I dynamically load a module that uses keys. The thread that has
an invalid table jumps into a function of that module that calles
pthread_key_get() ?

In such a scenario everything would simply crash, wouldn't it?

Jens

-- 
:: INRIA Nancy Grand Est :: http://www.loria.fr/~gustedt/   ::
:: AlGorille ::::::::::::::: office Nancy : +33 383593090   ::
:: ICube :::::::::::::: office Strasbourg : +33 368854536   ::
:: ::::::::::::::::::::::::::: gsm France : +33 651400183   ::
:: :::::::::::::::::::: gsm international : +49 15737185122 ::




[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

  reply	other threads:[~2013-02-11 12:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-11 10:44 Jens Gustedt
2013-02-11 11:14 ` Szabolcs Nagy
2013-02-11 12:24   ` Jens Gustedt [this message]
2013-02-11 12:51     ` Szabolcs Nagy

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=1360585447.9132.70.camel@eris.loria.fr \
    --to=jens.gustedt@inria.fr \
    --cc=musl@lists.openwall.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).