-
Bug
-
Resolution: Fixed
-
P4
-
16
-
gcc 10
-
b06
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8293425 | 15.0.9 | Yuri Nesterenko | P4 | Resolved | Fixed | b04 |
JDK-8293586 | 13.0.13 | Yuri Nesterenko | P4 | Resolved | Fixed | b04 |
JDK-8325931 | 11.0.23 | Jonathan Dowland | P4 | Resolved | Fixed | b04 |
Hi all,
I tried to build OpenJDK fastdebug with GCC 10.1 on Ubuntu 18.04, but I saw some compiler warnings as follows:
In file included from
/home/jyukutyo/code/jdk/src/hotspot/share/classfile/systemDictionary.hpp:31,
from
/home/jyukutyo/code/jdk/src/hotspot/share/classfile/javaClasses.hpp:28,
from
/home/jyukutyo/code/jdk/src/hotspot/share/precompiled/precompiled.hpp:35:
In member function 'void Symbol::byte_at_put(int, u1)',
inlined from 'Symbol::Symbol(const u1*, int, int)' at
/home/jyukutyo/code/jdk/src/hotspot/share/oops/symbol.cpp:55:16:
/home/jyukutyo/code/jdk/src/hotspot/share/oops/symbol.hpp:130:18: error:
writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
130 | _body[index] = value;
| ~~~~~~~~~~~~~^~~~~~~
I can resolve them with the following patch. I believe it fixes those potential bugs, so I'd like to contribute it.
(Our company has signed OCA.)
Thanks,
Koichi
===== PATCH =====
diff -r 20d92fe3ac52 src/hotspot/share/oops/symbol.cpp
--- a/src/hotspot/share/oops/symbol.cpp Tue Jun 16 03:16:41 2020 +0000
+++ b/src/hotspot/share/oops/symbol.cpp Thu Jun 18 07:08:50 2020 +0900
@@ -50,9 +50,10 @@
Symbol::Symbol(const u1* name, int length, int refcount) {
_hash_and_refcount = pack_hash_and_refcount((short)os::random(), refcount);
_length = length;
- _body[0] = 0; // in case length == 0
- for (int i = 0; i < length; i++) {
- byte_at_put(i, name[i]);
+ if (length == 0) {
+ _body[0] = 0;
+ } else {
+ memcpy(_body, name, length);
}
}
diff -r 20d92fe3ac52 src/hotspot/share/oops/symbol.hpp
--- a/src/hotspot/share/oops/symbol.hpp Tue Jun 16 03:16:41 2020 +0000
+++ b/src/hotspot/share/oops/symbol.hpp Thu Jun 18 07:08:50 2020 +0900
@@ -125,11 +125,6 @@
return (int)heap_word_size(byte_size(length));
}
- void byte_at_put(int index, u1 value) {
- assert(index >=0 && index < length(), "symbol index overflow");
- _body[index] = value;
- }
-
Symbol(const u1* name, int length, int refcount);
void* operator new(size_t size, int len) throw();
void* operator new(size_t size, int len, Arena* arena) throw();
- backported by
-
JDK-8293425 GCC 10 warning stringop-overflow with symbol code
- Resolved
-
JDK-8293586 GCC 10 warning stringop-overflow with symbol code
- Resolved
-
JDK-8325931 GCC 10 warning stringop-overflow with symbol code
- Resolved
- relates to
-
JDK-8249087 Always initialize _body[0..1] in Symbol constructor
- Resolved
- links to
-
Commit openjdk/jdk11u-dev/621048ac
-
Commit openjdk/jdk13u-dev/f9c77a72
-
Commit openjdk/jdk15u-dev/bcc79e20
-
Review openjdk/jdk11u-dev/2451
-
Review openjdk/jdk13u-dev/401
-
Review openjdk/jdk15u-dev/271