Summary: | Math.random() gives too low values on Win32 when _CRT_RAND_S is not defined | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Jonni Rainisto <jonni.rainisto> | ||||||
Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> | ||||||
Status: | RESOLVED FIXED | ||||||||
Severity: | Normal | CC: | commit-queue | ||||||
Priority: | P2 | ||||||||
Version: | 528+ (Nightly build) | ||||||||
Hardware: | PC | ||||||||
OS: | Windows 7 | ||||||||
Attachments: |
|
Description
Jonni Rainisto
2009-10-01 02:40:26 PDT
Created attachment 40430 [details]
Patch which fixes the bug.
Comment on attachment 40430 [details]
Patch which fixes the bug.
I think we need more bits of randomness. I'm not sure how many. It seems we are using 32 bits of randomness in the first two cases, and 53 bits in the next two. Having a Windows code path that uses only 30 bits seems wrong, but perhaps the 32-bit ones are also wrong.
review- for now based on that issue, but I could be convinced I am wrong.
Well in weakRandomNumber its using 15bit rand() 2 times, so imho normal case (when _CRT_RAND_S is defined) in MSVC randomless is even weaker (or same) than 30bits. Im a bit worried that calling rand() 4 times to get 53bit randomness could have some performance impacts. I can make the patch to use rand 4 times, or copypaste the weak random, if 30bit random is not enough? Created attachment 40473 [details]
Rand() patch which uses 53bits
Comment on attachment 40473 [details] Rand() patch which uses 53bits Clearing flags on attachment: 40473 Committed r49056: <http://trac.webkit.org/changeset/49056> All reviewed patches have been landed. Closing bug. |