RFR: 8295159: DSO created with -ffast-math breaks Java floating-point arithmetic

Andrew Haley aph at openjdk.org
Wed Oct 12 14:00:31 UTC 2022


On Wed, 12 Oct 2022 00:38:39 GMT, David Holmes <dholmes at openjdk.org> wrote:

> This appears to be a 10 year old bug in gcc. Have we ever had any issues reported because of this?

That's what is so insidious about messing with the floating-point control word: all that happens is people get slightly inaccurate results, which they don't notice.

> Inserting a workaround now seems rather late. Any FP-using native code can potentially break Java's FP semantics if it messes with the FPU control word (ref the old Borland compilers).

Indeed, but there seem to be a number of libraries out there compiled with -ffast-math. This is the kind of thing people do with highly performance-critical stuff like ray tracing, etc. But we don't want it to break Java.

> Shouldn't any workaround only be needed for the internals of `System.loadLibrary` as other JDK usages of `dlopen` should know what they are opening and that they are libraries that don't have this problem?

Maybe, but sometimes we use system- or user-provided librries.

-------------

PR: https://git.openjdk.org/jdk/pull/10661



More information about the build-dev mailing list