gerardog / gsudo

Sudo for Windows
https://gerardog.github.io/gsudo
MIT License
5.07k stars 136 forks source link

Issue: System.NullReferenceException thrown at gsudo start #318

Closed kintrupf closed 5 months ago

kintrupf commented 8 months ago

When starting gsudo.exe i get this exception:

Error: System.NullReferenceException: Object reference not set to an instance of an object.
   at gsudo.Commands.RunCommand.<RunUsingService>d__8.MoveNext() + 0x43e
--- End of stack trace from previous location ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x20
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xb6
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x42
   at gsudo.Commands.RunCommand.<Execute>d__6.MoveNext() + 0x362
--- End of stack trace from previous location ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x20
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xb6
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x42
   at gsudo.Program.<Start>d__1.MoveNext() + 0x1d3

It takes a few seconds for this message to appear in the console window after the credentials were entered in the UAC prompt. Obviously, no elevated shell is started. I have a separate user with admin privileges. On another system where I use gsudo with the same user/admin user configuration all works fine.

gsudo version is 2.4.0. This is the output from gsudo --debug:

Running as:
  User: ****
  Sid: S-1-5-21-3410838153-3907952226-3576459003-165127
  Is Admin: True
  Integrity Level: High (12288)

Credentials Cache:
  Mode: Auto
  Available for this process: False
  Total active cache sessions: 0

Processes attached to the current console:
      PID      PPID Integrity  UserName                  Name
    23880      6780 High       ******          C:\ProgramData\chocolatey\lib\gsudo\v2.4.0\gsudo.exe (this gsudo status)

Info: Service started
Debug: Service will shutdown if idle for 60.00:00:00
Error: System.ArgumentOutOfRangeException: Number must be either non-negative and less than or equal to Int32.MaxValue or -1. (Parameter 'dueTime')
   at System.Threading.Timer.Change(Int32, Int32) + 0x5f
   at gsudo.Commands.ServiceCommand.EnableTimer() + 0x4d
   at gsudo.Commands.ServiceCommand.<Execute>d__25.MoveNext() + 0x45f
--- End of stack trace from previous location ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x20
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xb6
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x42
   at gsudo.Program.<Start>d__1.MoveNext() + 0x1d3
Service shutdown. This window will close in 15 seconds
gerardog commented 8 months ago

You have identified a bug in the CacheDuration config setting. You have set a cache duration greater than 24 days, which triggers this bug.

You can reset the cache duration to 30 minutes or you can set it to Infinite to avoid triggering the bug.

Please open a CMD or Powershell console as administrator (the old way, right click, run as administrator) then run:

Then please do not close this ticket as this bug root cause is still not resolved.

Thank you for reporting!