# HG changeset patch # User Andrew John Hughes # Date 1603304160 -3600 # Node ID 7e0780d57319c52ee1b28a6b91f4c2ea3cdde56d # Parent a218d3f3a16fde1d1bd3a9d63cce10bebbbe4628 Bump shenandoah to aarch64-shenandoah-jdk8u272-b04. 2020-10-20 Andrew John Hughes Bump shenandoah to aarch64-shenandoah-jdk8u272-b04. * NEWS: Updated. * hotspot.map.in: Bump shenandoah to aarch64-shenandoah-jdk8u272-b04. * patches/hotspot/aarch32/8076475-pr3696.patch: Take a copy of the Shenandoah patch, so it can be changed without breaking AArch32 builds. * patches/hotspot/shenandoah/8076475-pr3696.patch: Update to apply after the version of JDK-8076475 which was included upstream, but didn't include changes to the code introduced by JDK-8059847, which is not upstream, or the strdup_check_oom calls, as JDK-6424123 is not in 8u yet. diff -r a218d3f3a16f -r 7e0780d57319 ChangeLog --- a/ChangeLog Mon Oct 19 16:56:16 2020 +0100 +++ b/ChangeLog Wed Oct 21 19:16:00 2020 +0100 @@ -1,3 +1,19 @@ +2020-10-20 Andrew John Hughes + + Bump shenandoah to aarch64-shenandoah-jdk8u272-b04. + * NEWS: Updated. + * hotspot.map.in: Bump shenandoah to + aarch64-shenandoah-jdk8u272-b04. + * patches/hotspot/aarch32/8076475-pr3696.patch: + Take a copy of the Shenandoah patch, so it can + be changed without breaking AArch32 builds. + * patches/hotspot/shenandoah/8076475-pr3696.patch: + Update to apply after the version of JDK-8076475 + which was included upstream, but didn't include + changes to the code introduced by JDK-8059847, + which is not upstream, or the strdup_check_oom + calls, as JDK-6424123 is not in 8u yet. + 2020-10-19 Andrew John Hughes Add HotSpot backports for 3.17.0 to the alternate diff -r a218d3f3a16f -r 7e0780d57319 NEWS --- a/NEWS Mon Oct 19 16:56:16 2020 +0100 +++ b/NEWS Wed Oct 21 19:16:00 2020 +0100 @@ -122,7 +122,190 @@ - JDK-8238386, PR3798: (sctp) jdk.sctp/unix/native/libsctp/SctpNet.c "multiple definition" link errors with GCC10 - JDK-8238388, PR3798: libj2gss/NativeFunc.o "multiple definition" link errors with GCC10 * Shenandoah + - [backport] 8221435: Shenandoah should not mark through weak roots + - [backport] 8221629: Shenandoah: Cleanup class unloading logic + - [backport] 8222992: Shenandoah: Pre-evacuate all roots + - [backport] 8223215: Shenandoah: Support verifying subset of roots + - [backport] 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family + - [backport] 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots + - [backport] 8224508: Shenandoah: Need to update thread roots in final mark for piggyback ref update cycle + - [backport] 8224579: ResourceMark not declared in shenandoahRootProcessor.inline.hpp with --disable-precompiled-headers + - [backport] 8224679: Shenandoah: Make ShenandoahParallelCodeCacheIterator noncopyable + - [backport] 8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle + - [backport] 8225014: Separate ShenandoahRootScanner method for object_iterate + - [backport] 8225216: gc/logging/TestMetaSpaceLog.java doesn't work for Shenandoah + - [backport] 8225573: Shenandoah: Enhance ShenandoahVerifier to ensure roots to-space invariant + - [backport] 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API + - [backport] 8226413: Shenandoah: Separate root scanner for SH::object_iterate() + - [backport] 8230853: Shenandoah: replace leftover assert(is_in(...)) with rich asserts + - [backport] 8231198: Shenandoah: heap walking should visit all roots most of the time + - [backport] 8231244: Shenandoah: all-roots heap walking misses some weak roots + - [backport] 8237632: Shenandoah: accept NULL fwdptr to cooperate with JVMTI and JFR + - [backport] 8239786: Shenandoah: print per-cycle statistics + - [backport] 8239926: Shenandoah: Shenandoah needs to mark nmethod's metadata + - [backport] 8240671: Shenandoah: refactor ShenandoahPhaseTimings + - [backport] 8240749: Shenandoah: refactor ShenandoahUtils + - [backport] 8240750: Shenandoah: remove leftover files and mentions of ShenandoahAllocTracker + - [backport] 8240868: Shenandoah: remove CM-with-UR piggybacking cycles + - [backport] 8240872: Shenandoah: Avoid updating new regions from start of evacuation + - [backport] 8240873: Shenandoah: Short-cut arraycopy barriers + - [backport] 8240915: Shenandoah: Remove unused fields in init mark tasks + - [backport] 8240948: Shenandoah: cleanup not-forwarded-objects paths after JDK-8240868 + - [backport] 8241062: Shenandoah: rich asserts trigger "empty statement" inspection + - [backport] 8241081: Shenandoah: Do not modify update-watermark concurrently + - [backport] 8241093: Shenandoah: editorial changes in flag descriptions + - [backport] 8241139: Shenandoah: distribute mark-compact work exactly to minimize fragmentation + - [backport] 8241142: Shenandoah: should not use parallel reference processing with single GC thread + - [backport] 8241351: Shenandoah: fragmentation metrics overhaul + - [backport] 8241435: Shenandoah: avoid disabling pacing with "aggressive" + - [backport] 8241520: Shenandoah: simplify region sequence numbers handling + - [backport] 8241534: Shenandoah: region status should include update watermark + - [backport] 8241583: Shenandoah: turn heap lock asserts into macros + - [backport] 8241668: Shenandoah: make ShenandoahHeapRegion not derive from ContiguousSpace + - [backport] 8241673: Shenandoah: refactor anti-false-sharing padding + - [backport] 8241675: Shenandoah: assert(n->outcnt() > 0) at shenandoahSupport.cpp:2858 with java/util/Collections/FindSubList.java + - [backport] 8241692: Shenandoah: remove ShenandoahHeapRegion::_reserved + - [backport] 8241700: Shenandoah: Fold ShenandoahKeepAliveBarrier flag into ShenandoahSATBBarrier + - [backport] 8241740: Shenandoah: remove ShenandoahHeapRegion::_heap + - [backport] 8241743: Shenandoah: refactor and inline ShenandoahHeap::heap() + - [backport] 8241748: Shenandoah: inline MarkingContext TAMS methods + - [backport] 8241838: Shenandoah: no need to trash cset during final mark + - [backport] 8241841: Shenandoah: ditch one of allocation type counters in ShenandoahHeapRegion + - [backport] 8241842: Shenandoah: inline ShenandoahHeapRegion::region_number + - [backport] 8241844: Shenandoah: rename ShenandoahHeapRegion::region_number + - [backport] 8241845: Shenandoah: align ShenandoahHeapRegions to cache lines + - [backport] 8241926: Shenandoah: only print heap changes for operations that directly affect it + - [backport] 8241983: Shenandoah: simplify FreeSet logging + - [backport] 8241985: Shenandoah: simplify collectable garbage logging + - [backport] 8242040: Shenandoah: print allocation failure type + - [backport] 8242041: Shenandoah: adaptive heuristics should account evac reserve in free target + - [backport] 8242042: Shenandoah: tune down ShenandoahGarbageThreshold + - [backport] 8242054: Shenandoah: New incremental-update mode + - [backport] 8242075: Shenandoah: rename ShenandoahHeapRegionSize flag + - [backport] 8242082: Shenandoah: Purge Traversal mode + - [backport] 8242083: Shenandoah: split "Prepare Evacuation" tracking into cset/freeset counters + - [backport] 8242089: Shenandoah: per-worker stats should be summed up, not averaged + - [backport] 8242101: Shenandoah: coalesce and parallelise heap region walks during the pauses + - [backport] 8242114: Shenandoah: remove ShenandoahHeapRegion::reset_alloc_metadata_to_shared + - [backport] 8242130: Shenandoah: Simplify arraycopy-barrier dispatching + - [backport] 8242211: Shenandoah: remove ShenandoahHeuristics::RegionData::_seqnum_last_alloc + - [backport] 8242212: Shenandoah: initialize ShenandoahHeuristics::_region_data eagerly + - [backport] 8242213: Shenandoah: remove ShenandoahHeuristics::_bytes_in_cset + - [backport] 8242217: Shenandoah: Enable GC mode to be diagnostic/experimental and have a name + - [backport] 8242227: Shenandoah: transit regions to cset state when adding to collection set + - [backport] 8242228: Shenandoah: remove unused ShenandoahCollectionSet methods + - [backport] 8242229: Shenandoah: inline ShenandoahHeapRegion liveness-related methods + - [backport] 8242267: Shenandoah: regions space needs to be aligned by os::vm_allocation_granularity() + - [backport] 8242271: Shenandoah: add test to verify GC mode unlock + - [backport] 8242273: Shenandoah: accept either SATB or IU barriers, but not both + - [backport] 8242301: Shenandoah: Inline LRB runtime call + - [backport] 8242316: Shenandoah: Turn NULL-check into assert in SATB slow-path entry + - [backport] 8242353: Shenandoah: micro-optimize region liveness handling + - [backport] 8242365: Shenandoah: use uint16_t instead of jushort for liveness cache + - [backport] 8242641: Shenandoah: clear live data and update TAMS optimistically + - [backport] 8243238: Shenandoah: explicit GC request should wait for a complete GC cycle + - [backport] 8243301: Shenandoah: ditch ShenandoahAllowMixedAllocs + - [backport] 8243307: Shenandoah: remove ShCollectionSet::live_data + - [backport] 8243395: Shenandoah: demote guarantee in ShenandoahPhaseTimings::record_workers_end + - [backport] 8243463: Shenandoah: ditch total_pause counters + - [backport] 8243464: Shenandoah: print statistic counters in time order + - [backport] 8243465: Shenandoah: ditch unused pause_other, conc_other counters + - [backport] 8243487: Shenandoah: make _num_phases illegal phase type + - [backport] 8243494: Shenandoah: set counters once per cycle + - [backport] 8243573: Shenandoah: rename GCParPhases and related code + - [backport] 8243848: Shenandoah: Windows build fails after JDK-8239786 + - [backport] 8244180: Shenandoah: carry Phase to ShWorkerTimingsTracker explicitly + - [backport] 8244200: Shenandoah: build breakages after JDK-8241743 + - [backport] 8244226: Shenandoah: per-cycle statistics contain worker data from previous cycles + - [backport] 8244326: Shenandoah: global statistics should not accept bogus samples + - [backport] 8244551: Shenandoah: Fix racy update of update_watermark + - [backport] 8244730: Shenandoah: gc/shenandoah/options/TestHeuristicsUnlock.java should only verify the heuristics + - [backport] 8244732: Shenandoah: move heuristics code to gc/shenandoah/heuristics + - [backport] 8244737: Shenandoah: move mode code to gc/shenandoah/mode + - [backport] 8244739: Shenandoah: break superclass dependency on ShenandoahNormalMode + - [backport] 8244740: Shenandoah: rename ShenandoahNormalMode to ShenandoahSATBMode + - [backport] 8245461: Shenandoah: refine mode name()-s + - [backport] 8245463: Shenandoah: refine ShenandoahPhaseTimings constructor arguments + - [backport] 8245726: Shenandoah: lift/cleanup ShenandoahHeuristics names and properties + - [backport] 8245754: Shenandoah: ditch ShenandoahAlwaysPreTouch + - [backport] 8245757: Shenandoah: AlwaysPreTouch should not disable heap resizing or uncommits + - [backport] 8245812: Shenandoah: compute root phase parallelism + - [backport] 8245814: Shenandoah: reconsider format specifiers for stats + - [backport] 8245825: Shenandoah: Remove diagnostic flag ShenandoahConcurrentScanCodeRoots + - [backport] 8246162: Shenandoah: full GC does not mark code roots when class unloading is off + - [backport] 8247310: Shenandoah: pacer should not affect interrupt status + - [backport] 8247358: Shenandoah: reconsider free budget slice for marking + - [backport] 8247474: Shenandoah: Windows build warning after JDK-8247310 + - [backport] 8247560: Shenandoah: heap iteration holds root locks all the time + - Fix slowdebug build after JDK-8230853 backport + - JDK-8006205: [TESTBUG] NEED_TEST: please JTREGIFY test/compiler/7177917/Test7177917.java + - JDK-8023697: failed class resolution reports different class name in detail message for the first and subsequent times + - JDK-8035493: JVMTI PopFrame capability must instruct compilers not to prune locals + - JDK-8046274: Removing dependency on jakarta-regexp + - JDK-8048933: -XX:+TraceExceptions output should include the message + - JDK-8061616: HotspotDiagnosticMXBean.getVMOption() throws IllegalArgumentException for flags of type double + - JDK-8076475: Misuses of strncpy/strncat + - JDK-8146612: C2: Precedence edges specification violated + - JDK-8148754: C2 loop unrolling fails due to unexpected graph shape + - JDK-8148854: Class names "SomeClass" and "LSomeClass;" treated by JVM as an equivalent + - JDK-8150986: serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java failing because expects HPROF JAVA PROFILE 1.0.1 file format - JDK-8152358, PR3800: code and comment cleanups found during the hunt for 8077392 + - JDK-8153583: Make OutputAnalyzer.reportDiagnosticSummary public + - JDK-8161072: AArch64: jtreg compiler/uncommontrap/TestDeoptOOM failure + - JDK-8167300: Scheduling failures during gcm should be fatal + - JDK-8171537: aarch64: compiler/c1/Test6849574.java generates guarantee failure in C1 + - JDK-8173300: [TESTBUG]compiler/tiered/NonTieredLevelsTest.java fails with compiler.whitebox.SimpleTestCaseHelper(int) must be compiled + - JDK-8177334: Update xmldsig implementation to Apache Santuario 2.1.1 + - JDK-8196969: JTreg Failure: serviceability/sa/ClhsdbJstack.java causes NPE + - JDK-8203481: Incorrect constraint for unextended_sp in frame:safe_for_sender + - JDK-8203699: java/lang/invoke/SpecialInterfaceCall fails with SIGILL on aarch64 + - JDK-8209413: AArch64: NPE in clhsdb jstack command + - JDK-8211714: Need to update vm_version.cpp to recognise VS2017 minor versions + - JDK-8214862: assert(proj != __null) at compile.cpp:3251 + - JDK-8216283: Allow shorter method sampling interval than 10 ms + - JDK-8216989: CardTableBarrierSetAssembler::gen_write_ref_array_post_barrier() does not check for zero length on AARCH64 + - JDK-8217368: AArch64: C2 recursive stack locking optimisation not triggered + - JDK-8217647: JFR: recordings on 32-bit systems unreadable + - JDK-8219566: JFR did not collect call stacks when MaxJavaStackTraceDepth is set to zero + - JDK-8220293: Deadlock in JFR string pool + - JDK-8221658: aarch64: add necessary predicate for ubfx patterns + - JDK-8230303: JDB hangs when running monitor command + - JDK-8230597: Update GIFlib library to the 5.2.1 + - JDK-8230711: ConnectionGraph::unique_java_object(Node* N) return NULL if n is not in the CG + - JDK-8231779: crash HeapWord*ParallelScavengeHeap::failed_mem_allocate + - JDK-8233197: Invert JvmtiExport::post_vm_initialized() and Jfr:on_vm_start() start-up order for correct option parsing + - JDK-8234617: C1: Incorrect result of field load due to missing narrowing conversion + - JDK-8235243: handle VS2017 15.9 and VS2019 in abstract_vm_version + - JDK-8235325: build failure on Linux after 8235243 + - JDK-8237512: AArch64: aarch64TestHook leaks a BufferBlob + - JDK-8237951: CTW: C2 compilation fails with "malformed control flow" + - JDK-8239852: java/util/concurrent tests fail with -XX:+VerifyGraphEdges: assert(!VerifyGraphEdges) failed: verification should have failed + - JDK-8240295: hs_err elapsed time in seconds is not accurate enough + - JDK-8240576: JVM crashes after transformation in C2 IdealLoopTree::merge_many_backedges + - JDK-8243489: Thread CPU Load event may contain wrong data for CPU time under certain conditions + - JDK-8244407: JVM crashes after transformation in C2 IdealLoopTree::split_fall_in + - JDK-8244548: JDK 8u: sun.misc.Version.jdkUpdateVersion() returns wrong result + - JDK-8244777: ClassLoaderStats VM Op uses constant hash value + - JDK-8245167: Top package in method profiling shows null in JMC + - JDK-8246310: Clean commented-out code about ModuleEntry andPackageEntry in JFR + - JDK-8246482: Build failures with +JFR -PCH + - JDK-8246703: [TESTBUG] Add test for JDK-8233197 + - JDK-8248219: aarch64: missing memory barrier in fast_storefield and fast_accessfield + - JDK-8248643: Remove extra leading space in JDK-8240295 8u backport + - JDK-8248851: CMS: Missing memory fences between free chunk check and klass read + - JDK-8250875: Incorrect parameter type for update_number in JDK_Version::jdk_update + - Shenandoah: add JFR roots to root processor after JFR integration + - Shenandoah: add root statistics for string dedup table/queues + - Shenandoah: fix build failures after JDK-8244737 backport + - Shenandoah: Fix build failure with +JFR -PCH + - Shenandoah: fix formats in ShenandoahStringSymbolTableUnlinkTask + - Shenandoah: fix runtime linking failure due to non-compiled shenandoahBarrierSetC1 + - Shenandoah: JNI weak roots are always cleared before Full GC mark + - Shenandoah: missing SystemDictionary roots in ShenandoahHeapIterationRootScanner + - Shenandoah: move barrier sets to their proper locations + - Shenandoah: move parallelCleaning.* to shenandoah/ + - Shenandoah: properly deallocates class loader metadata + - Shenandoah: specialize String Table scans for better pause performance - PR3798: Fix format-overflow error on GCC 10, caused by passing NULL to a '%s' directive * AArch64 port - JDK-8183925, PR3797: [AArch64] Decouple crash protection from watcher thread diff -r a218d3f3a16f -r 7e0780d57319 hotspot.map.in --- a/hotspot.map.in Mon Oct 19 16:56:16 2020 +0100 +++ b/hotspot.map.in Wed Oct 21 19:16:00 2020 +0100 @@ -1,4 +1,4 @@ # version type(drop/hg) url changeset sha256sum default drop https://icedtea.classpath.org/download/drops/icedtea8/@ICEDTEA_RELEASE@ 88961de57e43 5aa5045f0489e67e525b0ea88debee9e2a7db89291c2dfb0a52b7d23492b1b99 -shenandoah drop https://icedtea.classpath.org/download/drops/icedtea8/@ICEDTEA_RELEASE@ 7d23269db69a ca473d1f3bc0ac5ca6713a4df31d42d911c50f9789f0dce5b1726bd5a13536b1 +shenandoah drop https://icedtea.classpath.org/download/drops/icedtea8/@ICEDTEA_RELEASE@ f9a4ff26a4bd 12a4c7c306d6ba24cc9a197b3625b25661214d5ac167ec0dba972823d5035fd2 aarch32 drop https://icedtea.classpath.org/download/drops/icedtea8/@ICEDTEA_RELEASE@ 104a5c7f735e 642ece375346300cf11dce79dfb9ac3d5ac470bc68246ccf6fdcde7a495dc73b diff -r a218d3f3a16f -r 7e0780d57319 patches/hotspot/aarch32/8076475-pr3696.patch --- a/patches/hotspot/aarch32/8076475-pr3696.patch Mon Oct 19 16:56:16 2020 +0100 +++ b/patches/hotspot/aarch32/8076475-pr3696.patch Wed Oct 21 19:16:00 2020 +0100 @@ -1,1 +1,261 @@ -../shenandoah/8076475-pr3696.patch \ No newline at end of file +# HG changeset patch +# User stuefe +# Date 1549941248 0 +# Tue Feb 12 03:14:08 2019 +0000 +# Node ID 9bbf02572dc114e85829673a7cdaffa482115f42 +# Parent cfb34db6589e222d34e5b736b99ed4f69c261c4f +8076475, PR3696: Misuses of strncpy/strncat +Summary: Various small fixes around strncpy and strncat +Reviewed-by: dsamersoff, coleenp + +diff -Nru openjdk.orig/hotspot/agent/src/os/bsd/libproc_impl.c openjdk/hotspot/agent/src/os/bsd/libproc_impl.c +--- openjdk.orig/hotspot/agent/src/os/bsd/libproc_impl.c 2019-04-05 19:21:24.000000000 +0100 ++++ openjdk/hotspot/agent/src/os/bsd/libproc_impl.c 2019-04-16 16:05:31.441511929 +0100 +@@ -215,7 +215,12 @@ + return NULL; + } + +- strncpy(newlib->name, libname, sizeof(newlib->name)); ++ if (strlen(libname) >= sizeof(newlib->name)) { ++ print_debug("libname %s too long\n", libname); ++ return NULL; ++ } ++ strcpy(newlib->name, libname); ++ + newlib->base = base; + + if (fd == -1) { +diff -Nru openjdk.orig/hotspot/agent/src/os/linux/libproc_impl.c openjdk/hotspot/agent/src/os/linux/libproc_impl.c +--- openjdk.orig/hotspot/agent/src/os/linux/libproc_impl.c 2019-04-05 19:21:24.000000000 +0100 ++++ openjdk/hotspot/agent/src/os/linux/libproc_impl.c 2019-04-16 16:05:31.441511929 +0100 +@@ -162,7 +162,12 @@ + return NULL; + } + +- strncpy(newlib->name, libname, sizeof(newlib->name)); ++ if (strlen(libname) >= sizeof(newlib->name)) { ++ print_debug("libname %s too long\n", libname); ++ return NULL; ++ } ++ strcpy(newlib->name, libname); ++ + newlib->base = base; + + if (fd == -1) { +diff -Nru openjdk.orig/hotspot/src/os/bsd/dtrace/libjvm_db.c openjdk/hotspot/src/os/bsd/dtrace/libjvm_db.c +--- openjdk.orig/hotspot/src/os/bsd/dtrace/libjvm_db.c 2019-04-05 19:21:24.000000000 +0100 ++++ openjdk/hotspot/src/os/bsd/dtrace/libjvm_db.c 2019-04-16 16:05:31.441511929 +0100 +@@ -543,13 +543,14 @@ + CHECK_FAIL(err); + + result[0] = '\0'; +- strncat(result, klassString, size); +- size -= strlen(klassString); +- strncat(result, ".", size); +- size -= 1; +- strncat(result, nameString, size); +- size -= strlen(nameString); +- strncat(result, signatureString, size); ++ if (snprintf(result, size, ++ "%s.%s%s", ++ klassString, ++ nameString, ++ signatureString) >= size) { ++ // truncation ++ goto fail; ++ } + + if (nameString != NULL) free(nameString); + if (klassString != NULL) free(klassString); +@@ -1056,9 +1057,9 @@ + CHECK_FAIL(err); + } + if (deoptimized) { +- strncat(result + 1, " [deoptimized frame]; ", size-1); ++ strncat(result, " [deoptimized frame]; ", size - strlen(result) - 1); + } else { +- strncat(result + 1, " [compiled] ", size-1); ++ strncat(result, " [compiled] ", size - strlen(result) - 1); + } + if (debug) + fprintf(stderr, "name_for_nmethod: END: method name: %s, vf_cnt: %d\n\n", +diff -Nru openjdk.orig/hotspot/src/os/bsd/vm/decoder_machO.cpp openjdk/hotspot/src/os/bsd/vm/decoder_machO.cpp +--- openjdk.orig/hotspot/src/os/bsd/vm/decoder_machO.cpp 2019-04-05 19:21:24.000000000 +0100 ++++ openjdk/hotspot/src/os/bsd/vm/decoder_machO.cpp 2019-04-16 16:05:31.441511929 +0100 +@@ -97,6 +97,7 @@ + char * symname = mach_find_in_stringtable((char*) ((uintptr_t)mach_base + stroff), strsize, found_strx); + if (symname) { + strncpy(buf, symname, buflen); ++ buf[buflen - 1] = '\0'; + return true; + } + DEBUG_ONLY(tty->print_cr("no string or null string found.")); +diff -Nru openjdk.orig/hotspot/src/os/solaris/dtrace/libjvm_db.c openjdk/hotspot/src/os/solaris/dtrace/libjvm_db.c +--- openjdk.orig/hotspot/src/os/solaris/dtrace/libjvm_db.c 2019-04-05 19:21:24.000000000 +0100 ++++ openjdk/hotspot/src/os/solaris/dtrace/libjvm_db.c 2019-04-16 16:05:31.441511929 +0100 +@@ -543,13 +543,14 @@ + CHECK_FAIL(err); + + result[0] = '\0'; +- strncat(result, klassString, size); +- size -= strlen(klassString); +- strncat(result, ".", size); +- size -= 1; +- strncat(result, nameString, size); +- size -= strlen(nameString); +- strncat(result, signatureString, size); ++ if (snprintf(result, size, ++ "%s.%s%s", ++ klassString, ++ nameString, ++ signatureString) >= size) { ++ // truncation ++ goto fail; ++ } + + if (nameString != NULL) free(nameString); + if (klassString != NULL) free(klassString); +@@ -1056,9 +1057,9 @@ + CHECK_FAIL(err); + } + if (deoptimized) { +- strncat(result + 1, " [deoptimized frame]; ", size-1); ++ strncat(result, " [deoptimized frame]; ", size - strlen(result) - 1); + } else { +- strncat(result + 1, " [compiled] ", size-1); ++ strncat(result, " [compiled] ", size - strlen(result) - 1); + } + if (debug) + fprintf(stderr, "name_for_nmethod: END: method name: %s, vf_cnt: %d\n\n", +diff -Nru openjdk.orig/hotspot/src/share/tools/hsdis/hsdis.c openjdk/hotspot/src/share/tools/hsdis/hsdis.c +--- openjdk.orig/hotspot/src/share/tools/hsdis/hsdis.c 2019-04-05 19:21:24.000000000 +0100 ++++ openjdk/hotspot/src/share/tools/hsdis/hsdis.c 2019-04-16 16:05:31.445511866 +0100 +@@ -438,6 +438,7 @@ + } + p = q; + } ++ *iop = '\0'; + } + + static void print_help(struct hsdis_app_data* app_data, +diff -Nru openjdk.orig/hotspot/src/share/vm/compiler/compileBroker.hpp openjdk/hotspot/src/share/vm/compiler/compileBroker.hpp +--- openjdk.orig/hotspot/src/share/vm/compiler/compileBroker.hpp 2019-04-05 19:21:24.000000000 +0100 ++++ openjdk/hotspot/src/share/vm/compiler/compileBroker.hpp 2019-04-16 16:05:31.445511866 +0100 +@@ -173,7 +173,8 @@ + // these methods should be called in a thread safe context + + void set_current_method(const char* method) { +- strncpy(_current_method, method, (size_t)cmname_buffer_length); ++ strncpy(_current_method, method, (size_t)cmname_buffer_length-1); ++ _current_method[cmname_buffer_length-1] = '\0'; + if (UsePerfData) _perf_current_method->set_value(method); + } + +diff -Nru openjdk.orig/hotspot/src/share/vm/compiler/compilerOracle.cpp openjdk/hotspot/src/share/vm/compiler/compilerOracle.cpp +--- openjdk.orig/hotspot/src/share/vm/compiler/compilerOracle.cpp 2019-04-16 16:03:42.787215846 +0100 ++++ openjdk/hotspot/src/share/vm/compiler/compilerOracle.cpp 2019-04-16 16:05:31.445511866 +0100 +@@ -647,9 +647,7 @@ + // so read integer and fraction part of double value separately. + if (sscanf(line, "%*[ \t]%255[0-9]%*[ /\t]%255[0-9]%n", buffer[0], buffer[1], &bytes_read) == 2) { + char value[512] = ""; +- strncat(value, buffer[0], 255); +- strcat(value, "."); +- strncat(value, buffer[1], 255); ++ jio_snprintf(value, sizeof(value), "%s.%s", buffer[0], buffer[1]); + total_bytes_read += bytes_read; + return add_option_string(c_name, c_match, m_name, m_match, signature, flag, atof(value)); + } else { +diff -Nru openjdk.orig/hotspot/src/share/vm/compiler/disassembler.cpp openjdk/hotspot/src/share/vm/compiler/disassembler.cpp +--- openjdk.orig/hotspot/src/share/vm/compiler/disassembler.cpp 2019-04-05 19:21:24.000000000 +0100 ++++ openjdk/hotspot/src/share/vm/compiler/disassembler.cpp 2019-04-16 16:05:31.445511866 +0100 +@@ -298,6 +298,7 @@ + strlen((const char*)arg) > sizeof(buffer) - 1) { + // Only print this when the mach changes + strncpy(buffer, (const char*)arg, sizeof(buffer) - 1); ++ buffer[sizeof(buffer) - 1] = '\0'; + output()->print_cr("[Disassembling for mach='%s']", arg); + } + } else if (match(event, "format bytes-per-line")) { +diff -Nru openjdk.orig/hotspot/src/share/vm/runtime/arguments.cpp openjdk/hotspot/src/share/vm/runtime/arguments.cpp +--- openjdk.orig/hotspot/src/share/vm/runtime/arguments.cpp 2019-04-16 16:03:42.763216221 +0100 ++++ openjdk/hotspot/src/share/vm/runtime/arguments.cpp 2019-04-16 16:05:31.445511866 +0100 +@@ -3629,8 +3629,7 @@ + src ++; + } + +- char* copy = AllocateHeap(strlen(src) + 1, mtInternal); +- strncpy(copy, src, strlen(src) + 1); ++ char* copy = os::strdup_check_oom(src, mtInternal); + + // trim all trailing empty paths + for (char* tail = copy + strlen(copy) - 1; tail >= copy && *tail == separator; tail--) { +@@ -4013,18 +4012,14 @@ + if (end != NULL) *end = '\0'; + size_t jvm_path_len = strlen(jvm_path); + size_t file_sep_len = strlen(os::file_separator()); +- shared_archive_path = NEW_C_HEAP_ARRAY(char, jvm_path_len + +- file_sep_len + 20, mtInternal); ++ const size_t len = jvm_path_len + file_sep_len + 20; ++ shared_archive_path = NEW_C_HEAP_ARRAY(char, len, mtInternal); + if (shared_archive_path != NULL) { +- strncpy(shared_archive_path, jvm_path, jvm_path_len + 1); +- strncat(shared_archive_path, os::file_separator(), file_sep_len); +- strncat(shared_archive_path, "classes.jsa", 11); ++ jio_snprintf(shared_archive_path, len, "%s%sclasses.jsa", ++ jvm_path, os::file_separator()); + } + } else { +- shared_archive_path = NEW_C_HEAP_ARRAY(char, strlen(SharedArchiveFile) + 1, mtInternal); +- if (shared_archive_path != NULL) { +- strncpy(shared_archive_path, SharedArchiveFile, strlen(SharedArchiveFile) + 1); +- } ++ shared_archive_path = os::strdup_check_oom(SharedArchiveFile, mtInternal); + } + return shared_archive_path; + } +diff -Nru openjdk.orig/hotspot/src/share/vm/utilities/ostream.cpp openjdk/hotspot/src/share/vm/utilities/ostream.cpp +--- openjdk.orig/hotspot/src/share/vm/utilities/ostream.cpp 2019-04-05 19:21:24.000000000 +0100 ++++ openjdk/hotspot/src/share/vm/utilities/ostream.cpp 2019-04-16 16:06:46.896328647 +0100 +@@ -342,15 +342,19 @@ + assert(rm == NULL || Thread::current()->current_resource_mark() == rm, + "stringStream is re-allocated with a different ResourceMark"); + buffer = NEW_RESOURCE_ARRAY(char, end); +- strncpy(buffer, oldbuf, buffer_pos); ++ if (buffer_pos > 0) { ++ memcpy(buffer, oldbuf, buffer_pos); ++ } + buffer_length = end; + } + } + // invariant: buffer is always null-terminated + guarantee(buffer_pos + write_len + 1 <= buffer_length, "stringStream oob"); +- buffer[buffer_pos + write_len] = 0; +- strncpy(buffer + buffer_pos, s, write_len); +- buffer_pos += write_len; ++ if (write_len > 0) { ++ buffer[buffer_pos + write_len] = 0; ++ memcpy(buffer + buffer_pos, s, write_len); ++ buffer_pos += write_len; ++ } + + // Note that the following does not depend on write_len. + // This means that position and count get updated +diff -Nru openjdk.orig/hotspot/src/share/vm/utilities/vmError.cpp openjdk/hotspot/src/share/vm/utilities/vmError.cpp +--- openjdk.orig/hotspot/src/share/vm/utilities/vmError.cpp 2019-04-16 16:03:40.295254924 +0100 ++++ openjdk/hotspot/src/share/vm/utilities/vmError.cpp 2019-04-16 16:05:31.445511866 +0100 +@@ -451,14 +451,7 @@ + #else + const char *file = _filename; + #endif +- size_t len = strlen(file); +- size_t buflen = sizeof(buf); +- +- strncpy(buf, file, buflen); +- if (len + 10 < buflen) { +- sprintf(buf + len, ":%d", _lineno); +- } +- st->print(" (%s)", buf); ++ st->print(" (%s:%d)", file, _lineno); + } else { + st->print(" (0x%x)", _id); + } diff -r a218d3f3a16f -r 7e0780d57319 patches/hotspot/shenandoah/8076475-pr3696.patch --- a/patches/hotspot/shenandoah/8076475-pr3696.patch Mon Oct 19 16:56:16 2020 +0100 +++ b/patches/hotspot/shenandoah/8076475-pr3696.patch Wed Oct 21 19:16:00 2020 +0100 @@ -4,153 +4,11 @@ # Tue Feb 12 03:14:08 2019 +0000 # Node ID 9bbf02572dc114e85829673a7cdaffa482115f42 # Parent cfb34db6589e222d34e5b736b99ed4f69c261c4f +# Adapted to apply against version of JDK-8076475 in 8u272-b04 8076475, PR3696: Misuses of strncpy/strncat Summary: Various small fixes around strncpy and strncat Reviewed-by: dsamersoff, coleenp -diff -Nru openjdk.orig/hotspot/agent/src/os/bsd/libproc_impl.c openjdk/hotspot/agent/src/os/bsd/libproc_impl.c ---- openjdk.orig/hotspot/agent/src/os/bsd/libproc_impl.c 2019-04-05 19:21:24.000000000 +0100 -+++ openjdk/hotspot/agent/src/os/bsd/libproc_impl.c 2019-04-16 16:05:31.441511929 +0100 -@@ -215,7 +215,12 @@ - return NULL; - } - -- strncpy(newlib->name, libname, sizeof(newlib->name)); -+ if (strlen(libname) >= sizeof(newlib->name)) { -+ print_debug("libname %s too long\n", libname); -+ return NULL; -+ } -+ strcpy(newlib->name, libname); -+ - newlib->base = base; - - if (fd == -1) { -diff -Nru openjdk.orig/hotspot/agent/src/os/linux/libproc_impl.c openjdk/hotspot/agent/src/os/linux/libproc_impl.c ---- openjdk.orig/hotspot/agent/src/os/linux/libproc_impl.c 2019-04-05 19:21:24.000000000 +0100 -+++ openjdk/hotspot/agent/src/os/linux/libproc_impl.c 2019-04-16 16:05:31.441511929 +0100 -@@ -162,7 +162,12 @@ - return NULL; - } - -- strncpy(newlib->name, libname, sizeof(newlib->name)); -+ if (strlen(libname) >= sizeof(newlib->name)) { -+ print_debug("libname %s too long\n", libname); -+ return NULL; -+ } -+ strcpy(newlib->name, libname); -+ - newlib->base = base; - - if (fd == -1) { -diff -Nru openjdk.orig/hotspot/src/os/bsd/dtrace/libjvm_db.c openjdk/hotspot/src/os/bsd/dtrace/libjvm_db.c ---- openjdk.orig/hotspot/src/os/bsd/dtrace/libjvm_db.c 2019-04-05 19:21:24.000000000 +0100 -+++ openjdk/hotspot/src/os/bsd/dtrace/libjvm_db.c 2019-04-16 16:05:31.441511929 +0100 -@@ -543,13 +543,14 @@ - CHECK_FAIL(err); - - result[0] = '\0'; -- strncat(result, klassString, size); -- size -= strlen(klassString); -- strncat(result, ".", size); -- size -= 1; -- strncat(result, nameString, size); -- size -= strlen(nameString); -- strncat(result, signatureString, size); -+ if (snprintf(result, size, -+ "%s.%s%s", -+ klassString, -+ nameString, -+ signatureString) >= size) { -+ // truncation -+ goto fail; -+ } - - if (nameString != NULL) free(nameString); - if (klassString != NULL) free(klassString); -@@ -1056,9 +1057,9 @@ - CHECK_FAIL(err); - } - if (deoptimized) { -- strncat(result + 1, " [deoptimized frame]; ", size-1); -+ strncat(result, " [deoptimized frame]; ", size - strlen(result) - 1); - } else { -- strncat(result + 1, " [compiled] ", size-1); -+ strncat(result, " [compiled] ", size - strlen(result) - 1); - } - if (debug) - fprintf(stderr, "name_for_nmethod: END: method name: %s, vf_cnt: %d\n\n", -diff -Nru openjdk.orig/hotspot/src/os/bsd/vm/decoder_machO.cpp openjdk/hotspot/src/os/bsd/vm/decoder_machO.cpp ---- openjdk.orig/hotspot/src/os/bsd/vm/decoder_machO.cpp 2019-04-05 19:21:24.000000000 +0100 -+++ openjdk/hotspot/src/os/bsd/vm/decoder_machO.cpp 2019-04-16 16:05:31.441511929 +0100 -@@ -97,6 +97,7 @@ - char * symname = mach_find_in_stringtable((char*) ((uintptr_t)mach_base + stroff), strsize, found_strx); - if (symname) { - strncpy(buf, symname, buflen); -+ buf[buflen - 1] = '\0'; - return true; - } - DEBUG_ONLY(tty->print_cr("no string or null string found.")); -diff -Nru openjdk.orig/hotspot/src/os/solaris/dtrace/libjvm_db.c openjdk/hotspot/src/os/solaris/dtrace/libjvm_db.c ---- openjdk.orig/hotspot/src/os/solaris/dtrace/libjvm_db.c 2019-04-05 19:21:24.000000000 +0100 -+++ openjdk/hotspot/src/os/solaris/dtrace/libjvm_db.c 2019-04-16 16:05:31.441511929 +0100 -@@ -543,13 +543,14 @@ - CHECK_FAIL(err); - - result[0] = '\0'; -- strncat(result, klassString, size); -- size -= strlen(klassString); -- strncat(result, ".", size); -- size -= 1; -- strncat(result, nameString, size); -- size -= strlen(nameString); -- strncat(result, signatureString, size); -+ if (snprintf(result, size, -+ "%s.%s%s", -+ klassString, -+ nameString, -+ signatureString) >= size) { -+ // truncation -+ goto fail; -+ } - - if (nameString != NULL) free(nameString); - if (klassString != NULL) free(klassString); -@@ -1056,9 +1057,9 @@ - CHECK_FAIL(err); - } - if (deoptimized) { -- strncat(result + 1, " [deoptimized frame]; ", size-1); -+ strncat(result, " [deoptimized frame]; ", size - strlen(result) - 1); - } else { -- strncat(result + 1, " [compiled] ", size-1); -+ strncat(result, " [compiled] ", size - strlen(result) - 1); - } - if (debug) - fprintf(stderr, "name_for_nmethod: END: method name: %s, vf_cnt: %d\n\n", -diff -Nru openjdk.orig/hotspot/src/share/tools/hsdis/hsdis.c openjdk/hotspot/src/share/tools/hsdis/hsdis.c ---- openjdk.orig/hotspot/src/share/tools/hsdis/hsdis.c 2019-04-05 19:21:24.000000000 +0100 -+++ openjdk/hotspot/src/share/tools/hsdis/hsdis.c 2019-04-16 16:05:31.445511866 +0100 -@@ -438,6 +438,7 @@ - } - p = q; - } -+ *iop = '\0'; - } - - static void print_help(struct hsdis_app_data* app_data, -diff -Nru openjdk.orig/hotspot/src/share/vm/compiler/compileBroker.hpp openjdk/hotspot/src/share/vm/compiler/compileBroker.hpp ---- openjdk.orig/hotspot/src/share/vm/compiler/compileBroker.hpp 2019-04-05 19:21:24.000000000 +0100 -+++ openjdk/hotspot/src/share/vm/compiler/compileBroker.hpp 2019-04-16 16:05:31.445511866 +0100 -@@ -173,7 +173,8 @@ - // these methods should be called in a thread safe context - - void set_current_method(const char* method) { -- strncpy(_current_method, method, (size_t)cmname_buffer_length); -+ strncpy(_current_method, method, (size_t)cmname_buffer_length-1); -+ _current_method[cmname_buffer_length-1] = '\0'; - if (UsePerfData) _perf_current_method->set_value(method); - } - diff -Nru openjdk.orig/hotspot/src/share/vm/compiler/compilerOracle.cpp openjdk/hotspot/src/share/vm/compiler/compilerOracle.cpp --- openjdk.orig/hotspot/src/share/vm/compiler/compilerOracle.cpp 2019-04-16 16:03:42.787215846 +0100 +++ openjdk/hotspot/src/share/vm/compiler/compilerOracle.cpp 2019-04-16 16:05:31.445511866 +0100 @@ -165,97 +23,24 @@ total_bytes_read += bytes_read; return add_option_string(c_name, c_match, m_name, m_match, signature, flag, atof(value)); } else { -diff -Nru openjdk.orig/hotspot/src/share/vm/compiler/disassembler.cpp openjdk/hotspot/src/share/vm/compiler/disassembler.cpp ---- openjdk.orig/hotspot/src/share/vm/compiler/disassembler.cpp 2019-04-05 19:21:24.000000000 +0100 -+++ openjdk/hotspot/src/share/vm/compiler/disassembler.cpp 2019-04-16 16:05:31.445511866 +0100 -@@ -298,6 +298,7 @@ - strlen((const char*)arg) > sizeof(buffer) - 1) { - // Only print this when the mach changes - strncpy(buffer, (const char*)arg, sizeof(buffer) - 1); -+ buffer[sizeof(buffer) - 1] = '\0'; - output()->print_cr("[Disassembling for mach='%s']", arg); - } - } else if (match(event, "format bytes-per-line")) { -diff -Nru openjdk.orig/hotspot/src/share/vm/runtime/arguments.cpp openjdk/hotspot/src/share/vm/runtime/arguments.cpp ---- openjdk.orig/hotspot/src/share/vm/runtime/arguments.cpp 2019-04-16 16:03:42.763216221 +0100 -+++ openjdk/hotspot/src/share/vm/runtime/arguments.cpp 2019-04-16 16:05:31.445511866 +0100 -@@ -3629,8 +3629,7 @@ +diff --git openjdk.orig/hotspot/src/share/vm/runtime/arguments.cpp openjdk/hotspot/src/share/vm/runtime/arguments.cpp +--- openjdk.orig/hotspot/src/share/vm/runtime/arguments.cpp ++++ openjdk/hotspot/src/share/vm/runtime/arguments.cpp +@@ -3476,7 +3476,7 @@ src ++; } -- char* copy = AllocateHeap(strlen(src) + 1, mtInternal); -- strncpy(copy, src, strlen(src) + 1); +- char* copy = os::strdup(src, mtInternal); + char* copy = os::strdup_check_oom(src, mtInternal); // trim all trailing empty paths for (char* tail = copy + strlen(copy) - 1; tail >= copy && *tail == separator; tail--) { -@@ -4013,18 +4012,14 @@ - if (end != NULL) *end = '\0'; - size_t jvm_path_len = strlen(jvm_path); - size_t file_sep_len = strlen(os::file_separator()); -- shared_archive_path = NEW_C_HEAP_ARRAY(char, jvm_path_len + -- file_sep_len + 20, mtInternal); -+ const size_t len = jvm_path_len + file_sep_len + 20; -+ shared_archive_path = NEW_C_HEAP_ARRAY(char, len, mtInternal); - if (shared_archive_path != NULL) { -- strncpy(shared_archive_path, jvm_path, jvm_path_len + 1); -- strncat(shared_archive_path, os::file_separator(), file_sep_len); -- strncat(shared_archive_path, "classes.jsa", 11); -+ jio_snprintf(shared_archive_path, len, "%s%sclasses.jsa", -+ jvm_path, os::file_separator()); +@@ -3862,7 +3862,7 @@ + jvm_path, os::file_separator()); } } else { -- shared_archive_path = NEW_C_HEAP_ARRAY(char, strlen(SharedArchiveFile) + 1, mtInternal); -- if (shared_archive_path != NULL) { -- strncpy(shared_archive_path, SharedArchiveFile, strlen(SharedArchiveFile) + 1); -- } +- shared_archive_path = os::strdup(SharedArchiveFile, mtInternal); + shared_archive_path = os::strdup_check_oom(SharedArchiveFile, mtInternal); } return shared_archive_path; } -diff -Nru openjdk.orig/hotspot/src/share/vm/utilities/ostream.cpp openjdk/hotspot/src/share/vm/utilities/ostream.cpp ---- openjdk.orig/hotspot/src/share/vm/utilities/ostream.cpp 2019-04-05 19:21:24.000000000 +0100 -+++ openjdk/hotspot/src/share/vm/utilities/ostream.cpp 2019-04-16 16:06:46.896328647 +0100 -@@ -342,15 +342,19 @@ - assert(rm == NULL || Thread::current()->current_resource_mark() == rm, - "stringStream is re-allocated with a different ResourceMark"); - buffer = NEW_RESOURCE_ARRAY(char, end); -- strncpy(buffer, oldbuf, buffer_pos); -+ if (buffer_pos > 0) { -+ memcpy(buffer, oldbuf, buffer_pos); -+ } - buffer_length = end; - } - } - // invariant: buffer is always null-terminated - guarantee(buffer_pos + write_len + 1 <= buffer_length, "stringStream oob"); -- buffer[buffer_pos + write_len] = 0; -- strncpy(buffer + buffer_pos, s, write_len); -- buffer_pos += write_len; -+ if (write_len > 0) { -+ buffer[buffer_pos + write_len] = 0; -+ memcpy(buffer + buffer_pos, s, write_len); -+ buffer_pos += write_len; -+ } - - // Note that the following does not depend on write_len. - // This means that position and count get updated -diff -Nru openjdk.orig/hotspot/src/share/vm/utilities/vmError.cpp openjdk/hotspot/src/share/vm/utilities/vmError.cpp ---- openjdk.orig/hotspot/src/share/vm/utilities/vmError.cpp 2019-04-16 16:03:40.295254924 +0100 -+++ openjdk/hotspot/src/share/vm/utilities/vmError.cpp 2019-04-16 16:05:31.445511866 +0100 -@@ -451,14 +451,7 @@ - #else - const char *file = _filename; - #endif -- size_t len = strlen(file); -- size_t buflen = sizeof(buf); -- -- strncpy(buf, file, buflen); -- if (len + 10 < buflen) { -- sprintf(buf + len, ":%d", _lineno); -- } -- st->print(" (%s)", buf); -+ st->print(" (%s:%d)", file, _lineno); - } else { - st->print(" (0x%x)", _id); - }