Skip to content

Commit 9faead1

Browse files
committed
8319927: Log that IEEE rounding mode was corrupted by loading a library
Reviewed-by: goetz, lucy
1 parent f33c874 commit 9faead1

File tree

4 files changed

+37
-6
lines changed

4 files changed

+37
-6
lines changed

src/hotspot/os/bsd/os_bsd.cpp

+17-1
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,12 @@ bool os::dll_address_to_library_name(address addr, char* buf,
978978

979979
void *os::Bsd::dlopen_helper(const char *filename, int mode) {
980980
#ifndef IA32
981+
bool ieee_handling = IEEE_subnormal_handling_OK();
982+
if (!ieee_handling) {
983+
Events::log_dll_message(nullptr, "IEEE subnormal handling check failed before loading %s", filename);
984+
log_info(os)("IEEE subnormal handling check failed before loading %s", filename);
985+
}
986+
981987
// Save and restore the floating-point environment around dlopen().
982988
// There are known cases where global library initialization sets
983989
// FPU flags that affect computation accuracy, for example, enabling
@@ -1004,7 +1010,17 @@ void *os::Bsd::dlopen_helper(const char *filename, int mode) {
10041010
// flags. Silently fix things now.
10051011
int rtn = fesetenv(&default_fenv);
10061012
assert(rtn == 0, "fesetenv must succeed");
1007-
assert(IEEE_subnormal_handling_OK(), "fsetenv didn't work");
1013+
bool ieee_handling_after_issue = IEEE_subnormal_handling_OK();
1014+
1015+
if (ieee_handling_after_issue) {
1016+
Events::log_dll_message(nullptr, "IEEE subnormal handling had to be corrected after loading %s", filename);
1017+
log_info(os)("IEEE subnormal handling had to be corrected after loading %s", filename);
1018+
} else {
1019+
Events::log_dll_message(nullptr, "IEEE subnormal handling could not be corrected after loading %s", filename);
1020+
log_info(os)("IEEE subnormal handling could not be corrected after loading %s", filename);
1021+
}
1022+
1023+
assert(ieee_handling_after_issue, "fesetenv didn't work");
10081024
}
10091025
#endif // IA32
10101026

src/hotspot/os/linux/os_linux.cpp

+18-3
Original file line numberDiff line numberDiff line change
@@ -1804,6 +1804,12 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
18041804

18051805
void * os::Linux::dlopen_helper(const char *filename, char *ebuf, int ebuflen) {
18061806
#ifndef IA32
1807+
bool ieee_handling = IEEE_subnormal_handling_OK();
1808+
if (!ieee_handling) {
1809+
Events::log_dll_message(nullptr, "IEEE subnormal handling check failed before loading %s", filename);
1810+
log_info(os)("IEEE subnormal handling check failed before loading %s", filename);
1811+
}
1812+
18071813
// Save and restore the floating-point environment around dlopen().
18081814
// There are known cases where global library initialization sets
18091815
// FPU flags that affect computation accuracy, for example, enabling
@@ -1843,11 +1849,20 @@ void * os::Linux::dlopen_helper(const char *filename, char *ebuf, int ebuflen) {
18431849
#ifndef IA32
18441850
// Quickly test to make sure subnormals are correctly handled.
18451851
if (! IEEE_subnormal_handling_OK()) {
1846-
// We just dlopen()ed a library that mangled the floating-point
1847-
// flags. Silently fix things now.
1852+
// We just dlopen()ed a library that mangled the floating-point flags.
1853+
// Attempt to fix things now.
18481854
int rtn = fesetenv(&default_fenv);
18491855
assert(rtn == 0, "fesetenv must succeed");
1850-
assert(IEEE_subnormal_handling_OK(), "fsetenv didn't work");
1856+
bool ieee_handling_after_issue = IEEE_subnormal_handling_OK();
1857+
1858+
if (ieee_handling_after_issue) {
1859+
Events::log_dll_message(nullptr, "IEEE subnormal handling had to be corrected after loading %s", filename);
1860+
log_info(os)("IEEE subnormal handling had to be corrected after loading %s", filename);
1861+
} else {
1862+
Events::log_dll_message(nullptr, "IEEE subnormal handling could not be corrected after loading %s", filename);
1863+
log_info(os)("IEEE subnormal handling could not be corrected after loading %s", filename);
1864+
}
1865+
assert(ieee_handling_after_issue, "fesetenv didn't work");
18511866
}
18521867
#endif // IA32
18531868
}

test/hotspot/jtreg/compiler/floatingpoint/TestSubnormalDouble.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* @test
2626
* @bug 8295159
2727
* @summary DSO created with -ffast-math breaks Java floating-point arithmetic
28-
* @run main/othervm/native compiler.floatingpoint.TestSubnormalDouble
28+
* @run main/othervm/native -Xlog:os=info compiler.floatingpoint.TestSubnormalDouble
2929
*/
3030

3131
package compiler.floatingpoint;

test/hotspot/jtreg/compiler/floatingpoint/TestSubnormalFloat.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* @test
2626
* @bug 8295159
2727
* @summary DSO created with -ffast-math breaks Java floating-point arithmetic
28-
* @run main/othervm/native compiler.floatingpoint.TestSubnormalFloat
28+
* @run main/othervm/native -Xlog:os=info compiler.floatingpoint.TestSubnormalFloat
2929
*/
3030

3131
package compiler.floatingpoint;

0 commit comments

Comments
 (0)