rampaa / JL

JL is a program for looking up Japanese words and expressions.
Apache License 2.0
201 stars 4 forks source link

App crash when trying to mine from certain dictionaries #83

Closed watakaiiii closed 6 months ago

watakaiiii commented 6 months ago

First I was thinking it is related to dictionary not being from the list of supported but it actually also happens with some from supported dictionaries (e.g. meikyou, oubunsha, daijisen) It once crashed with kenkyuusha then I was able to mine another word perfectly fine from this dictionary. So it may not be related to particular dictionaries

Some examples when it happens: mining 事 from kenkyuusha, mining 事 from shinjirin, mining 事 from weblio kogo The common thing is that it is こと in the text and 事 in those dictionaries, dictionaries that list it as こと don't crash

Trying the same with 人: daijisen crashses, iwanami crashes, kenkyuusha crashes, oubunsha crashes

Logs:

System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
   at System.Collections.ArrayList.get_Item(Int32 index)
   at JL.Windows.GUI.PopupWindow.GetDefinitionTextBox(Int32 listViewIndex) in D:\a\JL\JL\JL.Windows\GUI\PopupWindow.xaml.cs:line 1821
   at JL.Windows.GUI.PopupWindow.GetSelectedDefinitions(Int32 listViewIndex) in D:\a\JL\JL\JL.Windows\GUI\PopupWindow.xaml.cs:line 1826
   at JL.Windows.GUI.PopupWindow.PrimarySpelling_PreviewMouseUp(Object sender, MouseButtonEventArgs e) in D:\a\JL\JL\JL.Windows\GUI\PopupWindow.xaml.cs:line 1096
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.Run()
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at System.Windows.Application.Run()
   at JL.Windows.App.Main()
watakaiiii commented 6 months ago

Complete reinstall fixed everything but I can't seem to remember what I've changed (if I even did) before the first crash happened that may be the reason. May it be that the first crash specifically (which I can't remember what word and what dictionary caused, but surely it was some not in the supported list) changed something? It seems so weird to me...

rampaa commented 6 months ago

First I was thinking it is related to dictionary not being from the list of supported

A dictionary being listed as a supported dictionary type should have no bearing on the mining functionality of JL.

Some examples when it happens: mining 事 from kenkyuusha, mining 事 from shinjirin, mining 事 from weblio kogo The common thing is that it is こと in the text and 事 in those dictionaries, dictionaries that list it as こと don't crash

Unfortunately I cannot reproduce the issue with the steps you've provided. I've looked up こと and mined the Weblio Kogo entry that has 事 as its primary spelling and it just worked as expected.

Complete reinstall fixed everything

Which version were you using before the complete install?

but I can't seem to remember what I've changed

Did you perhaps enable the "Don't show results under All" for some dictionaries? I'd like to reproduce the bug and fix it but with the steps you provided I can't reproduce it.

watakaiiii commented 6 months ago

Which version were you using before the complete install?

I was using the same version before and after reinstall (1.30.2)

Did you perhaps enable the "Don't show results under All" for some dictionaries? I'd like to reproduce the bug and fix it but with the steps you provided I can't reproduce it.

I haven't changed anything while importing dictionaries

I've found the word that first produced this bug, here's the sentence: "はぁ……。なんだその、めんどくさい話は。奴にそんな繊細な情緒はないだろ", the word is "情緒" and the dictionary is pixiv light, I'm using the 2024-04-23 version

Logs:

2024-04-25 15:40:32.678 +03:00 [FTL] Unhandled exception
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
   at System.Collections.ArrayList.get_Item(Int32 index)
   at JL.Windows.GUI.PopupWindow.GetDefinitionTextBox(Int32 listViewIndex) in D:\a\JL\JL\JL.Windows\GUI\PopupWindow.xaml.cs:line 1821
   at JL.Windows.GUI.PopupWindow.GetSelectedDefinitions(Int32 listViewIndex) in D:\a\JL\JL\JL.Windows\GUI\PopupWindow.xaml.cs:line 1826
   at JL.Windows.GUI.PopupWindow.PrimarySpelling_PreviewMouseUp(Object sender, MouseButtonEventArgs e) in D:\a\JL\JL\JL.Windows\GUI\PopupWindow.xaml.cs:line 1096
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.Run()
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at System.Windows.Application.Run()
   at JL.Windows.App.Main()
2024-04-25 15:40:47.612 +03:00 [ERR] Injecting One Core voices failed
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Speech.Internal.ObjectTokens.ObjectTokenCategory.Create(String sCategoryId)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at JL.Windows.SpeechSynthesis.SpeechSynthesisReflectionUtils.InjectOneCoreVoices(SpeechSynthesizer synthesizer) in D:\a\JL\JL\JL.Windows\SpeechSynthesis\SpeechSynthesisReflectionUtils.cs:line 39
2024-04-25 15:41:52.603 +03:00 [FTL] Unhandled exception
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
   at System.Collections.ArrayList.get_Item(Int32 index)
   at System.Windows.Data.ListCollectionView.InternalItemAt(Int32 index)
   at System.Windows.Data.ListCollectionView.GetItemAt(Int32 index)
   at System.Windows.Controls.ItemCollection.get_Item(Int32 index)
   at JL.Windows.GUI.PopupWindow.GetDefinitionTextBox(Int32 listViewIndex) in D:\a\JL\JL\JL.Windows\GUI\PopupWindow.xaml.cs:line 1821
   at JL.Windows.GUI.PopupWindow.GetSelectedDefinitions(Int32 listViewIndex) in D:\a\JL\JL\JL.Windows\GUI\PopupWindow.xaml.cs:line 1826
   at JL.Windows.GUI.PopupWindow.PrimarySpelling_PreviewMouseUp(Object sender, MouseButtonEventArgs e) in D:\a\JL\JL\JL.Windows\GUI\PopupWindow.xaml.cs:line 1096
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.Run()
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at System.Windows.Application.Run()
   at JL.Windows.App.Main()
watakaiiii commented 6 months ago

I was trying to avoid closing this and did this instead I'm sorry I'm so bad with this site

rampaa commented 6 months ago

I've found the word that first produced this bug

Are you able to reproduce the crash again with that sentence while mining 情緒? If you still can reproduce it, can you share the ..\JL\Config\dict.json file? I did try to reproduce it while having JMdict, Kanjidic, JMnedict, Pixiv Light under Manage Dictionaries window (in that order) but couldn't reproduce it. If you can reliable reproduce it while mining that word, it's possible that having the exact same dictionaries loaded might be necessary to reproduce it.

watakaiiii commented 6 months ago

Yeah, I was able to reproduce it twice now (reproducing then reinstalling then reproducing again), idk if it's necessary information but I'm using x64 version of JL Here's dicts.json:

dicts.json

rampaa commented 6 months ago

Thanks. Can you please zip the "dicts" folder and send it to rampaa.01@gmail.com (giving a link here could be considered illegal, so I'd like to avoid that), so that I can test it with the exact same dictionaries?

watakaiiii commented 6 months ago

Done

rampaa commented 6 months ago

Thanks, I was able to reproduce the problem thanks to your help. The bug only seems to occur when you filter the results with a dictionary. I am assuming you were clicking on the "pixiv" button to filter the results before mining 情緒. If that's indeed the case, I've fixed the problem and it will be included in the next version of JL. In the meanwhile please avoid dictionary filtering when you intend to mine a term.