Skip to content

Commit 849655a

Browse files
author
Vladimir Kozlov
committed
8358632: [asan] reports heap-buffer-overflow in AOTCodeCache::copy_bytes
Reviewed-by: vlivanov, iveresov
1 parent 575806c commit 849655a

2 files changed

Lines changed: 4 additions & 13 deletions

File tree

src/hotspot/share/code/aotCodeCache.cpp

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -460,18 +460,9 @@ AOTCodeCache* AOTCodeCache::open_for_dump() {
460460
}
461461

462462
void copy_bytes(const char* from, address to, uint size) {
463-
assert(size > 0, "sanity");
464-
bool by_words = true;
465-
if ((size > 2 * HeapWordSize) && (((intptr_t)from | (intptr_t)to) & (HeapWordSize - 1)) == 0) {
466-
// Use wordwise copies if possible:
467-
Copy::disjoint_words((HeapWord*)from,
468-
(HeapWord*)to,
469-
((size_t)size + HeapWordSize-1) / HeapWordSize);
470-
} else {
471-
by_words = false;
472-
Copy::conjoint_jbytes(from, to, (size_t)size);
473-
}
474-
log_trace(aot, codecache)("Copied %d bytes as %s from " INTPTR_FORMAT " to " INTPTR_FORMAT, size, (by_words ? "HeapWord" : "bytes"), p2i(from), p2i(to));
463+
assert((int)size > 0, "sanity");
464+
memcpy(to, from, size);
465+
log_trace(aot, codecache)("Copied %d bytes from " INTPTR_FORMAT " to " INTPTR_FORMAT, size, p2i(from), p2i(to));
475466
}
476467

477468
AOTCodeReader::AOTCodeReader(AOTCodeCache* cache, AOTCodeEntry* entry) {

test/hotspot/jtreg/runtime/cds/appcds/aotCode/AOTCodeCompressedOopsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public void checkExecution(OutputAnalyzer out, RunMode runMode) throws Exception
173173
* [0.022s][info][cds] narrow_oop_mode = 3, narrow_oop_base = 0x0000000300000000, narrow_oop_shift = 3
174174
* [0.022s][info][cds] heap range = [0x0000000301000000 - 0x0000000ac1000000]
175175
*/
176-
Pattern p = Pattern.compile("narrow_oop_base = 0x(\\d+), narrow_oop_shift = (\\d)");
176+
Pattern p = Pattern.compile("narrow_oop_base = 0x([0-9a-fA-F]+), narrow_oop_shift = (\\d)");
177177
for (int i = 0; i < list.size(); i++) {
178178
String line = list.get(i);
179179
if (line.indexOf("CDS archive was created with max heap size") != -1) {

0 commit comments

Comments
 (0)