lowleveldesign / process-governor

This application allows you to put various limits on Windows processes.
MIT License
626 stars 62 forks source link

Sometimes procgov can't create a process. #64

Closed AndreyRGW closed 9 months ago

AndreyRGW commented 9 months ago

procgov cannot create a process, but after several attempts it creates it.

log from cmd:

C:\Users\RGWyo>procgov64 --cpurate=60 --minws=1M --maxws=8192M --recursive G:\1\ELDEN RING v.1.10 (2022)\Elden Ring\Game\modengine2_launcher.exe
Process Governor v2.12.2363.8 - sets limits on processes
Copyright (C) 2023 Sebastian Solnica (lowleveldesign.org)

Max CPU rate:                               60%
Minimum WS memory (MB):                     01
Maximum WS memory (MB):                     8 192

All configured limits will also apply to the child processes.

Press Ctrl-C to end execution without terminating the process.

[2024-01-26 15:32:41.518] [stderr] [error] Couldn't create process: 10dd

C:\Users\RGWyo>procgov64 --cpurate=60 --minws=1M --maxws=8192M --recursive G:\1\ELDEN RING v.1.10 (2022)\Elden Ring\Game\modengine2_launcher.exe
Process Governor v2.12.2363.8 - sets limits on processes
Copyright (C) 2023 Sebastian Solnica (lowleveldesign.org)

Max CPU rate:                               60%
Minimum WS memory (MB):                     01
Maximum WS memory (MB):                     8 192

All configured limits will also apply to the child processes.

Press Ctrl-C to end execution without terminating the process.

[2024-01-26 15:32:42.404] [stderr] [error] Couldn't create process: 10dd

C:\Users\RGWyo>procgov64 --cpurate=60 --minws=1M --maxws=8192M --recursive G:\1\ELDEN RING v.1.10 (2022)\Elden Ring\Game\modengine2_launcher.exe
Process Governor v2.12.2363.8 - sets limits on processes
Copyright (C) 2023 Sebastian Solnica (lowleveldesign.org)

Max CPU rate:                               60%
Minimum WS memory (MB):                     01
Maximum WS memory (MB):                     8 192

All configured limits will also apply to the child processes.

Press Ctrl-C to end execution without terminating the process.

[2024-01-26 15:32:43.211] [stderr] [error] Couldn't create process: 10dd

C:\Users\RGWyo>procgov64 --cpurate=60 --minws=1M --maxws=8192M --recursive G:\1\ELDEN RING v.1.10 (2022)\Elden Ring\Game\modengine2_launcher.exe
Process Governor v2.12.2363.8 - sets limits on processes
Copyright (C) 2023 Sebastian Solnica (lowleveldesign.org)

Max CPU rate:                               60%
Minimum WS memory (MB):                     01
Maximum WS memory (MB):                     8 192

All configured limits will also apply to the child processes.

Press Ctrl-C to end execution without terminating the process.

*on this attempt everything started *
AndreyRGW commented 9 months ago

Checked 2.11, procgov works perfectly on it and there are no such errors

AndreyRGW commented 9 months ago

I also noticed that "--install" stopped working on 2.12: cmd appears for a fraction of a second and closes, but the program doesn't start

lowleveldesign commented 9 months ago

There were no major changes in procgov between those versions so I have no clue why the old one might be working. Please try the debug build of procgov (attached to this comment) and provide me with the more detailed error message. I've seen issues with the minws/maxws limits in the past, so it could be that it's the Windows itself that's unstable here.

procgov64.zip

AndreyRGW commented 9 months ago

There were no major changes in procgov between those versions so I have no clue why the old one might be working. Please try the debug build of procgov (attached to this comment) and provide me with the more detailed error message. I've seen issues with the minws/maxws limits in the past, so it could be that it's the Windows itself that's unstable here.

procgov64.zip

From my observations: 1) If I run a program through the cmd, the error "[stderr] [error] Couldn't create process: 10dd" is still there and fully reproducible. 2) But "--install" now works without fail and all programs start as they should.

UPD: image

I tried to run telegram.exe in the release version using the command that is applied via "-install" and got an error:

procgov64.exe --debugger --maxws=2147483648 --minws=33554432 "C:\Users\RGWyo\AppData\Roaming\Telegram Desktop\Telegram.exe""
Process Governor v2.12.2363.8 - sets limits on processes
Copyright (C) 2023 Sebastian Solnica (lowleveldesign.org)

Minimum WS memory (MB):                     32
Maximum WS memory (MB):                     2 048

ERROR: Required null terminator missing. (Parameter 'lpCommandLine')

UPD2:

so it could be that it's the Windows itself that's unstable here

Looks like this is indeed the case, modengine2_launcher itself was unstable and the only real problem is "--install".

lowleveldesign commented 9 months ago

This error message:

[2024-01-26 15:32:43.211] [stderr] [error] Couldn't create process: 10dd

does not come from procgov, but from modengine2_launcher.exe and it is a very generic error (ERROR_INVALID_OPERATION). Without debugging this process it's hard to tell why they are reporting it. I'm afraid there is not much I can do here.

Regarding the --install option, this bug is actually fixed, but I haven't had time to make a release yet. I will do it quite soon once I fix a few more bugs. In the meantime you may build it by yourself or use the version that I attached to the previous comment. It should run properly.

AndreyRGW commented 9 months ago

This error message:

[2024-01-26 15:32:43.211] [stderr] [error] Couldn't create process: 10dd

does not come from procgov, but from modengine2_launcher.exe and it is a very generic error (ERROR_INVALID_OPERATION). Without debugging this process it's hard to tell why they are reporting it. I'm afraid there is not much I can do here.

Regarding the --install option, this bug is actually fixed, but I haven't had time to make a release yet. I will do it quite soon once I fix a few more bugs. In the meantime you may build it by yourself or use the version that I attached to the previous comment. It should run properly.

I noticed bug (on your debug version) when I tried to restrict an already running stable diffusion process (python.exe):

C:\Users\RGWyo>procgov64 --minws=1M --maxws=20480M --recursive --pid=14432
Process Governor v1.0.0.0 - sets limits on processes
Copyright (C) 2023 Sebastian Solnica (lowleveldesign.org)

Minimum WS memory (MB):                     01
Maximum WS memory (MB):                     20 480

All configured limits will also apply to the child processes.

ERROR: System.ComponentModel.Win32Exception (0x80004005): The operation completed successfully.
   at ProcessGovernor.NtApi.CheckWin32Result[T](T)
   at ProcessGovernor.NtApi.SetProcessEnvironmentVariables(Int32, Dictionary`2)
   at ProcessGovernor.ProcessModule.<AssignProcessToJobObject>g__OpenOrCreateJob|2_0(<>c__DisplayClass2_0&, <>c__DisplayClass2_1&)
   at ProcessGovernor.ProcessModule.AssignProcessToJobObject(Int32, SessionSettings)
   at ProcessGovernor.Program.Main(String[])

upd: I tried to restrict a few more programs in the same way and the result didn't change. So for me (at least for now) the most stable version is 2.11.

lowleveldesign commented 9 months ago

Sorry, that was a stupid mistake on my side. I updated the dependencies and did not fully test. Try this one please.

procgov64.zip

AndreyRGW commented 9 months ago

Sorry, that was a stupid mistake on my side. I updated the dependencies and did not fully test. Try this one please.

procgov64.zip

This version works fine, no problems with --install, and binds to already running processes without errors. Thanks!