[PATCH][jdk8u] hotspot: Avoid calling vm_update with a NULL name
Andrew Hughes
gnu.andrew at redhat.com
Thu Jan 3 04:32:20 UTC 2019
On Thu, 20 Dec 2018 at 13:36, Siddhesh Poyarekar <siddhesh at gotplt.org> wrote:
>
> Hi,
>
> gcc 7.x gives the following warning when building jdk8u:
>
> /home/ubuntu/openjdk/jdk8u/hotspot/src/share/vm/runtime/fprofiler.cpp:
> In member function ‘void ThreadProfiler::vm_update(TickPosition)’:
> /home/ubuntu/openjdk/jdk8u/hotspot/src/share/vm/runtime/fprofiler.cpp:638:56:
> warning: argument 1 null where non-null expected [-Wnonnull]
> bool vm_match(const char* name) const { return strcmp(name, _name)
> == 0; }
> ~~~~~~^~~~~~~~~~~~~
> In file included from
> /home/ubuntu/openjdk/jdk8u/hotspot/src/share/vm/utilities/globalDefinitions_gcc.hpp:35:0,
> 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/string.h:136:12: note: in a call to function ‘int
> strcmp(const char*, const char*)’ declared here
> extern int strcmp (const char *__s1, const char *__s2)
> ^~~~~~
>
> This appears to be because vm_update with a single argument calls its
> sibling function with a NULL name, which is not safe. A safer and
> compatible alternative is to call vm_update with an empty string; it
> results in exactly the same hash as a NULL string, i.e. 0.
>
> Attached patch does that.
>
> Siddhesh
>
> PS: Is there interest in fixing such warnings and more in jdk8u? I
> found a few more warnings with gcc8 too that I could work on fixing.
I assume you mean gcc 8 in your opening sentence, as I don't see this
with 7.
Usually the route for OpenJDK fixes is to apply them to the current working
tree first (https://hg.openjdk.java.net/jdk) and then backport to
other supported
trees (currently 11, 8, 7 and 6).
However, this file seems to have been removed during the development of
OpenJDK 10 [0] so the change could straight into 8u.
Have you followed the process at [1] and signed the Oracle Contributor
Agreement?
[0] https://bugs.openjdk.java.net/browse/JDK-8173715
[1] https://openjdk.java.net/contribute/
--
Andrew :)
Senior Free Java Software Engineer
Red Hat, Inc. (http://www.redhat.com)
Web Site: http://fuseyism.com
Twitter: https://twitter.com/gnu_andrew_java
PGP Key: ed25519/0xCFDA0F9B35964222 (hkp://keys.gnupg.net)
Fingerprint = 5132 579D D154 0ED2 3E04 C5A0 CFDA 0F9B 3596 4222
More information about the jdk8u-dev
mailing list