From: Kalin KOZHUHAROV <kalin@ThinRope.net>
To: Linus Torvalds <torvalds@osdl.org>
Cc: Davide Libenzi <davidel@xmailserver.org>,
Robert Love <rml@ximian.com>, Chris Wedgwood <cw@f00f.org>,
Arjan van de Ven <arjanv@redhat.com>,
Russell Leighton <russ@elegant-software.com>,
Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: clone() <-> getpid() bug in 2.6?
Date: Sun, 06 Jun 2004 15:43:22 +0900 [thread overview]
Message-ID: <40C2BD0A.8000309@ThinRope.net> (raw)
In-Reply-To: <Pine.LNX.4.58.0406052244290.7010@ppc970.osdl.org>
Linus Torvalds wrote:
>
> On Sun, 6 Jun 2004, Kalin KOZHUHAROV wrote:
>
>>Well, not exactly sure about my reply, but let me try.
>>
>>The other day I was debugging some config problems with my qmail instalation and I ended up doing:
>># strace -p 4563 -f -F
>>...
>>[pid 13097] read(3, "\347\374\375TBH~\342\233\337\220\302l\220\317\237\37\25"..., 32) = 32
>>[pid 13097] close(3) = 0
>>[pid 13097] getpid() = 13097
>>[pid 13097] getpid() = 13097
>>[pid 13097] getuid32() = 89
>>[pid 13097] getpid() = 13097
>>[pid 13097] time(NULL) = 1086497450
>>[pid 13097] getpid() = 13097
>>[pid 13097] getpid() = 13097
>>[pid 13097] getpid() = 13097
>
>
> qmail is a piece of crap. The source code is completely unreadable, and it
> seems to think that "getpid()" is a good source of random data. Don't ask
> me why.
>
> It literally does things like
>
> random = now() + (getpid() << 16);
>
> and since there isn't a single comment in the whole source tree, it's
> pointless to wonder why. (In case you wonder, "now()" just does a
> "time(NULL)" call - whee.).
>
> I don't understand why people bother with it. It's not like Dan Bernstein
> is so charming that it makes up for the deficiencies of his programs.
Well, it just works once you set it up right. And many people use it and you can get community support to a certain extent.
> But no, even despite the strange usage, this isn't a performance issue.
> qmail will call "getpid()" a few tens of times per connection because of
> the wonderful quality of randomness it provides, or something.
>
> This is another gem you find when grepping for "getpid()" in qmail, and
> apparently the source of most of them:
>
> if (now() - when < ((60 + (getpid() & 31)) << 6))
>
> Don't you love it how timeouts etc seem to be based on random values that
> are calculated off the lower 5 bits of the process ID? And don't you find
> the above (totally uncommented) line just a thing of beauty and clarity?
:-) DJB is (in)famous for its "code clarity".
> Yeah.
>
> Anyway, you did find something that used more than a handful of getpid()
> calls, but no, it doesn't qualify as performance-critical, and even
> despite it's peyote-induced (or hey, some people are just crazy on their
> own) getpid() usage, it's not a reason to have a buggy glibc.
I definately agree that getpid() should not be cached as it gives inconsistent results.
That is why I just reported I case of "more than a handful of getpid() calls" that struck me recently.
Ok, I think I/we have no more to say about the above getpid() usage.
Is there anybody insisting on getpid() caching?
And can/will anydoby fix that in glibc?
Kalin.
--
||///_ o *****************************
||//'_/> WWW: http://ThinRope.net/
|||\/<"
|||\\ '
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
next prev parent reply other threads:[~2004-06-06 6:43 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-05 15:28 clone() <-> getpid() bug in 2.6? Russell Leighton
2004-06-05 20:45 ` Linus Torvalds
2004-06-05 20:55 ` Arjan van de Ven
2004-06-05 21:13 ` Linus Torvalds
2004-06-05 21:48 ` Robert Love
2004-06-05 22:44 ` Linus Torvalds
2004-06-05 21:53 ` Chris Wedgwood
2004-06-05 22:47 ` Robert Love
2004-06-05 22:57 ` David S. Miller
2004-06-05 23:01 ` Linus Torvalds
2004-06-05 23:07 ` Davide Libenzi
2004-06-05 23:18 ` Linus Torvalds
2004-06-05 23:26 ` Davide Libenzi
2004-06-06 5:08 ` Kalin KOZHUHAROV
2004-06-06 5:13 ` Chris Wedgwood
2004-06-06 5:34 ` Kalin KOZHUHAROV
2004-06-06 6:07 ` Linus Torvalds
2004-06-06 6:43 ` Kalin KOZHUHAROV [this message]
2004-06-06 7:57 ` Erik Andersen
2004-06-06 16:57 ` Linus Torvalds
2004-06-06 18:53 ` Simon Kirby
2004-06-06 19:00 ` Linus Torvalds
2004-06-06 9:52 ` Bernd Eckenfels
2004-06-06 13:07 ` Paul Rolland
2004-06-06 17:20 ` Patrick J. LoPresti
2004-06-06 17:31 ` Paul Rolland
2004-06-06 17:43 ` Davide Libenzi
2004-06-06 18:17 ` Rik van Riel
2004-06-06 18:37 ` Patrick J. LoPresti
2004-06-06 16:33 ` chris
[not found] ` <200406062022.54320.vda@port.imtp.ilyichevsk.odessa.ua>
2004-06-06 17:55 ` Linus Torvalds
2004-06-07 18:20 ` Bruce Guenter
2004-06-08 11:06 ` Kalin KOZHUHAROV
2004-06-05 23:19 ` Robert Love
2004-06-06 14:29 ` Russell Leighton
2004-06-06 15:38 ` Using getpid() often, another way? [was Re: clone() <-> getpid() bug in 2.6?] Russell Leighton
2004-06-06 15:44 ` Robert Love
2004-06-07 0:20 ` Russell Leighton
2004-06-06 15:58 ` Arjan van de Ven
2004-06-06 23:49 ` Russell Leighton
2004-06-07 12:13 ` Arjan van de Ven
2004-06-07 13:48 ` Sean Neakums
2004-06-07 14:00 ` Christoph Hellwig
2004-06-07 14:10 ` Sean Neakums
2004-06-07 18:42 ` David Mosberger
2004-06-07 23:02 ` Russell Leighton
2004-06-07 23:27 ` David Mosberger
2004-06-08 6:01 ` Arjan van de Ven
2004-06-08 9:48 ` Eric W. Biederman
2004-06-07 0:09 ` Russell Leighton
2004-06-07 12:20 ` Arjan van de Ven
2004-06-06 17:19 ` Linus Torvalds
2004-06-12 9:15 ` Dominik Straßer
2004-06-12 13:47 ` Linus Torvalds
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=40C2BD0A.8000309@ThinRope.net \
--to=kalin@thinrope.net \
--cc=arjanv@redhat.com \
--cc=cw@f00f.org \
--cc=davidel@xmailserver.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rml@ximian.com \
--cc=russ@elegant-software.com \
--cc=torvalds@osdl.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox