jsapi-tests.exe fails with Assertion failure: (uintptr_t(ptr) & 1) == 0
Categories
(Firefox Build System :: General: Unsupported Platforms, enhancement, P5)
Tracking
(firefox70 fixed)
Tracking | Status | |
---|---|---|
firefox70 | --- | fixed |
People
(Reporter: tjr, Assigned: iain)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
(deleted),
text/x-phabricator-request
|
Details |
Reporter | ||
Comment 1•6 years ago
|
||
Reporter | ||
Comment 2•6 years ago
|
||
Updated•6 years ago
|
Comment 3•6 years ago
|
||
Comment 4•6 years ago
|
||
Comment 5•6 years ago
|
||
Comment 6•6 years ago
|
||
Comment 7•6 years ago
|
||
Updated•6 years ago
|
Reporter | ||
Comment 8•5 years ago
|
||
Now that Bug 1401624 has landed; can I ask folks to look at this again and give some guidance on whether triggering this assertion is worrying and needs investigation?
Assignee | ||
Comment 9•5 years ago
|
||
Our previous representation of private values assumed that the private pointer was aligned, and did some bit twiddling to try to disguise it as a double. Since bug 1293313, it has been unnecessary to set the top bit for a double, so that bit twiddling is unnecessary. There are actual use cases where private values are unaligned, so we should fix this.
While cleaning this up, I also removed unboxPrivateValue, because its only use could be better written using loadPrivateValue directly.
Assignee | ||
Comment 10•5 years ago
|
||
Justification for the above patch: I've run myself around in circles a couple of times, but now I think I'm convinced that we were already implicitly relying on the top bit to be clear under the existing implementation, so it should not be a problem to make it explicit.
Specifically, because we set the sign bit in isDouble before doing the comparison, the value of the high bit is irrelevant when it comes to disguising a pointer as a double. All that matters is that the value of the pointer (after the high bit is set) must be less than JSVAL_SHIFTED_TAG_MAX_DOUBLE, which is 0xfff8_0000_ffff_ffff.
The bottom half of the standard actually-only-48-bits address space runs from 0x0 to 0x0000_7fff_ffff_ffff, which trivially satisfies the requirement. The top half of the address space (typically reserved for the kernel) runs from 0xffff_8000_0000_0000 to 0xffff_ffff_ffff_ffff. Shifting the low end of that range by 1 gives 0x7fff_c000_0000_0000, which (with the top bit set) is still greater than JSVAL_SHIFTED_TAG_MAX_DOUBLE.
So there's actually no need to do any shifting or bit-twiddling. Kernel pointers don't work either way. Any pointer that we could store under the old system can just be stored as a raw pointer, and everything will work out fine.
Comment 11•5 years ago
|
||
Comment 13•5 years ago
|
||
bugherder |
Comment 15•5 years ago
|
||
Is this backportable to ESR68 and ESR60 without also backporting the object-biased boxing patch? In bug 1566883 I described a use case which produces some fairly surprising behaviour for embedders due to this bug.
Updated•5 years ago
|
Assignee | ||
Comment 16•5 years ago
|
||
The patch would look different, because object-biased NaN-boxing did a lot of tidying, but this change can be made independently.
That said, I don't think uplifting the entire patch is realistic. The Value representation is a pretty fundamental part of the engine. What we might be able to do is uplift a minimal alternate API to ESR68: something along the lines of "getUnalignedPrivate/toUnalignedPrivate", using the new representation. There would be no in-tree uses of the API, but embedders could use it to store unaligned pointers.
The API would probably get deprecated in the next ESR release.
Would that be worthwhile for you?
Comment 17•5 years ago
|
||
To be worthwhile for my use case, I would need ArrayBuffer to use that unaligned private API: https://searchfox.org/mozilla-esr68/source/js/src/vm/ArrayBufferObject.cpp#983
Would that be a possibility?
Reporter | ||
Comment 18•5 years ago
|
||
I would like whatever is necessary to remove that assertion from esr68; for the MinGW build to work.
Comment 19•5 years ago
|
||
This assert should probably be a MOZ_RELEASE_ASSERT. The current 68 code has a hard requirement on the alignment (since it drops the low bit internally).
One option may be a compile-time #ifdef for 68 so that we can safely uplift and only things like mingw builds would opt in. Having release asserts in the key choke-points like NewArrayBuffer are probably worthwhile for all users and is a low risk change as well (since if the assert trips, the browser is about to experience far worse problems).
Assignee | ||
Comment 20•5 years ago
|
||
After talking it over with RyanVM, the plan is to uplift the core of the patch (minus some incidental cleanups) to ESR68, hidden behind an #ifdef. See bug 1568564.
Comment 21•5 years ago
|
||
Appreciated, thanks!
Description
•