Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subrocesses not being killed #691

Open
jsongerber opened this issue Oct 25, 2024 · 3 comments
Open

Subrocesses not being killed #691

jsongerber opened this issue Oct 25, 2024 · 3 comments

Comments

@jsongerber
Copy link
Contributor

I'm using PHPStan to lint PHP code.

My understanding is that each save should trigger an analyze command, and if a previous process is still running, it should terminate before a new one starts.

When checking the running processes via require('lint').get_running(), it only shows a single process, which seems correct. However, it appears that multiple processes are being spawned:
380215159-980e9af7-4ca9-4baf-8d7f-dc94eca1b925

As you can see, only one command is phpstan analyze, others are subprocesses that seems to be orphans, and keep hanging for long minutes, and can take a lot of memory, affecting performance.
This behavior seems similar to issue #521, so I’m wondering if this might be a regression.

Please tell me if you need any more information.

@lukoshkin
Copy link

I experience the same with shellcheck and flake8
I think it's major bug that must be fixed sooner
I can't mend the throttling anyhow but rebooting the laptop which is annoying

@mfussenegger
Copy link
Owner

This behavior seems similar to #521, so I’m wondering if this might be a regression.

There are test cases for the cancellation:

it("get_running returns running linter", function()
local linter = {
name = "dummy",
cmd = "python",
args = {"tests/loop.py"},
parser = require("lint.parser").from_errorformat("%f:%l: %m")
}
lint.linters.dummy = linter
local orig_lint = lint.lint
---@type lint.LintProc
local captured_proc
---@diagnostic disable-next-line: duplicate-set-field
lint.lint = function(...)
captured_proc = assert(orig_lint(...))
return captured_proc
end
lint.try_lint("dummy")
assert.are.same({"dummy"}, lint.get_running())
assert(captured_proc)
captured_proc:cancel()
vim.wait(500, function() return #lint.get_running() == 0 end)
assert.are.same({}, lint.get_running())
assert.is_false(captured_proc.handle:is_active())
end)

So I'm fairly sure it didn't regress.

Could you check if you can terminate the orphan phpstan processes using kill ? nvim-lint first sends a sigint signal and if that doesn't work for ~10 seconds it sends a sigkill

@jsongerber
Copy link
Contributor Author

Thank you for your response and for taking time to investigate.

At the time of creating this issue I had 8gb of ram, I since bought more and the issue seems to have disappear (or is less visible).

I tried to reproduce but the processes are now finishing too quick to be able to kill orphan ones (there are still orphans but they seem to not last long, and I don't know if they die by themselves or are killed by the plugin).

When I have time this week I'll try to edit phpstan to add sleep functions to simulate longer processes, but I don't know if it will work.

Maybe @lukoshkin can help if he can reproduce the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants