Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:42307 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 34913 invoked from network); 17 Dec 2008 21:22:08 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Dec 2008 21:22:08 -0000 Authentication-Results: pb1.pair.com header.from=helly@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=helly@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 85.214.94.56 as permitted sender) X-PHP-List-Original-Sender: helly@php.net X-Host-Fingerprint: 85.214.94.56 aixcept.net Linux 2.6 Received: from [85.214.94.56] ([85.214.94.56:32809] helo=h1149922.serverkompetenz.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 59/69-19668-D7D69494 for ; Wed, 17 Dec 2008 16:22:06 -0500 Received: from MBOERGER-ZRH.corp.google.com (177-0.1-85.cust.bluewin.ch [85.1.0.177]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by h1149922.serverkompetenz.net (Postfix) with ESMTP id 71E6411F15F; Wed, 17 Dec 2008 22:22:02 +0100 (CET) Date: Wed, 17 Dec 2008 22:19:11 +0100 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <28434894.20081217221911@marcus-boerger.de> To: "Etienne Kneuss" CC: "Lars Strojny" , "Guilherme Blanco" , "internals Mailing List" In-Reply-To: References: <1229538590.4955.15.camel@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] New function proposal: spl_object_id From: helly@php.net (Marcus Boerger) Hello Etienne, Wednesday, December 17, 2008, 7:59:01 PM, you wrote: > Hello, > On Wed, Dec 17, 2008 at 7:29 PM, Lars Strojny wrote: >> Hi Guilherme, >> >> thanks for moving the discussion to the list. >> >> Am Mittwoch, den 17.12.2008, 15:31 -0200 schrieb Guilherme Blanco: >> [...] >>> It seems that Marcus controls the commit access to SPL. So I'm turning >>> the conversation async, since I cannot find him online at IRC. >>> So, can anyone review the patch, comment it and commit if approved? >> >> Just for clarification, it is not about access, but about maintenance. >> So if Marcus gives his go, we can happily apply the patch and add a few >> tests (something you could start preparing now). >> >> cu, Lars >> > Last time I checked with Marcus, there were concerns about disclosing > a valid pointer to the user. > I'd be happy to see a use-case where this information is really needed > heavily. The only real usecase of heavy usages seems to be to > implement sets of objects. but splObjectStorage is here for that > precise use-case... Correct in all Etienne. The patch might be a tiny bit faster but exposes valid pointers which is extremely bad and also allows other bad things. That was the only reason I used md5 hashin. What I needed was something that is really unique per object (object pointer or id plus pointer to handler table). Since spl_object_hash() does not say how it creates the hash it should be fine change the way it does it. Since in a new session the hashes are of no more use we can even do that in any new version. However I must still insist on not exposing any valid information. Last but not least. In your code you know the maximum length of the extression, so you can allocate the string and snprintf into it. Even faster is to do a hexdump into a preallocated string. For the size use: char* hash = (char*)safe_emalloc(sizeof(void*), 2, 1); Now the dump of the two pointers. This approach should make it a bit faster for you. Something that might work is to create a random 128 bit hash key that is xored onto the hash created from the two pointers. This hash key can be allocated for each session the first time the function will be used. If you do that I am more than happy to accept that as a replacement for current spl_object_hash(). marcus > Regards > -- > Etienne Kneuss > http://www.colder.ch > Men never do evil so completely and cheerfully as > when they do it from a religious conviction. > -- Pascal Best regards, Marcus