Closed Bug 842265 Opened 12 years ago Closed 12 years ago

Intermittent test_getRandomValues.html | The array buffer has one random value

Categories

(Core :: DOM: Core & HTML, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla22

People

(Reporter: RyanVM, Assigned: keeler)

References

Details

(Keywords: intermittent-failure)

Attachments

(1 file, 2 obsolete files)

https://tbpl.mozilla.org/php/getParsedLog.php?id=19838478&tree=Mozilla-Inbound Rev3 Fedora 12 mozilla-inbound opt test mochitest-3 on 2013-02-18 02:39:14 PST for push 673dd484f5b5 slave: talos-r3-fed-071 6769 INFO TEST-START | /tests/dom/tests/mochitest/crypto/test_getRandomValues.html 6770 INFO TEST-PASS | /tests/dom/tests/mochitest/crypto/test_getRandomValues.html | ArrayBuffer result is argument buffer 6771 INFO TEST-PASS | /tests/dom/tests/mochitest/crypto/test_getRandomValues.html | Non-zero result: 0 found in the Int8: 32 ArrayBufferView 6772 INFO TEST-PASS | /tests/dom/tests/mochitest/crypto/test_getRandomValues.html | ArrayBuffer result is argument buffer 6773 INFO TEST-PASS | /tests/dom/tests/mochitest/crypto/test_getRandomValues.html | Non-zero result: 0 found in the Int16: 32 ArrayBufferView 6774 INFO TEST-PASS | /tests/dom/tests/mochitest/crypto/test_getRandomValues.html | ArrayBuffer result is argument buffer 6775 INFO TEST-PASS | /tests/dom/tests/mochitest/crypto/test_getRandomValues.html | Non-zero result: 0 found in the Int32: 32 ArrayBufferView 6776 INFO TEST-PASS | /tests/dom/tests/mochitest/crypto/test_getRandomValues.html | ArrayBuffer result is argument buffer 6777 INFO TEST-PASS | /tests/dom/tests/mochitest/crypto/test_getRandomValues.html | Non-zero result: 0 found in the Uint8: 32 ArrayBufferView 6778 INFO TEST-PASS | /tests/dom/tests/mochitest/crypto/test_getRandomValues.html | ArrayBuffer result is argument buffer 6779 INFO TEST-PASS | /tests/dom/tests/mochitest/crypto/test_getRandomValues.html | Non-zero result: 0 found in the Uint16: 32 ArrayBufferView 6780 INFO TEST-PASS | /tests/dom/tests/mochitest/crypto/test_getRandomValues.html | ArrayBuffer result is argument buffer 6781 INFO TEST-PASS | /tests/dom/tests/mochitest/crypto/test_getRandomValues.html | Non-zero result: 0 found in the Uint32: 32 ArrayBufferView 6782 INFO TEST-PASS | /tests/dom/tests/mochitest/crypto/test_getRandomValues.html | ArrayBuffer result is argument buffer 6783 INFO TEST-PASS | /tests/dom/tests/mochitest/crypto/test_getRandomValues.html | Non-zero result: 0 found in the Uint8: 65536 ArrayBufferView 6784 INFO TEST-PASS | /tests/dom/tests/mochitest/crypto/test_getRandomValues.html | ArrayBuffer result is argument buffer 6785 INFO TEST-PASS | /tests/dom/tests/mochitest/crypto/test_getRandomValues.html | Non-zero result: 0 found in the Uint8Clamped: 32 ArrayBufferView 6786 INFO TEST-KNOWN-FAIL | /tests/dom/tests/mochitest/crypto/test_getRandomValues.html | Exception was the correct type 6787 INFO TEST-PASS | /tests/dom/tests/mochitest/crypto/test_getRandomValues.html | Extended length array buffer fails, NS_ERROR_DOM_QUOTA_EXCEEDED_ERR thrown 6788 INFO TEST-PASS | /tests/dom/tests/mochitest/crypto/test_getRandomValues.html | Expected TYPE_MISMATCH_ERR: Float32Array is not valid, got [Exception... "The type of an object is incompatible with the expected type of the parameter associated to the object" code: "17" nsresult: "0x80530011 (TypeMismatchError)" location: "http://mochi.test:8888/tests/dom/tests/mochitest/crypto/test_getRandomValues.html Line: 47"]. 6789 INFO TEST-PASS | /tests/dom/tests/mochitest/crypto/test_getRandomValues.html | Expected TYPE_MISMATCH_ERR: Float64Array is not valid, got [Exception... "The type of an object is incompatible with the expected type of the parameter associated to the object" code: "17" nsresult: "0x80530011 (TypeMismatchError)" location: "http://mochi.test:8888/tests/dom/tests/mochitest/crypto/test_getRandomValues.html Line: 47"]. 6790 INFO TEST-PASS | /tests/dom/tests/mochitest/crypto/test_getRandomValues.html | 11 tests run via testData 6791 INFO TEST-PASS | /tests/dom/tests/mochitest/crypto/test_getRandomValues.html | Expected TYPE_ERR, got [Exception... "Parameter is not an object" code: "1003" nsresult: "0x805303eb (NS_ERROR_DOM_NOT_OBJECT_ERR)" location: "http://mochi.test:8888/tests/dom/tests/mochitest/crypto/test_getRandomValues.html Line: 125"]. 6792 INFO TEST-PASS | /tests/dom/tests/mochitest/crypto/test_getRandomValues.html | The array buffer is unchanged, still 0 length 6793 ERROR TEST-UNEXPECTED-FAIL | /tests/dom/tests/mochitest/crypto/test_getRandomValues.html | The array buffer has one random value
Interesting. So far this has only happened on Linux?
test_getRandomValues.html: 142 // Test a one-length buffer view 143 try { 144 var a = new Int8Array(1); 145 var b = window.crypto.getRandomValues(a); 146 ok(a[0] !== 0, "The array buffer has one random value"); 147 ok(a === b, "ArrayBuffer result is argument buffer"); 148 } 149 catch (ex) { 150 ok(false, "A one-length array buffer view should not fail"); 151 } Looks like this will fail about once every 256 runs (I'm assuming 0 can be returned as a random value?) Instead of just checking once, we should probably repeatedly call getRandomValues on a buffer of length 1 and check that the results are not all 0.
Attached patch patch (obsolete) — Splinter Review
Attachment #716297 - Flags: review?(bsmith)
Attachment #716297 - Flags: feedback?(ddahl)
Comment on attachment 716297 [details] [diff] [review] patch Review of attachment 716297 [details] [diff] [review]: ----------------------------------------------------------------- Nice! I think Camilo caught this before we landed it and I dropped the ball. thanks!
Attachment #716297 - Flags: feedback?(ddahl) → feedback+
Comment on attachment 716297 [details] [diff] [review] patch Review of attachment 716297 [details] [diff] [review]: ----------------------------------------------------------------- ::: dom/tests/mochitest/crypto/test_getRandomValues.html @@ +154,2 @@ > } > + ok(oneLengthBufferSum !== 0, "The values from the one-length array buffers were not all zero (and thus were probably random)"); Doesn't this just reduce the frequency to 1/16th of the current frequency? It so, it would still fail pretty regularly, right? I think it would make more sense to just loop forever until a non-zero value is generated. The test would time out if we failed to output anything repeatedly.
Attached patch patch v2 (obsolete) — Splinter Review
(In reply to Brian Smith (:bsmith) from comment #14) > Comment on attachment 716297 [details] [diff] [review] > patch > > Review of attachment 716297 [details] [diff] [review]: > ----------------------------------------------------------------- > > ::: dom/tests/mochitest/crypto/test_getRandomValues.html > @@ +154,2 @@ > > } > > + ok(oneLengthBufferSum !== 0, "The values from the one-length array buffers were not all zero (and thus were probably random)"); > > Doesn't this just reduce the frequency to 1/16th of the current frequency? > It so, it would still fail pretty regularly, right? > > I think it would make more sense to just loop forever until a non-zero value > is generated. The test would time out if we failed to output anything > repeatedly. The probability that oneLengthBufferSum is 0 is the probability that every randomly generated value is 0. If getRandomValues generates integers from 0 to 255 uniformly at random, this is (1/256)^16, or 2^-128. But yeah, your solution is better.
Assignee: nobody → dkeeler
Attachment #716297 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #716297 - Flags: review?(bsmith)
Attachment #716637 - Flags: review?(bsmith)
Comment on attachment 716637 [details] [diff] [review] patch v2 Review of attachment 716637 [details] [diff] [review]: ----------------------------------------------------------------- ::: dom/tests/mochitest/crypto/test_getRandomValues.html @@ +154,2 @@ > } > + while (randomVal == 0); Add a comment: // The probability of getRandomValues generating a zero value is 1/256 so we run this in a loop until it returns a non-zero value to guard against false failures.
Attachment #716637 - Flags: review?(bsmith) → review+
Thanks, Brian. Carrying over r+. Try: https://tbpl.mozilla.org/?tree=Try&rev=bbd459c9018e
Attachment #716637 - Attachment is obsolete: true
Attachment #716782 - Flags: review+
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla22
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: