Skip to content

SIGSEGV / core dump in jvm when accessing archive item properties while archive is closing in other thread, with example #70

@dev747368

Description

@dev747368

Error:

[thread 5616 also had an error][thread 5617 also had an error]

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f7ef8f2d906, pid=5598, tid=5618
#
# JRE version: OpenJDK Runtime Environment Corretto-21.0.3.9.1 (21.0.3+9) (build 21.0.3+9-LTS)
# Java VM: OpenJDK 64-Bit Server VM Corretto-21.0.3.9.1 (21.0.3+9-LTS, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# C  [lib7-Zip-JBinding.so+0x12d906]  Java_net_sf_sevenzipjbinding_impl_InArchiveImpl_nativeGetStringProperty+0x216
#
# Core dump will be written. Default location: Core dumps may be processed with "/bin/false" (or dumping to /..redacted../core.5598)
#
# An error report file with more information is saved as:
# /..redacted.../hs_err_pid5598.log
[0.114s][warning][os] Loading hsdis library failed
#
# If you would like to submit a bug report, please visit:
#   https://github.com/corretto/corretto-21/issues/
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

Example to reproduce:

import java.io.*;

import net.sf.sevenzipjbinding.*;
import net.sf.sevenzipjbinding.simple.*;
import net.sf.sevenzipjbinding.util.*;

public class test {

	public static void main(String[] args) throws Throwable {
		String so = "/path/to/Linux-amd64/lib7-Zip-JBinding.so";
		System.load(so);
		SevenZip.initLoadedLibraries();

		byte[] bytes = new FileInputStream(new File("/path/to/zip")).readAllBytes();
		ByteArrayStream bas = new ByteArrayStream(bytes, false);
		try (IInArchive archive = SevenZip.openInArchive(null, bas)) {
			ISimpleInArchiveItem[] items = archive.getSimpleInterface().getArchiveItems();
			for (ISimpleInArchiveItem item : items) {
				System.out.println("starting thread for: " + item.getPath());
				Thread th = new Thread(() -> {
					while (true) {
						try {
							item.getPath();
						}
						catch (Throwable e) {
							e.printStackTrace();
						}
					}
				});
				th.setDaemon(true);
				th.start();
			}
			Thread.sleep(500);
			System.out.println("closing archive");
		}
		catch (SevenZipException e) {
			e.printStackTrace();
		}

		System.out.println("waiting before exit");
		Thread.sleep(100);
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions