HIL: Ctrl-C terminates the board worker before its lock task logs the failure

Open
#4,500 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python, raspberry-pi

Research direction

Start with test/hil/hil_test.py and trace main(), drain_pool, pool shutdown, and _abort_report to see how KeyboardInterrupt is handled. Check the board task's lock and failure logging path, then reproduce the Ctrl-C case on hardware. Done means the run writes an abort report, logs a failed event with its receipts, and leaves no stale lock record.

Written by the indexing model from the issue text.

Description

follow-up Prio 📌

A Ctrl-C on test/hil/hil_test.py leaves the board's lock record stale instead of ending its task as failed. The
run also writes no report.

Evidence

  • ci.lan, raspberry_pi_pico, #4499's branch with agentrc 48d46bbf. SIGINT went to the run's process group after 4
    tests:
    • The run exited 130 with no report.
    • The lock record stayed stale (cleanupOwed: true, the board worker's pid), and no failed event was logged.
    • All 14 idle pool workers printed KeyboardInterrupt tracebacks. The board worker printed nothing.
  • The next run on the board reported it as previous-cleanup-failure (found-left). Its park logged restored for
    it, so recovery works; only the interrupted run's own record of the failure is lost.

Cause

This is read from the source and is not yet confirmed by a trace:

  • Main's KeyboardInterrupt in drain_pool is not caught by except Exception in main().
  • Leaving with pool: therefore calls Pool.terminate(), which sends SIGTERM to every worker.
  • The board worker has no SIGTERM handler, so it dies before its board_task can end the task and log the failure.
  • _abort_report is skipped for the same reason, which is why there is no report.

Remaining work

  • On KeyboardInterrupt in main(), let in-flight workers end their board task (bounded join, or close() +
    join(timeout)) before terminate(). Write the abort report as the other abort paths do.
  • Confirm on hardware that a Ctrl-C then logs a failed event with the run's receipts and leaves no stale record.

Deferred: the pool shutdown predates #4499 and the recovery path covers it.

Dominant language
C
Stars
7.3k
Forks
1.6k
Avg merge
1d 19h
Merged PRs (30d)
67

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from hathach/tinyusb

All issues in hathach/tinyusb

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.