Skip to content

maybe a java bug #8

@umjammer

Description

@umjammer

old code (after the patch below)

diff --git a/src/main/java/vavi/speech/phonemizer/SudachiJaPhonemizer.java b/src/main/java/vavi/speech/phonemizer/SudachiJaPhonemizer.java
index c0045e2..8314106 100644
--- a/src/main/java/vavi/speech/phonemizer/SudachiJaPhonemizer.java
+++ b/src/main/java/vavi/speech/phonemizer/SudachiJaPhonemizer.java
@@ -38,12 +38,14 @@ public class SudachiJaPhonemizer implements JaPhonemizer {
 
     public SudachiJaPhonemizer() {
         try {
-            Config config = Config.fromClasspath("sudachi.json");
-            Dictionary dict = new DictionaryFactory().create(config);
+        Config config = Config.fromClasspath("sudachi.json");
+        try (
+            Dictionary dict = new DictionaryFactory().create(config)) {
             tokenizer = dict.create();
-            Runtime.getRuntime().addShutdownHook(new Thread(() -> {
-                try { dict.close(); } catch (IOException e) { throw new UncheckedIOException(e); }
-            }));
+//            Runtime.getRuntime().addShutdownHook(new Thread(() -> {
+//                try { dict.close(); } catch (IOException e) { throw new UncheckedIOException(e); }
+//            }));
+            }
         } catch (IOException e) {
             throw new UncheckedIOException(e);
         }

causes crash around java.nio.DirectIntBufferU#get(int).

hs_err_pid92309.log

after the patch above, this program will have a bug that closing dict before using that.

but on catalina the program after the patch works, it contains a bug though.

$ java -version                                                                                                                                                                                                master
java version "1.8.0_301"
Java(TM) SE Runtime Environment (build 1.8.0_301-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.301-b09, mixed mode)
nsano@nsanomac3 02:22:08 ~/src/java/vavi-speech2 
$ uname -a                                                                                                                                                                                                     master
Darwin nsanomac3 19.6.0 Darwin Kernel Version 19.6.0: Tue Jun 21 21:18:39 PDT 2022; root:xnu-6153.141.66~1/RELEASE_X86_64 x86_64 i386 Darwin

on the other hand, on monterey the program after patch cause crash. java should throw an exception.

$ java -version                                                                                                                                                                                                   0.1.7
java version "1.8.0_341"
Java(TM) SE Runtime Environment (build 1.8.0_341-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.341-b10, mixed mode)
$ uname -a                                                                                                                                                                                                        0.1.7
Darwin nsanomac4 21.6.0 Darwin Kernel Version 21.6.0: Thu Sep 29 20:12:57 PDT 2022; root:xnu-8020.240.7~1/RELEASE_X86_64 x86_64

i couldn't create a small sample bug reproducer. because there is no way to create a java.nio.DirectIntBufferU instance.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions