[Bug 56372] New: musl based exp2() gives very inaccurate results on i686
https://bugs.winehq.org/show_bug.cgi?id=56372 Bug ID: 56372 Summary: musl based exp2() gives very inaccurate results on i686 Product: Wine Version: 8.6 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: msvcrt Assignee: wine-bugs(a)winehq.org Reporter: martin(a)martin.st CC: piotr(a)codeweavers.com Regression SHA1: ca0643875961ef62c76e0b9cbd0433002a948d9b Distribution: --- Since switching the msvcrt implementation of exp2() from internal to musl based, in ca0643875961ef62c76e0b9cbd0433002a948d9b, the accuracy on i686 has become quite bad, to the point of breaking a handful of tests in ffmpeg. The issue can be reproduced with the following test snippet: --- #include <stdio.h> #include <math.h> double input = 5.979471; int main(int argc, char* argv[]) { printf("exp2(%f) = %f\n", input, exp2(input)); return 0; } --- Prior to this commit, and with later versions on e.g. x86_64, the output is: exp2(5.979471) = 63.095753 However, on i686, the output now is: exp2(5.979471) = 62.968753 This is an error of around 0.2%, which is a couple orders of magnitudes larger than expected/tolerated. It's curious how this issue only appears on i686 though, i.e. it doesn't look like an issue with the musl exp2() implementation algorithm, but some component of it misbehaving on i686. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=56372 Martin Storsjö <martin(a)martin.st> changed: What |Removed |Added ---------------------------------------------------------------------------- Hardware|x86-64 |x86 -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=56372 --- Comment #1 from Martin Storsjö <martin(a)martin.st> --- For extra context; this reproduces with llvm-mingw https://github.com/mstorsjo/llvm-mingw/releases/tag/20231128. With older mingw-w64 releases, calls to exp2() go to mingw-w64-crt's internal implementation, but when targeting UCRT, with the latest few releases, the exp2() calls go to the UCRT exp2() function. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=56372 Martin Storsjö <martin(a)martin.st> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |julliard(a)winehq.org --- Comment #2 from Martin Storsjö <martin(a)martin.st> --- This is a bug with how Wine has integrated the musl sources. Musl removes excess precision from float values in a number of places, this seems to be critical to get the intended precision, see https://gitlab.winehq.org/wine/wine/-/blob/wine-9.3/libs/musl/src/internal/l.... However, in order for this to work as expected, musl also tries to add specific compiler flags, in order to get the right behaviour. See https://git.musl-libc.org/cgit/musl/tree/configure?h=v1.2.4&id=f5f55d6589940... - which does this: tryflag CFLAGS_C99FSE -fexcess-precision=standard \ || { test "$ARCH" = i386 && tryflag CFLAGS_C99FSE -ffloat-store ; } So wine would need to check for these flags somewhere, and enable them for the musl sources. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=56372 --- Comment #3 from Martin Storsjö <martin(a)martin.st> --- FWIW, the issue reproduces if Wine is built with GCC (either in old full ELF mode, or in PE mode), but if built with Clang (tested in PE mode with llvm-mingw), the issue doesn't seem to appear. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=56372 blubban(a)gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |blubban(a)gmail.com --- Comment #4 from blubban(a)gmail.com --- Easier solution: Simply add a volatile or two to those functions. https://godbolt.org/z/sWb58Pb4Y -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=56372 Alex Henrie <alexhenrie24(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |alexhenrie24(a)gmail.com --- Comment #5 from Alex Henrie <alexhenrie24(a)gmail.com> --- Created attachment 76313 --> https://bugs.winehq.org/attachment.cgi?id=76313 Test program I'm attaching a compiled copy of Martin's test program in case anyone is interested in the bug but doesn't want to download llvm-mingw in order to reproduce it. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=56372 Ken Sharp <imwellcushtymelike(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- URL| |https://bugs.winehq.org/att | |achment.cgi?id=76313 Keywords| |download, regression, | |testcase -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=56372 Piotr Caban <piotr.caban(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |FIXED Status|UNCONFIRMED |RESOLVED Fixed by SHA1| |3607eae620f12cf42a62c201b0c | |78e9d8bcfffc3 CC| |piotr.caban(a)gmail.com --- Comment #6 from Piotr Caban <piotr.caban(a)gmail.com> --- Marking as fixed by 3607eae620f12cf42a62c201b0c78e9d8bcfffc3. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=56372 Alexandre Julliard <julliard(a)winehq.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED --- Comment #7 from Alexandre Julliard <julliard(a)winehq.org> --- Closing bugs fixed in 9.20. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=56372 Michael Stefaniuc <mstefani(a)winehq.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mstefani(a)winehq.org Target Milestone|--- |9.0.x -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=56372 Michael Stefaniuc <mstefani(a)winehq.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|9.0.x |--- --- Comment #8 from Michael Stefaniuc <mstefani(a)winehq.org> --- Removing the 9.0.x milestone from bug fixes included in 9.0.1. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
participants (1)
-
WineHQ Bugzilla