DRMacIver / shrinkray

Shrinkray is a modern multi-format test-case reducer
MIT License
85 stars 2 forks source link

getting "Could not kill subprocess with pid {sp.pid}. Something has gone seriously wrong.", logic bug? #6

Closed cfbolz closed 1 month ago

cfbolz commented 3 months ago

Hi David!

I'm shrinking input to Z3 that I feed it via a Python script. Z3 ignores SIGINT and continues, so when shrinkray tries to kill a process it really needs to use SIGKILL. However, I'm getting "Could not kill subprocess...", isn't the logic in interrupt_wait_and_kill simply wrong?:

async def interrupt_wait_and_kill(sp: "trio.Process", delay: float = 0.1) -> None:
        ... # try to kill with SIGINT

        if sp.returncode is None:
            signal_group(sp, signal.SIGKILL)

        with trio.move_on_after(delay):
            await sp.wait()

        if sp.returncode is not None:
            raise ValueError(
                f"Could not kill subprocess with pid {sp.pid}. Something has gone seriously wrong."
            )

I think the last if should be if sp.returncode is None:, right?

I'm happy to open a PR if you tell me whether you also want a test for this situation, or whether you'd be happy simply with the fix.

Apart from that shrinkray is working great for my problem!

DRMacIver commented 1 month ago

Whoops, sorry, I somehow missed this report.

Yes I think you're quite correct and this logic is straightforwardly wrong. Sorry about that! I'd love a pull request, but if not I'll get around to it at some point soonish.