Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport] 8319053: Segment dump files remain after parallel heap dump on Windows #715

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/hotspot/share/services/heapDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ enum {

// Supports I/O operations for a dump

class DumpWriter : public ResourceObj {
class DumpWriter : public CHeapObj<mtInternal> {
private:
enum {
io_buffer_max_size = 1*M,
Expand Down Expand Up @@ -1734,7 +1734,9 @@ void DumpMerger::do_merge() {
#endif
}
// Delete selected segmented heap file nevertheless
remove(path);
if (remove(path) != 0) {
log_info(heapdump)("Removal of segment file (%d) failed (%d)", i, errno);
}
}

// restore compressor for further use
Expand Down Expand Up @@ -2264,6 +2266,7 @@ void VM_HeapDumper::work(uint worker_id) {
} else {
// propagate local error to global if any
_dumper_controller->dumper_complete(local_writer, writer());
delete local_writer;
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import jdk.test.lib.Asserts;
import jdk.test.lib.JDKToolLauncher;
Expand All @@ -40,14 +42,16 @@

/**
* @test
* @bug 8306441
* @bug 8306441 8319053
* @summary Verify the integrity of generated heap dump and capability of parallel dump
* @library /test/lib
* @run main HeapDumpParallelTest
*/

public class HeapDumpParallelTest {

private static final String heapDumpFileName = "parallelHeapDump.bin";

private static void checkAndVerify(OutputAnalyzer dcmdOut, LingeredApp app, File heapDumpFile, boolean expectSerial) throws IOException {
dcmdOut.shouldHaveExitValue(0);
dcmdOut.shouldContain("Heap dump file created");
Expand All @@ -66,6 +70,16 @@ private static void checkAndVerify(OutputAnalyzer dcmdOut, LingeredApp app, File
appOut.shouldNotContain("Merge heap files complete");
}
verifyHeapDump(heapDumpFile);

List<String> files
= Stream.of(heapDumpFile.getAbsoluteFile().getParentFile().listFiles())
.filter(file -> !file.isDirectory())
.map(File::getName)
.filter(name -> name.startsWith(heapDumpFileName) && !name.equals(heapDumpFileName))
.collect(Collectors.toList());
if (!files.isEmpty()) {
throw new RuntimeException("Unexpected files left: " + files);
}
if (heapDumpFile.exists()) {
heapDumpFile.delete();
}
Expand All @@ -83,8 +97,6 @@ private static LingeredApp launchApp() throws IOException {
}

public static void main(String[] args) throws Exception {
String heapDumpFileName = "parallelHeapDump.bin";

File heapDumpFile = new File(heapDumpFileName);
if (heapDumpFile.exists()) {
heapDumpFile.delete();
Expand Down