Allocator mismatches

2009-03-29 Thread Neil
Firefox may want to switch to using the jemalloc allocator on the Mac. 
As I understand it, this is tricky because you can't globally replace 
malloc/free. While in theory it would be possible to replace NS_Free 
and/or PR_Free, this runs into problems when the code doesn't match its 
allocators. In particular, I am counting NS_Free, PR_Free, PL_strfree 
and free as separate deallocators, which might strike you as a bit 
harsh, as you probably only need to care about NS_Free. Note that 
nsXPIDLCString and .Adopt() counts as an NS_Free, while nsCRT::strdup 
counts as a PR_Malloc, and I'm currently lumping PR_smprintf_free in 
with free, and PORT_Free with whatever it calls.


I instrumented the code and I ran all the mochitests (which include some 
SSL) and I could only find a few (<20) allocator mismatches in 
Gecko/Toolkit. By comparison, there are a horrifying number of allocator 
mismatches in mailnews (nsDirPrefs.cpp on its own manages to use one 
deallocator for a variable allocated by one of three allocators) and 
several in libjar, narrowly relegating you to third in a hypothetical 
"hall of shame". (I haven't filed bugs on mailnews or libjar yet either.)


Using the above criteria, I found the following allocator mismatches 
under security/*


nsNSSCallbacks.cpp: HandshakeCallback calls Adopt(cipherName) instead of 
Assign and PORT_Free. In fact, it can leak cipherName.


nsNSSCertificate.cpp: several times it Adopt()s the result of 
CERT_Hexify, when it should use PORT_Free.


nsNSSIOLayer.cpp: both adopts the result of and allocates an outparam 
using nsCRT::strdup, when both times it should use NS_strdup, while 
SSL_RevealURL allocates with PL_strdup but charCleaner uses PR_FREEIF.


nsSSLStatus.cpp: allocates an outparam using PL_strdup, when it should 
use ToNewCString.


pk12util.c: uses PR_Free for a string allocated with malloc, and 
PORT_ZFree for a string allocated with PL_strdup.


Would you be interested in patches for some or all of these? Who would 
want to review them?


--
Warning: May contain traces of nuts.
--
dev-tech-crypto mailing list
dev-tech-crypto@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-tech-crypto


0.9770793 See The Pleasure Inside ... 0.4069237

2009-03-29 Thread iwantsex
0.3829699 See The Pleasure Inside ... 0.9236727

0.9770793 Now Visit http://www.clicklinknow.com/dating/ 0.4069237

-- 
dev-tech-crypto mailing list
dev-tech-crypto@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-tech-crypto