From a9f7e5db66007528f64321248700069c4268758a Mon Sep 17 00:00:00 2001 From: Antonio Vieiro Date: Wed, 18 Dec 2024 21:07:02 +0100 Subject: [PATCH] Backport eaa475f72ced51cf0f0d0bce9ff1265bfb81ab31 --- .../macosx/native/libsaproc/ps_core.c | 15 ++++++++++----- test/hotspot/jtreg/ProblemList.txt | 14 +++++++------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/jdk.hotspot.agent/macosx/native/libsaproc/ps_core.c b/src/jdk.hotspot.agent/macosx/native/libsaproc/ps_core.c index 992df0eacaf..4853a21ae64 100644 --- a/src/jdk.hotspot.agent/macosx/native/libsaproc/ps_core.c +++ b/src/jdk.hotspot.agent/macosx/native/libsaproc/ps_core.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021, Azul Systems, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -297,11 +297,16 @@ static bool read_core_segments(struct ps_prochandle* ph) { print_debug("failed to read LC_SEGMENT_64 i = %d!\n", i); goto err; } - if (add_map_info(ph, fd, segcmd.fileoff, segcmd.vmaddr, segcmd.vmsize, segcmd.flags) == NULL) { - print_debug("Failed to add map_info at i = %d\n", i); - goto err; + // The base of the library is offset by a random amount which ends up as a load command with a + // filesize of 0. This must be ignored otherwise the base address of the library is wrong. + if (segcmd.filesize != 0) { + if (add_map_info(ph, fd, segcmd.fileoff, segcmd.vmaddr, segcmd.vmsize, segcmd.flags) == NULL) { + print_debug("Failed to add map_info at i = %d\n", i); + goto err; + } } - print_debug("LC_SEGMENT_64 added: nsects=%d fileoff=0x%llx vmaddr=0x%llx vmsize=0x%llx filesize=0x%llx %s\n", + print_debug("LC_SEGMENT_64 %s: nsects=%d fileoff=0x%llx vmaddr=0x%llx vmsize=0x%llx filesize=0x%llx %s\n", + segcmd.filesize == 0 ? "with filesize == 0 ignored" : "added", segcmd.nsects, segcmd.fileoff, segcmd.vmaddr, segcmd.vmsize, segcmd.filesize, &segcmd.segname[0]); } else if (lcmd.cmd == LC_THREAD || lcmd.cmd == LC_UNIXTHREAD) { diff --git a/test/hotspot/jtreg/ProblemList.txt b/test/hotspot/jtreg/ProblemList.txt index bec65d11c54..a588af5eaf0 100644 --- a/test/hotspot/jtreg/ProblemList.txt +++ b/test/hotspot/jtreg/ProblemList.txt @@ -115,13 +115,13 @@ serviceability/sa/TestRevPtrsForInvokeDynamic.java 8241235 generic-all serviceability/jvmti/ModuleAwareAgents/ThreadStart/MAAThreadStart.java 8225354 windows-all serviceability/dcmd/gc/RunFinalizationTest.java 8227120 generic-all -serviceability/sa/ClhsdbCDSCore.java 8294316,8267433 macosx-x64 -serviceability/sa/ClhsdbFindPC.java#id1 8294316,8267433 macosx-x64 -serviceability/sa/ClhsdbFindPC.java#id3 8294316,8267433 macosx-x64 -serviceability/sa/ClhsdbPmap.java#id1 8294316,8267433 macosx-x64 -serviceability/sa/ClhsdbPstack.java#id1 8294316,8267433 macosx-x64 -serviceability/sa/TestJmapCore.java 8294316,8267433 macosx-x64 -serviceability/sa/TestJmapCoreMetaspace.java 8294316,8267433 macosx-x64 +serviceability/sa/ClhsdbCDSCore.java 8267433 macosx-x64 +serviceability/sa/ClhsdbFindPC.java#id1 8267433 macosx-x64 +serviceability/sa/ClhsdbFindPC.java#id3 8267433 macosx-x64 +serviceability/sa/ClhsdbPmap.java#id1 8267433 macosx-x64 +serviceability/sa/ClhsdbPstack.java#id1 8267433 macosx-x64 +serviceability/sa/TestJmapCore.java 8267433 macosx-x64 +serviceability/sa/TestJmapCoreMetaspace.java 8267433 macosx-x64 #############################################################################