RFR: 8187578: BitMap::reallocate should check if old_map is NULL
Erik Helin
erik.helin at oracle.com
Fri Sep 15 13:04:49 UTC 2017
Hi all,
I'm still trying to compile with gcc 7.1.1 and run into another small
issue. BitMap::reallocate calls Copy::disjoint_words and there is a case
in Copy::disjoint_words that might result in call to memcpy. The problem
is that BitMap::reallocate does not check that the "from" argument to
Copy::disjoint_words differs from NULL, and a call to memcpy with a NULL
argument is undefined behavior.
Webrev:
http://cr.openjdk.java.net/~ehelin/8187578/00/
Patch:
--- old/src/hotspot/share/utilities/bitMap.cpp 2017-09-15
14:47:21.471113699 +0200
+++ new/src/hotspot/share/utilities/bitMap.cpp 2017-09-15
14:47:21.179112252 +0200
@@ -81,8 +81,10 @@
if (new_size_in_words > 0) {
map = allocator.allocate(new_size_in_words);
- Copy::disjoint_words((HeapWord*)old_map, (HeapWord*) map,
- MIN2(old_size_in_words, new_size_in_words));
+ if (old_map != NULL) {
+ Copy::disjoint_words((HeapWord*)old_map, (HeapWord*) map,
+ MIN2(old_size_in_words, new_size_in_words));
+ }
if (new_size_in_words > old_size_in_words) {
clear_range_of_words(map, old_size_in_words, new_size_in_words);
Thanks,
Erik
More information about the hotspot-dev
mailing list