jellyfin-archive / jellyfin-plugin-anime

Anime Metadata Provider for Jellyfin
https://jellyfin.org
GNU General Public License v2.0
58 stars 24 forks source link

scan crashing with AccessViolation in `System.Text.RegularExpressions.RegexInterpreter` #60

Open hauntingEcho opened 4 years ago

hauntingEcho commented 4 years ago

Running the 10.5.2-arm docker image with Anime plugin 7.0.0, using AniList causes crashes whenever a library is scanned, giving the logs below. Disabling AniList seems to solve the issue.

[22:03:20] [INF] [42] Jellyfin.Plugin.Anime.Providers.AniList.AniListSeriesProvider: Start AniList... Searching(Black Rock Shooter)
Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at System.Text.RegularExpressions.RegexInterpreter.Forwardcharnext()
   at System.Text.RegularExpressions.RegexInterpreter.Go()
   at System.Text.RegularExpressions.RegexRunner.Scan(System.Text.RegularExpressions.Regex, System.String, Int32, Int32, Int32, Int32, Boolean, System.TimeSpan)
   at System.Text.RegularExpressions.Regex.Run(Boolean, Int32, System.String, Int32, Int32, Int32)
   at System.Text.RegularExpressions.MatchCollection.GetMatch(Int32)
   at System.Text.RegularExpressions.MatchCollection+Enumerator.MoveNext()
   at Jellyfin.Plugin.Anime.Providers.Equals_check+<One_line_regex>d__6.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Jellyfin.Plugin.Anime.Providers.Equals_check+<One_line_regex>d__6, Jellyfin.Plugin.Anime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null]](<One_line_regex>d__6 ByRef)
   at Jellyfin.Plugin.Anime.Providers.Equals_check.One_line_regex(System.Text.RegularExpressions.Regex, System.String, System.Threading.CancellationToken, Int32, Int32)
   at Jellyfin.Plugin.Anime.Providers.Equals_check+<Fast_xml_search>d__7.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.Boolean, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Jellyfin.Plugin.Anime.Providers.Equals_check+<Fast_xml_search>d__7, Jellyfin.Plugin.Anime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null]].ExecutionContextCallback(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.Boolean, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Jellyfin.Plugin.Anime.Providers.Equals_check+<Fast_xml_search>d__7, Jellyfin.Plugin.Anime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext(System.Threading.Thread)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.Boolean, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Jellyfin.Plugin.Anime.Providers.Equals_check+<Fast_xml_search>d__7, Jellyfin.Plugin.Anime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
   at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction(System.Runtime.CompilerServices.IAsyncStateMachineBox, Boolean)
   at System.Threading.Tasks.Task.RunContinuations(System.Object)
   at System.Threading.Tasks.Task.FinishContinuations()
   at System.Threading.Tasks.Task`1[[System.__Canon, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].TrySetResult(System.__Canon)
   at Jellyfin.Plugin.Anime.Providers.Equals_check+<Half_string>d__5.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.__Canon, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Jellyfin.Plugin.Anime.Providers.Equals_check+<Half_string>d__5, Jellyfin.Plugin.Anime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null]].ExecutionContextCallback(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.__Canon, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Jellyfin.Plugin.Anime.Providers.Equals_check+<Half_string>d__5, Jellyfin.Plugin.Anime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext(System.Threading.Thread)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.__Canon, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Jellyfin.Plugin.Anime.Providers.Equals_check+<Half_string>d__5, Jellyfin.Plugin.Anime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
   at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction(System.Runtime.CompilerServices.IAsyncStateMachineBox, Boolean)
   at System.Threading.Tasks.Task.RunContinuations(System.Object)
   at System.Threading.Tasks.Task.FinishContinuations()
   at System.Threading.Tasks.Task.FinishStageThree()
   at System.Threading.Tasks.Task.FinishStageTwo()
   at System.Threading.Tasks.Task.FinishSlow(Boolean)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef, System.Threading.Thread)
   at System.Threading.Tasks.Task.ExecuteEntryUnsafe(System.Threading.Thread)
   at System.Threading.Tasks.Task.ExecuteFromThreadPool(System.Threading.Thread)
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
[22:03:53] [INF] [1] Main: Jellyfin version: 10.5.2
hauntingEcho commented 4 years ago

after letting it run awhile, it looks like I'm getting this issue from RegExes elsewhere too. For what it's worth, other series with spaces in their names worked fine.

[22:53:11] [INF] [19] AniSearch: Start AniSearch... Searching(Koe no Katachi)
Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at System.Text.RegularExpressions.RegexInterpreter.Go()
   at System.Text.RegularExpressions.RegexRunner.Scan(System.Text.RegularExpressions.Regex, System.String, Int32, Int32, Int32, Int32, Boolean, System.TimeSpan)
   at System.Text.RegularExpressions.Regex.Run(Boolean, Int32, System.String, Int32, Int32, Int32)
   at System.Text.RegularExpressions.MatchCollection.GetMatch(Int32)
   at System.Text.RegularExpressions.MatchCollection+Enumerator.MoveNext()
   at Jellyfin.Plugin.Anime.Providers.Equals_check+<One_line_regex>d__6.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Jellyfin.Plugin.Anime.Providers.Equals_check+<One_line_regex>d__6, Jellyfin.Plugin.Anime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null]](<One_line_regex>d__6 ByRef)
   at Jellyfin.Plugin.Anime.Providers.Equals_check.One_line_regex(System.Text.RegularExpressions.Regex, System.String, System.Threading.CancellationToken, Int32, Int32)
   at Jellyfin.Plugin.Anime.Providers.Equals_check+<Fast_xml_search>d__7.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.Boolean, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Jellyfin.Plugin.Anime.Providers.Equals_check+<Fast_xml_search>d__7, Jellyfin.Plugin.Anime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null]].ExecutionContextCallback(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.Boolean, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Jellyfin.Plugin.Anime.Providers.Equals_check+<Fast_xml_search>d__7, Jellyfin.Plugin.Anime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext(System.Threading.Thread)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.Boolean, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Jellyfin.Plugin.Anime.Providers.Equals_check+<Fast_xml_search>d__7, Jellyfin.Plugin.Anime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
   at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction(System.Runtime.CompilerServices.IAsyncStateMachineBox, Boolean)
   at System.Threading.Tasks.Task.RunContinuations(System.Object)
   at System.Threading.Tasks.Task.FinishContinuations()
   at System.Threading.Tasks.Task`1[[System.__Canon, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].TrySetResult(System.__Canon)
   at Jellyfin.Plugin.Anime.Providers.Equals_check+<Half_string>d__5.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.__Canon, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Jellyfin.Plugin.Anime.Providers.Equals_check+<Half_string>d__5, Jellyfin.Plugin.Anime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null]].ExecutionContextCallback(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.__Canon, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Jellyfin.Plugin.Anime.Providers.Equals_check+<Half_string>d__5, Jellyfin.Plugin.Anime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext(System.Threading.Thread)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.__Canon, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Jellyfin.Plugin.Anime.Providers.Equals_check+<Half_string>d__5, Jellyfin.Plugin.Anime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
   at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction(System.Runtime.CompilerServices.IAsyncStateMachineBox, Boolean)
   at System.Threading.Tasks.Task.RunContinuations(System.Object)
   at System.Threading.Tasks.Task.FinishContinuations()
   at System.Threading.Tasks.Task.FinishStageThree()
   at System.Threading.Tasks.Task.FinishStageTwo()
   at System.Threading.Tasks.Task.FinishSlow(Boolean)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef, System.Threading.Thread)
   at System.Threading.Tasks.Task.ExecuteEntryUnsafe(System.Threading.Thread)
   at System.Threading.Tasks.Task.ExecuteFromThreadPool(System.Threading.Thread)
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
hauntingEcho commented 4 years ago

For what it's worth, my logs are also getting spammed hard from https://github.com/jellyfin/jellyfin/issues/2471 - hopefully that turns out to be the root cause of the issue, since I'm also getting crashes without the above error

hauntingEcho commented 4 years ago

reverting to 10.4.3 with plugin v4 seems to have worked as a temporary resolution. It feels like a use-after-free issue, but I'm not familiar enough with C# diagnostics to be able to track that down.