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

implement parent monitoring thread #8

Merged
merged 4 commits into from
Nov 1, 2024
Merged

Conversation

karmacoma-eth
Copy link
Collaborator

fixes #7

@karmacoma-eth
Copy link
Collaborator Author

tested with:

# quickexit.py

import subprocess
import sys

proc = subprocess.Popen(
    ["rye", "run", "jsi", "--full-run", "--debug", "examples/unsat_div.smt2"]
)

print(f"started {proc.pid=}")
sys.exit(42)

@karmacoma-eth
Copy link
Collaborator Author

does not work as intended with halmos, and can repro the problem with the following snippet:

import subprocess
import sys
import time

timeout = int(sys.argv[1]) if len(sys.argv) > 1 else 5

try:
    cmd = ["jsi", "--full-run", "--debug", "examples/unsat_div.smt2"]
    output = subprocess.run(
        cmd, capture_output=False, text=True, timeout=timeout
    ).stdout.strip()
except KeyboardInterrupt:
    print("quickexit: caught KeyboardInterrupt")
    time.sleep(timeout)

sys.exit(42)

it is possible to get to quickexit: caught KeyboardInterrupt, but parent process died, exiting... is never printed by jsi and the solvers keep running 🤨

@karmacoma-eth
Copy link
Collaborator Author

does not work as intended with halmos, and can repro the problem with the following snippet:

import subprocess
import sys
import time

timeout = int(sys.argv[1]) if len(sys.argv) > 1 else 5

try:
    cmd = ["jsi", "--full-run", "--debug", "examples/unsat_div.smt2"]
    output = subprocess.run(
        cmd, capture_output=False, text=True, timeout=timeout
    ).stdout.strip()
except KeyboardInterrupt:
    print("quickexit: caught KeyboardInterrupt")
    time.sleep(timeout)

sys.exit(42)

it is possible to get to quickexit: caught KeyboardInterrupt, but parent process died, exiting... is never printed by jsi and the solvers keep running 🤨

that is because subprocess.run wraps communicate with an exception handler that can call process.kill() (SIGKILL, not SIGTERM), which kills the jsi process (and its parent monitor thread) but not the solvers. Out of scope for the thread -- this is something the reaper should be able to deal with.

Halmos should also be changed to avoid sending SIGKILL to jsi

@karmacoma-eth karmacoma-eth merged commit 0dc81ba into main Nov 1, 2024
8 checks passed
@karmacoma-eth karmacoma-eth deleted the fix-parent-monitor branch November 1, 2024 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

jsi keeps running after invoker exits
1 participant