Closed Bug 1140806 Opened 10 years ago Closed 10 years ago

Fennec debug build crashes on startup with "Can't open /dev/urandom?!" in js/src/jsmath.cpp

Categories

(Core :: JavaScript Engine, defect)

ARM
Android
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla39
Tracking Status
firefox39 --- fixed

People

(Reporter: kats, Assigned: cpeterson)

References

Details

(Keywords: assertion, reproducible)

Attachments

(2 files)

I did a debug build of Fennec using latest m-c and tried to run it, and it crashes on startup. Logcat attached, it indicates a crash from the assertion at [1]. I'm running on a Nexus 4 with Android 4.2.2.

[1] http://mxr.mozilla.org/mozilla-central/source/js/src/jsmath.cpp?rev=7c9dfca903cc#748
cpeterson, looks like you added this assert not too long ago...
Flags: needinfo?(cpeterson)
Attached file Logcat (deleted) —
odd. Did you hit this assertion just once or every time? What's the value of errno? I'm not sure why Fennec wouldn't be able to open /dev/urandom. I suspect the "fix" will be to remove this assertion. :)
Flags: needinfo?(cpeterson) → needinfo?(bugmail.mozilla)
errno is 14, which is EFAULT. According to http://linux.die.net/man/2/open this happens when "pathname points outside your accessible address space."

FWIW I did this on my device and it worked fine:

$ su
# cd /data/local/tmp
# touch dummy
# chmod 777 dummy
# run-as org.mozilla.fennec_kats dd if=/dev/urandom of=/data/local/tmp/dummy bs=1 count=8

so I think org.mozilla.fennec_kats has permissions to read /dev/urandom.
Flags: needinfo?(bugmail.mozilla) → needinfo?(cpeterson)
And I hit this assertion every time.
Nick: in bug 1056373, you added a comment saying "/dev/urandom doesn't exist on Android." What was the problem you were seeing? Did this just affect your local builds? Is this an initialization race when Fennec is just launching?

> // XXX: Initialize the RNG state to 0 so that random_initSeed is lazily
> // called for us on the first call to random_next (via
> // random_nextDouble). We need to do this here because /dev/urandom
> // doesn't exist on Android, resulting in assertion failures.

https://hg.mozilla.org/mozilla-central/rev/0da1dc4f6c95#l10.39

I landed this assertion almost two months ago and no one has reported this failure before. We could just remove this assertion but if this function can't read /dev/urandom, then other calls to /dev/urandom might be quietly failing, leaving Fennec in a vulnerable state.
Blocks: 1119403
Flags: needinfo?(cpeterson) → needinfo?(nfitzgerald)
(In reply to Chris Peterson [:cpeterson] from comment #6)
> Nick: in bug 1056373, you added a comment saying "/dev/urandom doesn't exist
> on Android." What was the problem you were seeing?

I don't think I actually verified that it doesn't exist on android devices, just that /dev/urandom could never be opened. My new jit-test was permafailing on android because of this assertion, and after talking to some folks in #jsapi, and noting that some set of tests related to (or using?) Math.random were hidden on android because they always triggered this assertion, we came to the (false?) conclusion that it just didn't exist there. So I simply worked around it.

> Did this just affect your local builds?

Never made a local android build, just saw this on tbpl.

> Is this an initialization race when Fennec is just launching?

Not 100% sure, but I don't think so, as there were other tests (jit-tests?) that are hidden on android because of this assertion.
Flags: needinfo?(nfitzgerald)
A perhaps-interesting question is why android debug mochitests are green on tbpl. I was hitting this assertion during gecko startup and would expect all debug android tests to also. Can either of you try doing a fennec debug build to see if you can reproduce the crash?
My local Fennec builds do not hit this assert. I am testing a patch that would replace /dev/urandom with arc4random on Android and BSDs (including OS X). arc4random can never fail and it doesn't need to open new fds, which might be a problem on some systems.
Assignee: nobody → cpeterson
Status: NEW → ASSIGNED
Attached patch use-arc4random-seed.patch (deleted) — Splinter Review
Initialize JS random seed using arc4random on Android and BSDs. Linux/glibc does not have arc4random() but Android's bionic libc does. I have not actually tested this on BSDs other than OS X.
Attachment #8574744 - Flags: review?(nfitzgerald)
Comment on attachment 8574744 [details] [diff] [review]
use-arc4random-seed.patch

Review of attachment 8574744 [details] [diff] [review]:
-----------------------------------------------------------------

rs=me
Attachment #8574744 - Flags: review?(nfitzgerald) → review+
Nick or Kats, do you know which Android tests are hidden because of this assertion failure?
Flags: needinfo?(nfitzgerald)
No idea, sorry.
https://hg.mozilla.org/mozilla-central/rev/d81e8b99b284
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla39
(In reply to Chris Peterson [:cpeterson] from comment #12)
> Nick or Kats, do you know which Android tests are hidden because of this
> assertion failure?

Found it! https://bugzilla.mozilla.org/show_bug.cgi?id=1056373#c35
Flags: needinfo?(nfitzgerald)
Thanks. I'll look into unhiding those tests.
Blocks: 1056373
Unfortunately, the Android 4.0 jit-tests can't be unhidden because are still failing with bug 1098513:

TEST-UNEXPECTED-FAIL | tests/jit-test/jit-test/tests/debug/Memory-drainAllocationsLog-14.js | /data/local/tests/jit-tests/jit-tests/tests/debug/Memory-drainAllocationsLog-14.js:40:8 Error: Assertion failed: got false, expected true
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: