Floating point differences between platforms
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
People
(Reporter: philip, Assigned: me)
References
(Blocks 1 open bug, Regressed 1 open bug)
Details
(Whiteboard: [fingerprinting])
Attachments
(10 files, 3 obsolete files)
(deleted),
text/x-phabricator-request
|
RyanVM
:
approval-mozilla-esr91+
|
Details |
(deleted),
text/x-phabricator-request
|
RyanVM
:
approval-mozilla-esr91+
|
Details |
(deleted),
text/x-phabricator-request
|
RyanVM
:
approval-mozilla-esr91+
|
Details |
(deleted),
text/x-phabricator-request
|
RyanVM
:
approval-mozilla-esr91+
|
Details |
(deleted),
text/x-phabricator-request
|
RyanVM
:
approval-mozilla-esr91+
|
Details |
(deleted),
text/x-phabricator-request
|
RyanVM
:
approval-mozilla-esr91+
|
Details |
(deleted),
text/html
|
Details | |
(deleted),
text/html
|
Details | |
(deleted),
text/html
|
Details | |
(deleted),
text/html
|
Details |
Comment 1•15 years ago
|
||
Comment 2•15 years ago
|
||
Comment 3•15 years ago
|
||
Comment 4•15 years ago
|
||
Comment 5•15 years ago
|
||
Comment 6•15 years ago
|
||
Reporter | ||
Comment 7•15 years ago
|
||
Comment 8•15 years ago
|
||
Comment 9•15 years ago
|
||
Updated•10 years ago
|
Updated•6 years ago
|
Comment 10•4 years ago
|
||
:cpeterson fyi:
since FF68
- windows: four results (two more yet to be added). Note: Tor Browser has there own fingerprint of two results as they use mingw)
- android: at least seven results
- linux: two results so far (one more I know of yet to be added)
- mac: one result
chromium on the other hand is the same across all platforms AFAIK
Comment 11•4 years ago
|
||
Thanks for the links! Using your example code, I can reproduce the differences in 32-bit and 64-bit Firefox builds on Windows. I mistakenly thought these architecture differences were nullified when Firefox switched to fdlibm in bug 933257.
I was also just reading this related Tor bug: "Math routines are OS fingerprintable" https://gitlab.torproject.org/legacy/trac/-/issues/13018
Comment 12•4 years ago
|
||
swapping libm libraries should also nullifies entropy in audio fingerprinting - ask Paul Adenot: this has been discussed upstream as a standard
[1] https://gitlab.torproject.org/tpo/applications/tor-browser/-/issues/13017#note_2615311
Assignee | ||
Comment 13•3 years ago
|
||
Updated•3 years ago
|
Assignee | ||
Comment 14•3 years ago
|
||
Updated•3 years ago
|
Updated•3 years ago
|
Assignee | ||
Comment 15•3 years ago
|
||
Assignee | ||
Comment 16•3 years ago
|
||
Depends on D119420
Assignee | ||
Comment 17•3 years ago
|
||
Depends on D119422
Assignee | ||
Comment 18•3 years ago
|
||
Depends on D119423
Assignee | ||
Comment 19•3 years ago
|
||
Depends on D119424
Assignee | ||
Comment 20•3 years ago
|
||
Depends on D119425
Assignee | ||
Comment 21•3 years ago
|
||
Depends on D119426
Comment 22•3 years ago
|
||
Thank you for working on this!
Have you checked the performance impact by switching to fdlibm sin/cos/tan? (see bug 933257 comment #139 and bug 933257 comment #159 for the previous performance impact)
Assignee | ||
Comment 23•3 years ago
|
||
(In reply to Tooru Fujisawa [:arai] from comment #22)
Have you checked the performance impact by switching to fdlibm sin/cos/tan? (see bug 933257 comment #139 and bug 933257 comment #159 for the previous performance impact)
We did a few basic experiments early on, like we saw a 10% slowdown on the box2d benchmark in Jetstream. But, now that these patches are beginning to take shape, we are going to do more benchmarking.
Thanks for the references to the comments, I will keep the ni to redo those experiments and post the data here.
Comment 24•3 years ago
|
||
sin/cos/tan
changes alone won't solve all math entropy, but would seem to nail most of them. There are cbrt
, cosh
, expm1
and sinh
polyfills that have entropy, so assuming the patch works, we'd need a follow up bug
Updated•3 years ago
|
Updated•3 years ago
|
Updated•3 years ago
|
Updated•3 years ago
|
Updated•3 years ago
|
Comment 25•3 years ago
|
||
What is our actual fingerprinting breakdown here? Is it more than just Win/Mac/Lin/Android?
Comment 26•3 years ago
|
||
What is our actual fingerprinting breakdown here? Is it more than just Win/Mac/Lin/Android?
There are differences within each: such as linux distros can differ, android has at least seven results, windows at least four (not counting mingw vs winsdk which should only apply to Tor Browser)
Assignee | ||
Comment 27•3 years ago
|
||
(In reply to sanketh from comment #23)
(In reply to Tooru Fujisawa [:arai] from comment #22)
Have you checked the performance impact by switching to fdlibm sin/cos/tan? (see bug 933257 comment #139 and bug 933257 comment #159 for the previous performance impact)
We did a few basic experiments early on, like we saw a 10% slowdown on the box2d benchmark in Jetstream. But, now that these patches are beginning to take shape, we are going to do more benchmarking.
Thanks for the references to the comments, I will keep the ni to redo those experiments and post the data here.
We did more experiments and the data is included in the email to dev-platform. Following the discussion there and offline, we might do more experiments, and we'll post the details here when we have it.
Assignee | ||
Comment 28•3 years ago
|
||
(In reply to Simon Mainey from comment #24)
sin/cos/tan
changes alone won't solve all math entropy, but would seem to nail most of them. There arecbrt
,cosh
,expm1
andsinh
polyfills that have entropy, so assuming the patch works, we'd need a follow up bug
(Sorry for the late response.) I don't think I follow. Could you expand on how polyfills have entropy? Does the same polyfill on different platforms give different results (which might indicate that some underlying primitive, like say pow
, is not the same across machines) or something else?
Comment 29•3 years ago
|
||
(In reply to sanketh from comment #28)
Does the same polyfill on different platforms give different results
Different devices it seems, and limited to Android. Look at [1] https://arkenfox.github.io/TZP/tests/mathdata.html and scan the Firefox results F20 to F26 and spot all the blue p1
's. These are items that differed from the control test (which was a windows Firefox), not a direct comparison to each other. But you can see the results of each polyfill per Android result, they are clearly not all the same
At the top, see the 55 items that differ (so far) in Firefox tests, the polyfill ones are color coded to stand out with a p1
(ignore the number, that was in case multiple polyfills were used per function). The very first item listed is cbrt 1p1
- cbrt test array item 1 using polyfill. At [2] https://arkenfox.github.io/TZP/tests/math.html , scroll down to data, you can see that cbrt test 1 uses Math.PI
polyfill code at [2] https://github.com/arkenfox/TZP/blob/d7b77267890483c4e111500fc2c3b7c0a7258c6d/tests/math.html#L321
crbt
usespow
, and the testcbrt1
usesMath.PI
cosh
,expm1
,sinh
allexp
- and the tests in question all use the value1
So I guess that kind of simplifies that up a bit. Android only with Math.PI + pow
, and exp + 1
. Polyfill entropy between desktops vs Android (which we could live with), and the entropy within Android is a different issue (like how Chromium's audio hash can change with a kernel update). I would ignore this and follow up in a different issue once this one is solved
Assignee | ||
Comment 30•3 years ago
|
||
Simon, (In reply to Simon Mainey from comment #29)
[...]
Thank you for the detailed response. As suggested, I created a new bug Bug 1722181 and we can continue the discussion there once this is resolved.
Assignee | ||
Comment 31•3 years ago
|
||
Following the response to the email to dev-platform, we did further benchmarking using a shippable build (we were using a opt build for the original numbers) and the results show smaller slowdowns.
Method
We benchmarked the patch with the javascript.options.use_fdlibm_for_sin_cos_tan
set to true
("fdlibm on") and false
("fdlibm off") on three OSes (OS X, Linux, and Windows) and compared it to moz-central ("current"). We tested on JetStream's Box2d, Kraken's Audio DFT, and SunSpider's Math Partial Sums which aim to simulate real-world workloads and on arai’s microbenchmark of concerning values to infer a fine-grained performance impact.
The data was collected from the following try runs:
- "current" (moz-central)
- "fdlibm on"
- "fdlibm off"
Three Benchmarks
On OS X and Linux, we see a small speedup across the board with the average speedup being 2.2% and 3.7% respectively.
On Windows, the impact is less uniform, we see a 26% speedup on Kraken Audio DFT, 7.1% slowdown on SunSpider Math Partial Sums, and 0.8% slowdown on JetStream Box2D.
Arai's Microbenchmark
On OS X and Linux, we see speedups for some tasks and slowdowns for others, with an average speedup of 6.4% and 3.7% respectively.
On Windows, we see slowdowns across the board with an average slowdown of 18%.
I couldn't figure out how to attach images to a bugzilla comment 😬, so I put them on a webpage: https://snkth.com/browser-fingerprinting/fdlibm-vs-native/
Comment 32•3 years ago
|
||
Comment 33•3 years ago
|
||
Comment 34•3 years ago
|
||
Assignee | ||
Comment 35•3 years ago
|
||
Comment 36•3 years ago
|
||
Comment 37•3 years ago
|
||
Backed out for causing build bustages.
Failure log windows 2012 build bustage
Failure log linux spidermonkey build bustage
Failure log linux arm spidermonkey build bustage
Failure log linux pkg spidermonkey build bustage
Updated•3 years ago
|
Updated•3 years ago
|
Comment 39•3 years ago
|
||
Comment 40•3 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/a4aeb9fac1b3
https://hg.mozilla.org/mozilla-central/rev/12a65b83675a
https://hg.mozilla.org/mozilla-central/rev/18fbbce162fc
https://hg.mozilla.org/mozilla-central/rev/07b64b719699
https://hg.mozilla.org/mozilla-central/rev/effc44a3a9a1
https://hg.mozilla.org/mozilla-central/rev/a42624b244be
Comment 41•3 years ago
|
||
Comment on attachment 9230309 [details]
Bug 531915 - part 6 - optionally use fdlibm's sin, cos, and tan in jsmath r?tjr
ESR Uplift Approval Request
- If this is not a sec:{high,crit} bug, please state case for ESR consideration: These patches are (mostly) inert in normal browser behavior. (They do add a conditional to some math functions which technically hurts performance, but our tests show this is near-unnoticable.) However it will be used by Tor Browser who will switch to ESR 91 in the coming months.
- User impact if declined: Tor will have to carry this patchset and potentially rebase it for the lifetime of ESR 91.
- Fix Landed on Version: 93
- Risk to taking this patch: Low
- Why is the change risky/not risky? (and alternatives if risky): Does nto affect browser behavior unless you have Resist Fingerprinting enabled.
- String or UUID changes made by this patch:
Updated•3 years ago
|
Comment 42•3 years ago
|
||
Comment on attachment 9230303 [details]
Bug 531915 - part 1 - update fdlibm to import files needed for sin, cos, and tan r?tjr
Approved for 91.1esr, though it would be nice if we could standardize around this across the board for consistency's sake.
Updated•3 years ago
|
Updated•3 years ago
|
Updated•3 years ago
|
Updated•3 years ago
|
Updated•3 years ago
|
Comment 43•3 years ago
|
||
bugherder uplift |
https://hg.mozilla.org/releases/mozilla-esr91/rev/8ae275ca114a
https://hg.mozilla.org/releases/mozilla-esr91/rev/1fe916db8fcb
https://hg.mozilla.org/releases/mozilla-esr91/rev/4c5f83a45cb9
https://hg.mozilla.org/releases/mozilla-esr91/rev/96aa6da7b8c9
https://hg.mozilla.org/releases/mozilla-esr91/rev/c5a25957f5a7
https://hg.mozilla.org/releases/mozilla-esr91/rev/063632032a8b
Comment 44•3 years ago
|
||
On 32bit Linux builds I'm getting now:
[ 1841s] 28:33.05 /usr/bin/ccache /usr/bin/g++ -o IntermNodePatternMatcher.o -c -I/home/abuild/rpmbuild/BUILD/obj/dist/stl_wrappers -I/home/abuild/rpmbuild/BUILD/obj/dist/system_wrappers -include /home/abuild/rpmbuild/BUILD/firefox-91.1.0/config/gcc_hidden.h -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-strong -DNDEBUG=1 -DTRIMMED=1 -DANGLE_PLATFORM_EXPORT= -D__NDK_FPABI__= -DANGLE_SKIP_DXGI_1_2_CHECK -DANGLE_ENABLE_KEYEDMUTEX -DANGLE_TRANSLATOR_ESSL_ONLY -DANGLE_ENABLE_ESSL -DANGLE_ENABLE_GLSL -DANGLE_ENABLE_HLSL '-DCR_CLANG_REVISION="llvmorg-12-init-11060-g118c3f3c-1"' -DDYNAMIC_ANNOTATIONS_ENABLED=0 -DNOMINMAX -DUNICODE -DWINVER=0x0A00 -D_ATL_NO_OPENGL -D_CRT_RAND_S -D_CRT_SECURE_NO_DEPRECATE -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SECURE_ATL -D_UNICODE -I/home/abuild/rpmbuild/BUILD/firefox-91.1.0/gfx/angle/targets/translator -I/home/abuild/rpmbuild/BUILD/obj/gfx/angle/targets/translator -I/home/abuild/rpmbuild/BUILD/firefox-91.1.0/gfx/angle/checkout/include -I/home/abuild/rpmbuild/BUILD/firefox-91.1.0/gfx/angle/checkout/out/gen/angle -I/home/abuild/rpmbuild/BUILD/firefox-91.1.0/gfx/angle/checkout/src -I/home/abuild/rpmbuild/BUILD/firefox-91.1.0/gfx/angle/checkout/src/common/third_party/base -I/home/abuild/rpmbuild/BUILD/obj/dist/include -I/usr/include/nspr4 -I/usr/include/nss3 -I/usr/include/nspr4 -I/home/abuild/rpmbuild/BUILD/obj/dist/include/nss -DMOZILLA_CLIENT -include /home/abuild/rpmbuild/BUILD/obj/mozilla-config.h -Wall -Wempty-body -Wignored-qualifiers -Wpointer-arith -Wsign-compare -Wtype-limits -Wunreachable-code -Wno-invalid-offsetof -Wc++2a-compat -Wduplicated-cond -Wimplicit-fallthrough -Wno-error=maybe-uninitialized -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=coverage-mismatch -Wno-error=free-nonheap-object -Wno-multistatement-macros -Wno-error=class-memaccess -Wno-error=deprecated-copy -Wno-error=unused-but-set-variable -Wformat -Wformat-overflow=2 -Wno-psabi -fno-sized-deallocation -fno-aligned-new -fno-exceptions -fno-strict-aliasing -fPIC -fno-rtti -ffunction-sections -fdata-sections -fno-exceptions -fno-math-errno -pthread -pipe -freorder-blocks -O2 -fomit-frame-pointer -funwind-tables -msse2 -MD -MP -MF .deps/IntermNodePatternMatcher.o.pp /home/abuild/rpmbuild/BUILD/firefox-91.1.0/gfx/angle/checkout/src/compiler/translator/tree_util/IntermNodePatternMatcher.cpp
[ 1841s] 28:33.12 In file included from /home/abuild/rpmbuild/BUILD/firefox-91.1.0/modules/fdlibm/src/e_acos.cpp:44:
[ 1841s] 28:33.12 /home/abuild/rpmbuild/BUILD/firefox-91.1.0/modules/fdlibm/src/math_private.h:34:21: error: conflicting declaration ‘typedef __double_t double_t’
[ 1841s] 28:33.12 34 | typedef __double_t double_t;
[ 1841s] 28:33.12 | ^~~~~~~~
[ 1841s] 28:33.12 In file included from /usr/include/c++/11/cmath:45,
[ 1841s] 28:33.12 from /home/abuild/rpmbuild/BUILD/obj/dist/system_wrappers/cmath:3,
[ 1841s] 28:33.12 from /home/abuild/rpmbuild/BUILD/obj/dist/stl_wrappers/cmath:60,
[ 1841s] 28:33.12 from /home/abuild/rpmbuild/BUILD/firefox-91.1.0/modules/fdlibm/src/e_acos.cpp:41:
[ 1841s] 28:33.12 /usr/include/math.h:156:21: note: previous declaration as ‘typedef long double double_t’
[ 1841s] 28:33.12 156 | typedef long double double_t;
[ 1841s] 28:33.12 | ^~~~~~~~
[ 1841s] 28:33.12 gmake[4]: *** [/home/abuild/rpmbuild/BUILD/firefox-91.1.0/config/rules.mk:676: e_acos.o] Error 1
Assignee | ||
Comment 45•3 years ago
|
||
(In reply to Wolfgang Rosenauer [:wolfiR] from comment #44)
On 32bit Linux builds I'm getting now:
[...]
Thank you for reporting this, do you see this across distros or just on specific distros?
The fix would be to update these lines in math_private.h
to go from
typedef double __double_t;
typedef __double_t double_t;
to
#if [linux 32-bit & maybe specific distro]
typedef long double __double_t;
#else
typedef double __double_t;
#endif
typedef __double_t double_t;
Comment 46•3 years ago
|
||
I'm building only for openSUSE and there is only one official version left for i386 which is openSUSE Tumbleweed. I cannot tell if that is specific.
The system has glibc 2.33 and apparently it defines __GLIBC_FLT_EVAL_METHOD=2 resulting in typedef long double double_t; in math.h
Assignee | ||
Comment 47•3 years ago
|
||
(In reply to Wolfgang Rosenauer [:wolfiR] from comment #46)
I'm building only for openSUSE and there is only one official version left for i386 which is openSUSE Tumbleweed. I cannot tell if that is specific.
The system has glibc 2.33 and apparently it defines __GLIBC_FLT_EVAL_METHOD=2 resulting in typedef long double double_t; in math.h
Thank you for the information and for digging into glibc. I am going to tag @arai and @tjr and maybe together we can figure out how to proceed.
For starters, it looks like the autoland job for this patch didn't test Linux 32-bit (it tested Windows 32-bit and Android 32-bit) which is odd (since Firefox provides a Linux 32-bit installer). Earlier, I was worried that if we set double_t
to long double
it would break on other 32-bit linux distros but now I am not sure if that is true (it will break on 32-bit windows and 32-bit android but it might hold for all 32-bit linux.)
Comment 48•3 years ago
|
||
given that what we want to do there is just use double
, regardless of system's definition (double
or long double
),
I think we'd better workaround the conflict by not using the double_t
or __double_t
identifiers.
We can replace double_t
and __double_t
to some other names, or maybe just use double
itself.
Comment 49•3 years ago
|
||
anyway, let's do that in new bug, given this bug is already fixed, in previous cycle.
Updated•3 years ago
|
Description
•