[PATCH][jdk8u] hotspot: Fix build warning with gcc 7.x
Siddhesh Poyarekar
siddhesh at gotplt.org
Thu Dec 20 13:24:22 UTC 2018
Hi,
gcc 7 has improved diagnostics that warn on potential out of bounds
errors. This results in the following warning when building jdk8u with
gcc 7:
/home/ubuntu/openjdk/jdk8u/hotspot/src/share/vm/code/dependencies.cpp:
In function ‘static void Dependencies::write_dependency_to(xmlStream*,
Dependencies::DepType, GrowableArray<Dependencies::DepArgument>*, Klass*)’:
/home/ubuntu/openjdk/jdk8u/hotspot/src/share/vm/code/dependencies.cpp:498:6:
warning: ‘%d’ directive writing between 1 and 10 bytes into a region of
size 9 [-Wformat-overflow=]
void Dependencies::write_dependency_to(xmlStream* xtty,
^~~~~~~~~~~~
/home/ubuntu/openjdk/jdk8u/hotspot/src/share/vm/code/dependencies.cpp:498:6:
note: directive argument in the range [0, 2147483647]
In file included from /usr/include/stdio.h:862:0,
from
/home/ubuntu/openjdk/jdk8u/hotspot/src/share/vm/prims/jni.h:39,
from
/home/ubuntu/openjdk/jdk8u/hotspot/src/share/vm/utilities/globalDefinitions_gcc.hpp:28,
from
/home/ubuntu/openjdk/jdk8u/hotspot/src/share/vm/utilities/globalDefinitions.hpp:33,
from
/home/ubuntu/openjdk/jdk8u/hotspot/src/share/vm/utilities/debug.hpp:28,
from
/home/ubuntu/openjdk/jdk8u/hotspot/src/share/vm/runtime/globals.hpp:28,
from
/home/ubuntu/openjdk/jdk8u/hotspot/src/share/vm/memory/allocation.hpp:28,
from
/home/ubuntu/openjdk/jdk8u/hotspot/src/share/vm/memory/iterator.hpp:28,
from
/home/ubuntu/openjdk/jdk8u/hotspot/src/share/vm/memory/genOopClosures.hpp:28,
from
/home/ubuntu/openjdk/jdk8u/hotspot/src/share/vm/oops/klass.hpp:28,
from
/home/ubuntu/openjdk/jdk8u/hotspot/src/share/vm/runtime/handles.hpp:28,
from
/home/ubuntu/openjdk/jdk8u/hotspot/src/share/vm/memory/universe.hpp:28,
from
/home/ubuntu/openjdk/jdk8u/hotspot/src/share/vm/code/oopRecorder.hpp:28,
from
/home/ubuntu/openjdk/jdk8u/hotspot/src/share/vm/asm/codeBuffer.hpp:28,
from
/home/ubuntu/openjdk/jdk8u/hotspot/src/share/vm/asm/assembler.hpp:28,
from
/home/ubuntu/openjdk/jdk8u/hotspot/src/share/vm/precompiled/precompiled.hpp:29:
/usr/include/aarch64-linux-gnu/bits/stdio2.h:34:43: note:
‘__builtin___sprintf_chk’ output between 3 and 12 bytes into a
destination of size 10
__bos (__s), __fmt, __va_arg_pack ());
^
The bounds will likely never be crossed in practice but it might be safe
to trivially bump up th size of the array in question (xn) and thus
silence the warning. Attached patch does that.
I have build tested this on aarch64 and x86 to verify that the warning
is silenced. A hotspot test run aarch64 shows no new test failures from
this.
Siddhesh
-------------- next part --------------
diff -r c747935d0dc6 src/share/vm/code/dependencies.cpp
--- a/src/share/vm/code/dependencies.cpp Tue Nov 13 11:21:32 2018 -0500
+++ b/src/share/vm/code/dependencies.cpp Thu Dec 20 12:38:32 2018 +0000
@@ -525,7 +525,7 @@
xtty->object("x", arg.metadata_value());
}
} else {
- char xn[10]; sprintf(xn, "x%d", j);
+ char xn[12]; sprintf(xn, "x%d", j);
if (arg.is_oop()) {
xtty->object(xn, arg.oop_value());
} else {
More information about the jdk8u-dev
mailing list