ChocolateyGUI icon indicating copy to clipboard operation
ChocolateyGUI copied to clipboard

Chocolatey GUI fails to launch when data.db is corrupted

Open corbob opened this issue 3 years ago • 3 comments

When %appdata%\Local\Chocolatey Gui\data.db is corrupted, Chocolatey GUI will fail to launch with no apparent output.

When you look in the Event viewer, you will see an error from .NET Runtime with ID 1026 that will look something like the below.

2021-12-02_13-27-04

The contents of the event:

Application: ChocolateyGui.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ArgumentNullException
   at Autofac.ResolutionExtensions.ResolveService(Autofac.IComponentContext, Autofac.Core.Service, System.Collections.Generic.IEnumerable`1<Autofac.Core.Parameter>)
   at Autofac.ResolutionExtensions.Resolve[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](Autofac.IComponentContext, System.Collections.Generic.IEnumerable`1<Autofac.Core.Parameter>)
   at ChocolateyGui.App.Main(System.String[])

This looks to be similar, but not quite the same as #864. Of interest is that this crash appears to happen prior to anything being written to the Chocolatey GUI Log.

Note: To get a corrupted file, you can delete the one that's there and then create an empty file with the name data.db.

Workaround

The %appdata%\Local\Chocolatey Gui\data.db file can be renamed, removed, or deleted to work around this issue.

corbob avatar Dec 03 '21 01:12 corbob

@corbob were there any steps to reproduce this problem, or how did you come to the conclusion that is was an issue with the data.db file? Do we have an example of a corrupted data.db file?

gep13 avatar Dec 04 '21 07:12 gep13

Oh, it looks like I typed some stuff up then took it out... How I originally got a corrupted file for myself was to open the file in vscode (and tell vscode to in fact open it), I then removed a dozen or so bytes at the beginning, and saved it back. Then Chocolatey GUI wouldn't open anymore. I later reproduced it by creating a 0-byte file names data.db. Ultimately this came out of a Zendesk Ticket. I suspect we could go back to the customer and see if they still have the corrupted data.db file for further investigation.

corbob avatar Dec 04 '21 20:12 corbob

So I've done some investigating into this, but I'm having some issues trying to debug. Below are my notes about what I think the issues are:

If the user's data.db file is corrupted in some way or empty, ChocolateyGuiModule.cs Line 115 will throw an exception of type LiteException.

While if the global data.db file is corrupted or empty, ChocolateyGuiModule.cs Line 120 will throw the same exception.

Unfortunately it doesn't look like we can continue with the user DB corrupted, but the global can continue as though it was non-administrator and get some default settings. I have a naive workaround (no PR yet because this is just me poking at it and seeing what's what).

corbob avatar Dec 05 '21 02:12 corbob