Inspiration

Real-time bugs are the ones you can't reproduce. A robot arm misses its 1 ms deadline twice a minute, the bug disappears when you add logging, and the evidence is buried in a kernel trace of 100,000+ events from 150 threads. QNX gives you the perfect instrument for this: tracelogger and the Momentics System Profiler record everything. But you still have to know what pattern to look for, and find it by hand.

We wanted the first pass to be automatic: point a tool at a trace and have it find the root cause. For example: "this semaphore, held by this thread, preempted by that one, made your control loop late; here are the event numbers, and here is the fix." Then it proves the fix with a second trace.

What it does

KEVIN reads QNX 8.0 kernel event traces and finds the root cause of the real-time bugs that are hardest to reproduce:

  • Priority inversions, including the ones QNX can't fix for you (semaphores have no owner, so there is no priority inheritance). Healthy inheritance is reported as info, not as a bug.
  • QNX message-passing deadlocks: two servers that MsgSend() to each other, SEND- and REPLY-blocked forever. A bug that only exists on a microkernel.
  • Lock deadlocks, decoding QNX's mutex owner word so the cycle is observed, not guessed.
  • Missed deadlines, jitter and skipped periods, naming the thread that took the CPU.
  • Slow IPC, starvation and interrupt latency (QNX 8.0 interrupt service threads).

For every finding it gives:

  • a plain-English explanation in which every claim cites trace event numbers;
  • a swimlane timeline zoomed to the problem;
  • an IPC map with the deadlock cycle drawn in red;
  • a C fix snippet.

Then:

  • kevin diff before after proves a fix. On the real robot-arm captures, the worst response went from 8,141 µs to 516 µs, and deadline misses from 23 to 0: FIX VERIFIED.
  • kevin whatif --set telemetry.prio=8 replays the recorded CPU demand with new priorities before you rebuild.
    • It is labelled a simulation, and it first checks that an unchanged replay reproduces the bug.
    • On the real trace, lowering telemetry alone only cut the inversion from 8 occurrences to 2, because a second thread also preempts the lock holder. Priority tweaks move the problem; inheritance fixes it.
  • kevin check --fail-on high gates CI with exit codes, JUnit XML and a GitHub job summary.
  • kevin live streams a running target's kernel events and reports the bug while it happens.
  • kevin ask "why was control_loop late?" answers questions, citing only events it was shown.

Detectors decide, the LLM only explains. Every finding comes from deterministic code. Claude or Gemini (optional) rewrites the explanation, and a validator rejects any text that cites an event or thread that isn't in the finding's evidence; KEVIN then falls back to its built-in template. Everything works offline without an API key.

How we built it

KEVIN is a new project, built from scratch during the hackathon.

On the QNX 8.0 target (C11, qcc):

  • kevin-export, built on QNX's libtraceparser, converts .kev traces to JSON lines. It decodes:
    • thread states with priorities;
    • kernel-call arguments (64-bit sync addresses, mutex owner words, connection ids);
    • message passing (the COMM class);
    • interrupts and names.
  • armctl, a small robot-arm controller: sensor reader, 1 ms control loop, motor server, safety monitor, telemetry and logger. Its --bug inversion|msg-deadlock|slow-ipc|jitter and --fixed flags let one binary give both the before and the after trace.
  • A bug zoo: one tiny program per bug, with ground-truth labels.
  • capture.sh and live.sh, wrappers around tracelogger.

On the host (pure Python, runs on macOS): a pipeline from events to per-thread state timelines, a time-varying wait-for graph and message transactions. Deterministic detectors run on those, followed by explanations and the reports: terminal, JSON, and one self-contained HTML file.

A QNX lab on a Mac. The QNX 8.0 host tools run on Linux, so target/vm/qnx.sh:

  • runs QNX Software Center and qcc in an x86_64 Linux container (colima + Rosetta);
  • builds a QEMU aarch64 image with mkqnximage;
  • boots QNX 8.0 on the Mac in about a minute.

