Created attachment 37127 [details] crash pid file We notice JVM crash occurring when we try to write workbook very rarely. Code in summary would be as follows OPCPackage opcPackage = OPCPackage.open(workbookFilename, PackageAccess.READ_WRITE); Workbook workbook = new XSSFWorkbook(opcPackage); File tmpFile = tmpFile = File.createTempFile(existingFile.getName(), ".tmp", new File(".")); try (FileOutputStream fos = new FileOutputStream(tmpFile)) { workbook.write(fos); } Details of the crash would be attached in the PID file
Apache POI version - 3.15
This does not look like a POI bug to me, but rather a JVM bug: # # A fatal error has been detected by the Java Runtime Environment: # # SIGBUS (0x7) at pc=0x00007ff613be8a32, pid=33123, tid=140691906696960 # # JRE version: Java(TM) SE Runtime Environment (8.0_91-b14) (build 1.8.0_91-b14) # Java VM: Java HotSpot(TM) 64-Bit Server VM (25.91-b14 mixed mode linux-amd64 compressed oops) # Problematic frame: # C [libzip.so+0x11a32] newEntry+0x62 # Please first update your Java installation to a more recent patch level of Java 8 (current for Java 8 is Java 8 Update 241 CPU) and report back if you can reproduce the crash.
BTW: I have seen bug reports JVM crashes with SIGBUS when creating temp files and there's not enough space left on the device. But these should have already been fixed even in your 4 year-old version of Java. As a side note, the double assignment to `tmpFile` looks really weird (but it has nothing to do with the crash): File tmpFile = tmpFile = File.createTempFile(existingFile.getName(), ".tmp", new File("."));
Thanks for responding Axel. double assignment of tmp is my mistake while copy and paste and formatting. Also I see another bug link which is close to crash location https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8186557 and they recommend disabling memory mapping. Not sure whether that would help. Also see another stack overflow message, which talks about WorkBookFactory https://stackoverflow.com/questions/11344131/jvm-crashing-while-writing-to-xlsx-file-poi/17329250
Java programs shouldn't be able to crash the JVM. I think you'll need to report this to Oracle or OpenJDK (depending on which JDK you use)
A little info I copied from https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8233188 : > Historically, native crashes in > java.util.zip.ZipFile::getNextEntry > were invariably due to the zip file being overwritten while running. (DON'T DO THAT) > In recent jdks, I think this was addressed by moving the native code into java (and not using mmap). Since the bug seems to be within the JDK, and should be fixed in more recent versions, you should first update your JDK 8 and see if you can reproduce the crash. Alternatively disable mmap or make sure files are not changed/moved/deleted while writing the workbook.
This seems to be a problem in the JDK itself, so there is nothing that we can fix in Apache POI as far as I see, thus I am closing this for now.