Menu

#1279 Checking for problems throws error: "Comparison method violates its general contract"

6.0.2
open-fixed
None
5
2026-01-17
2024-12-26
No

I recently downloaded the latest realease, but now "Checking for problems" (Ctrl + Shift + V) throws an error: "Comparison method violates its general contract".

Does anyone have any idea on how to fix this?

1 Attachments

Discussion

1 2 > >> (Page 1 of 2)
  • Erik De Boeck

    Erik De Boeck - 2024-12-26

    I downloaded and installed the latest weekly release, and now the check works. But the beta version was really slow, so I reverted back to the stable release...

    So a solution would still interest me. :)

     

    Last edit: Erik De Boeck 2024-12-26
  • Erik De Boeck

    Erik De Boeck - 2025-01-13

    I cleared the logs, re-opened OmegaT, and exported the logs to the file "before error". I then ran "Checking for problems" (not sure how it's called exactly in English), and saved the new file "after error". The error statements begin on line 467.

     
  • Hiroshi Miura

    Hiroshi Miura - 2025-04-28

    Thank you for the report.

    I picked the lines from the reported log

    18709: Fout: Caused by: java.lang.IllegalArgumentException: Comparison method violates its general contract! 
    18709: Fout:    at java.base/java.util.TimSort.mergeLo(Unknown Source) 
    18709: Fout:    at java.base/java.util.TimSort.mergeAt(Unknown Source) 
    18709: Fout:    at java.base/java.util.TimSort.mergeCollapse(Unknown Source) 
    18709: Fout:    at java.base/java.util.TimSort.sort(Unknown Source) 
    18709: Fout:    at java.base/java.util.Arrays.sort(Unknown Source) 
    18709: Fout:    at java.base/java.util.ArrayList.sort(Unknown Source) 
    18709: Fout:    at org.omegat.gui.glossary.GlossarySearcher.sortGlossaryEntries(GlossarySearcher.java:249) 
    

    The source code in OmegaT 6.0 of GlossarySearcher class line 249 is like

    https://github.com/omegat-org/omegat/blob/releases/6.0/src/org/omegat/gui/glossary/GlossarySearcher.java#L248-L251

        static void sortGlossaryEntries(List<GlossaryEntry> entries) {
            entries.sort((o1, o2) -> {
                int p1 = o1.getPriority() ? 1 : 2;
                int p2 = o2.getPriority() ? 1 : 2;
    

    There are several bad habits in the function.

    1. direct maniipulation of the argument list
    2. no null checks

    It should be changed such as

        static List<GlossaryEntry> sortGlossaryEntries(List<GlossaryEntry> entries) {
            if (entries == null) {
               /* raise error */
              }
            return entries.filter(Objects::notNull).sort((o1, o2) -> {
                int p1 = o1.getPriority() ? 1 : 2;
                int p2 = o2.getPriority() ? 1 : 2;
    
     
  • Hiroshi Miura

    Hiroshi Miura - 2025-04-28

    I find an error from MS office filter from the log.

    18709: FINE: Error checking if file is supported by OpenXMLFilter: C:\Users\Erik\Google Drive\Scheidsrechteren\Vertalingen\OmegaT\IFAF Engels-Nederlands\source\~$rtalingsvoorbereiding.docx 
    18709: FINE: java.util.zip.ZipException: zip END header not found 
    18709: FINE:    at java.base/java.util.zip.ZipFile$Source.zerror(Unknown Source) 
    18709: FINE:    at java.base/java.util.zip.ZipFile$Source.findEND(Unknown Source) 
    18709: FINE:    at java.base/java.util.zip.ZipFile$Source.initCEN(Unknown Source) 
    18709: FINE:    at java.base/java.util.zip.ZipFile$Source.<init>(Unknown Source) 
    18709: FINE:    at java.base/java.util.zip.ZipFile$Source.get(Unknown Source) 
    18709: FINE:    at java.base/java.util.zip.ZipFile$CleanableResource.<init>(Unknown Source) 
    18709: FINE:    at java.base/java.util.zip.ZipFile$CleanableResource.get(Unknown Source) 
    18709: FINE:    at java.base/java.util.zip.ZipFile.<init>(Unknown Source) 
    18709: FINE:    at java.base/java.util.zip.ZipFile.<init>(Unknown Source) 
    18709: FINE:    at java.base/java.util.zip.ZipFile.<init>(Unknown Source) 
    18709: FINE:    at org.omegat.filters3.xml.openxml.OpenXMLFilter.isFileSupported(OpenXMLFilter.java:159) 
    

    Your office file is broken such as partial download or somthing.

     
  • Hiroshi Miura

    Hiroshi Miura - 2025-04-28

    Pushed PR https://github.com/omegat-org/omegat/pull/1365 for release 6.0 branch.

    The problem may be also exist on current master/6.1 beta versions.

     

    Last edit: Hiroshi Miura 2025-04-28
    • Hiroshi Miura

      Hiroshi Miura - 2025-05-26
       
  • Jean-Christophe Helary

    @backjudge88, Hiroshi has implemented a fix in that PR. Could you build the code and see if the solution works? If you can’t build the code, we can provide you with a compiled version.

     
  • Hiroshi Miura

    Hiroshi Miura - 2025-05-17

    @brandelune It's not appropriate to ask the reporter to verify the fix in this case, because the issue stems from internal logic errors rather than user-facing behavior. The problems are:

    1. The StAX MS Office filter does not correctly handle MSO temporary files and raises exceptions when it shouldn't.
    2. The GlossarySearcher class does not handle null values properly when caused by the StAX filter.
    3. The GlossarySearcher class displays the resulting exception to the user, even though this error is internal and should be silently handled.

    This is an internal processing issue and not something the user should encounter directly.

    Required fixes:

    1. The StAX MS Office filter should ignore MSO temporary files.
    2. The GlossarySearcher should be made robust against null inputs.
    3. Exceptions from internal logic should be handled gracefully and not shown to end users.
     
    👍
    1
    • Jean-Christophe Helary

      Ok. My bad. Thank you for pointing that out.

       
    • Erik De Boeck

      Erik De Boeck - 2025-05-18

      So the issue is still unresolved? Or is it resolved, but am I unable to check it/contribute?

       
      • Jean-Christophe Helary

        You can build the code from the PR if you want. Or you can wait for the weekly release after the merging.

         
  • Hiroshi Miura

    Hiroshi Miura - 2025-06-14

    I have built the jar for the topic branch.
    When you have a installation of the OmegaT 6.0.1 and test the change here, you can replace your installed OmegaT.jar with the attachment.

     
    • Hiroshi Miura

      Hiroshi Miura - 2025-06-22

      There is an application folder on your OS. Please check manual.
      https://omegat.sourceforge.io/manual-snapshot/en/chapter.appendices.html#application.folder

      You should check current application folder has files such as readme.txt, OmegaT.jar , and others. You should rename current OmegaT.jar with OmegaT-old.jar then copy the hotfix OmegaT.jar to there.

       
      • Erik De Boeck

        Erik De Boeck - 2025-06-22

        That's what I did in attempts 2-4.

         
  • Erik De Boeck

    Erik De Boeck - 2025-06-21

    I wasn't fully sure what you meant, but in any case:
    1. Running the jar from a folder with only the jar resulted in this error:

    PS C:\PortbleApps\OmegaT> java -jar OmegaT.jar
    87576: Info: ===================================================================
    87576: Info: OmegaT-6.0.2_0_a2b8cf3f7 (Sat Jun 21 08:42:13 CEST 2025)  Locale nl_BE
    87576: Info: Java: Oracle Corporation ver. 21.0.6, uitgevoerd vanaf 'C:\Program Files\Java\jdk-21' (LOG_STARTUP_INFO)
    Exception in thread "main" java.lang.NoClassDefFoundError: com/vlsolutions/swing/docking/event/DockableStateWillChangeListener
            at org.omegat.convert.ConvertConfigs.convert(ConvertConfigs.java:56)
            at org.omegat.Main.main(Main.java:188)
    Caused by: java.lang.ClassNotFoundException: com.vlsolutions.swing.docking.event.DockableStateWillChangeListener
            at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
            at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
            at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
            ... 2 more
    
    1. Replacing the jar file of my installed OmegaT instance resulted in the same error window as in my first post. Unfortunately, I didn't think of exporting logs.
    2. Downloading "Windows installer packaged with 64-bit JRE" again and re-installing (which probably was pointless, because I now see the latest change was done in August 2024), and tried "checking for problems". Same error window.
    3. I again replaced the jar in the OmegaT installation folder. Now I saved the logs before trying to "check for problems". Same result. I then saved the logs again.
     
  • Hiroshi Miura

    Hiroshi Miura - 2025-08-20
    • assigned_to: Hiroshi Miura
    • Group: 6.0 --> 6.0.2
     
    👍
    1
  • Hiroshi Miura

    Hiroshi Miura - 2025-09-10
    • status: open --> open-fixed
     
  • Hiroshi Miura

    Hiroshi Miura - 2025-09-10

    The fix was merged in 3 month ago, and waiting release.

     
  • Erik De Boeck

    Erik De Boeck - 2025-12-29

    I ran into this problem again... I tried the latest build of 6.0.2, which threw an error when loading the project. The error refers to a file that doesn't exist:

    PS C:\Users\Erik\Google Drive\Scheidsrechteren\Vertalingen\OmegaT\IFAF Engels-Nederlands\source> dir
    
        Directory: C:\Users\Erik\Google Drive\Scheidsrechteren\Vertalingen\OmegaT\IFAF Engels-Nederlands\source
    
    Mode                 LastWriteTime         Length Name
    ----                 -------------         ------ ----
    -a---          27/10/2022    20:44          12268 Crew equipment checklist.xlsx
    -a---           6/02/2023    17:05          25449 IAFOA MOFO Backside book cover text.docx
    -a---          22/06/2025    10:50       11522634 IAFOA MOFO.docx
    -a---           7/01/2023    16:23          24064 IFAF Rules Backside book cover text.docx
    -a---          22/06/2025    10:53       12513270 IFAF Rules.docx
    -a---          29/12/2025     9:13          46100 Voorbereiding 2026.docx
    
    PS C:\Users\Erik\Google Drive\Scheidsrechteren\Vertalingen\OmegaT\IFAF Engels-Nederlands\source>
    

    Then, when checking for errors, the Comparison method violates its general contract pops up again. Again, see attached logs.

     

    Last edit: Erik De Boeck 2025-12-29
  • Erik De Boeck

    Erik De Boeck - 2025-12-30

    Okay, I found out that there is a second level to hidden files in Windows, so I got rid of ~$rtalingsvoorbereiding.docx. But that didn't change anything for the error about which this ticket is.

     
  • Erik De Boeck

    Erik De Boeck - 2025-12-30

    Since I opened the ticket a few months ago, I've gained a bit more understanding of Java. It looks like we're being directed to GlossarySearcher.java:279, but that line is empty (https://github.com/omegat-org/omegat/blob/6327a55c9b1884c0a9561419d8a092d9b4641e5f/src/org/omegat/gui/glossary/GlossarySearcher.java#L279).

    So the weekly build of 6.0.2 must not be from the master branch?

    When I run 6.1.0's weekly build, I don't get the error.

    But for full disclosure, that version threw these errors at startup:

    15:42:59.213: Fout: java.lang.ClassNotFoundException:
    15:42:59.213: Fout:     at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
    15:42:59.214: Fout:     at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
    15:42:59.214: Fout:     at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
    15:42:59.214: Fout:     at org.omegat.gui.properties.SegmentPropertiesArea.<init>(SegmentPropertiesArea.java:129)
    15:42:59.214: Fout:     at org.omegat.core.Core.initializeGUIimpl(Core.java:283)
    15:42:59.214: Fout:     at org.omegat.core.Core.initializeGUI(Core.java:247)
    15:42:59.214: Fout:     at org.omegat.Main.runGUI(Main.java:388)
    15:42:59.214: Fout:     at org.omegat.Main.main(Main.java:241)
    15:42:59.293: Info: Gebeurtenis: stoppen van toepassing (LOG_INFO_EVENT_APPLICATION_STARTUP)
    15:42:59.916: Info: Beschikbare scriptprogramma's:
    15:42:59.916: Info:  - Groovy Scripting Engine Groovy v.5.0.3 (extensies: groovy)
    15:42:59.916: Info:  - OpenJDK Nashorn ECMAScript v.ECMA - 262 Edition 5.1 (extensies: js)
    15:43:00.313: Fout: Uncaught exception in thread [AWT-EventQueue-0] (LOG_ERROR_UNCAUGHT_EXCEPTION)
    15:43:00.313: Fout: java.lang.IllegalArgumentException: argument "in" is null
    15:43:00.313: Fout:     at com.fasterxml.jackson.databind.ObjectMapper._assertNotNull(ObjectMapper.java:5126)
    15:43:00.313: Fout:     at com.fasterxml.jackson.databind.ObjectMapper.readTree(ObjectMapper.java:3279)
    15:43:00.313: Fout:     at org.omegat.gui.tipoftheday.OmegaTTipOfTheDayModel.initTips(OmegaTTipOfTheDayModel.java:72)
    15:43:00.313: Fout:     at org.omegat.gui.tipoftheday.OmegaTTipOfTheDayModel.<init>(OmegaTTipOfTheDayModel.java:57)
    15:43:00.313: Fout:     at org.omegat.gui.tipoftheday.TipOfTheDayController.showComponent(TipOfTheDayController.java:60)
    15:43:00.313: Fout:     at org.omegat.gui.tipoftheday.TipOfTheDayController.start(TipOfTheDayController.java:55)
    15:43:00.313: Fout:     at org.omegat.gui.tipoftheday.TipOfTheDayModule$TipOfTheDayModuleListener.lambda$onApplicationStartup$0(TipOfTheDayModule.java:74)
    15:43:00.313: Fout:     at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
    15:43:00.313: Fout:     at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:773)
    15:43:00.313: Fout:     at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:720)
    15:43:00.313: Fout:     at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:714)
    15:43:00.313: Fout:     at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
    15:43:00.313: Fout:     at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)
    15:43:00.313: Fout:     at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
    15:43:00.313: Fout:     at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
    15:43:00.313: Fout:     at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
    15:43:00.313: Fout:     at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
    15:43:00.313: Fout:     at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
    15:43:00.313: Fout:     at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    15:43:00.313: Fout:     at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
    

    So in summary: the error is still there in 6.0.2, but not in 6.1.0.

     
    • Hiroshi Miura

      Hiroshi Miura - 2025-12-30

      Thank you for the feedback. A fix of ClassNotFound from SegmentPropertiesArea class has been merged yesterday with
      https://github.com/omegat-org/omegat/pull/1845
      This issue does not affect functions. Please check next weekly release.

       

      Last edit: Hiroshi Miura 2025-12-30
  • Hiroshi Miura

    Hiroshi Miura - 2025-12-31

    The Problem
    The issue was introduced to fix BUGS#1239 "feat: glossary support optional sort by src length"

    The issue is that the condition (o2.getSrcText().contains(o1.getSrcText()) || o1.getSrcText().contains(o2.getSrcText())) is used to decide whether to compare by length, but it doesn't guarantee a consistent ordering across multiple elements.

    A strategy

    // longer is better if one contains another
    

    causes a problem.

    For example:
    A contains B.
    B contains C.
    But A might NOT contain C (though in string terms it would, but imagine more complex logic or overlapping cases).

    More importantly, if A contains B, we sort by length. If A does not contain D, we might fall through to alphabetical sorting. This "switching" of sorting criteria based on a non-transitive property (like "contains") is what trips up TimSort.

    The Example
    Consider these three strings:
    A: "abc" (Length 3)
    B: "a" (Length 1)
    C: "bc" (Length 2)

    A contains B and C
    B does not contains C

    when compared with A-B A-C the determined order is A < B, A < C

    The trap:
    A: "apple pie" (Length 9)
    B: "apple" (Length 5)
    C: "banana" (Length 6)

    Comparisons:
    Compare A and B: A contains B. Sort by length (longer first). A < B (Result -4).
    Compare B and C: Neither contains the other. Sort alphabetically. B < C ("apple" < "banana").
    Compare A and C: Neither contains the other. Sort alphabetically. C < A ("banana" < "apple pie").

    The Violation: We have:

    A < B
    B < C
    ...but C < A!
    
     
  • Hiroshi Miura

    Hiroshi Miura - 2026-01-01

    I forgot I have already fixed the bug with PR#1424

    The PR for master branch.
    https://github.com/omegat-org/omegat/pull/1424

    It is why branch releases/6.0 has "contains" but master branch has "startsWith".

    Ok I want to align with the fix for v6.0.2 .

     
1 2 > >> (Page 1 of 2)

Log in to post a comment.