Calibrated on real traces. Every detector was written first against a scheduler simulator, then corrected against real QNX 8.0 captures. That is where most of the learning happened.

Challenges we ran into

The first real trace corrected KEVIN in more than a dozen places. A few:

  • The trace format. Kernel-call entries and exits arrive through one callback; the event code tells them apart (bit 0x80 = exit, 0x200 = 64-bit arguments). libtraceparser can't read a pipe, so live mode records one-second slices and marks the unrecorded gaps between them as unknown.
  • QNX 8.0 has no ISRs. Interrupts are delivered to service threads (one INT_DELIVER event), so KEVIN learns from the trace itself which thread serves which IRQ.
  • Things that look impossible but aren't.
    • QNX re-logs a running thread.
    • It logs a preempted thread's READY a few µs after its preemptor runs.
    • Its idle threads never log READY.
    • KEVIN first flagged 40–58 "impossible" stretches per trace. After calibration it flags 7–17, and no finding changed.
  • Who owns a lock? Uncontended QNX mutex locks never enter the kernel. The only owner information is the __owner word in the contending SyncMutexLock: ((pid & 0x7fff) << 16) | tid.
  • QEMU's timer. It rounded sub-millisecond offsets to the same tick, so the bugs never happened. The test programs now trigger their bugs by handshake.
  • Multicore honesty. On a 4-CPU run, KEVIN first reported an inversion while one CPU sat idle. Now it only counts the time when every CPU the low-priority thread may use is busy with higher-priority work.

Accomplishments that we're proud of

  • 17 real QNX 8.0 captures: 14 of 14 expected bugs found, with 0 false positives and 0 missed.
    • Priority inversion: 2
    • QNX message-passing deadlock: 2
    • Lock deadlock: 1
    • Missed deadline / skipped periods: 4
    • Jitter: 1
    • Slow IPC: 2
    • Starvation: 1
    • Interrupt latency: 1
    • The clean runs report no bugs: a fixed controller, a healthy inheritance mutex, an interrupt thread at the right priority, and two unpinned 4-CPU runs.
    • Caveats: 17 traces is a small set, and we wrote every scenario.
  • The fix is proven, not claimed: 8,141 µs → 516 µs and 23 → 0 deadline misses, measured on two real captures.
  • A general LLM is not enough. We gave gemini-3.8-flash the raw trace window around each bug, the best case for it. It found 8 of 13 bugs and raised 3 false alarms; KEVIN found 13 of 13 with none. The LLM is good at explaining, so that's the only job KEVIN gives it.
  • It degrades honestly. With events dropped at random, precision stays at 0.96 at 1% loss and 0.84 at 5%. Impossible state sequences become "unknown", never guesses.
  • A codelab a stranger can follow: build, capture, analyse, try a fix, prove it, gate CI. A test runs every command in it.
  • 167 tests, all offline; 1M events are analysed in about 3 s on a laptop.

What we learned

  • A real trace is the only specification that matters. A microkernel's event stream has rules the documentation doesn't spell out, and each one first showed up as a false positive.
  • "Detectors decide, the LLM explains" is the right split for debugging tools. The model is good at turning evidence into an explanation, and a validator stops it from inventing evidence.
  • Honest uncertainty is a feature. Marking what's inferred, refusing to make claims across lost events, and labelling simulations "approximate" made the tool more trustworthy, not less useful.

What's next

  • Run on physical hardware (a Raspberry Pi with QNX 8.0) and on larger real systems.
  • A VS Code panel next to the QNX Toolkit: click a finding to jump to the timeline.
  • kev2json: the exporter as a standalone open-source tool.
  • More detectors: sporadic-server budget overruns, adaptive-partitioning starvation, and IPC priority floating across chains of servers.

Built With

  • c
  • docker-(colima)
  • libtraceparser
  • mkqnximage
  • python
  • qemu
  • qnx-8.0
  • qnx-software-center
  • tracelogger
Share this project:

Updates

Submission history