8000 Errors inside spawned processes are swallowed and misreported as "deadlock: no process is runnable" · Issue #174 · kexhq/kex · GitHub
[go: up one dir, main page]

Skip to content

Errors inside spawned processes are swallowed and misreported as "deadlock: no process is runnable" #174

Closed

Description

@akoskovacs

A runtime error inside a spawned process is swallowed. The process dies, and the program reports the consequence — no runnable process — instead of the cause, with no location.

The same expression, in the main process and inside a spawn:

# die1.kex — main process
main do
  IO.printLine([1].append(2))
end
Internal error: die1.kex:2:26: runtime error: Undefined method: append for [Int]
# die2.kex — inside spawn
type Msg = | Ping(Process)
main do
  let p = spawn do
    receive do
      Ping(who) => who.send([1].append(2))
    end
  end
  p.send(Ping(Process.self))
  receive do
    r => IO.printLine("got ${r}")
  end
end
Internal error: :0:0: runtime error: deadlock: no process is runnable

Same defect, same line of code. In one case the message names the method, the receiver type, and the source location; in the other it names none of them and misattributes the failure to the scheduler. :0:0 is not a real location.

"Deadlock" is also the wrong diagnosis. Nothing deadlocked — a process crashed, and the parent then blocked forever in receive on a reply that could never come. The scheduler is reporting the second-order effect.

Why this is worth fixing beyond the message

This is how every bug inside a spawned process presents, so any process-based code is debugged with no cause and no line number. It cost me a while to find in a hand-written spec fake; the same shape appears in any receive loop.

It also gets worse under the capability/mocking design in #143: state-carrying test fakes have to be backed by processes (no global mutable state), so ordinary mistakes in test doubles will land in spawned processes by construction, and will surface as deadlock: no process is runnable.

Suggested direction

The crashing process should report its own error — method, receiver, and source location, as the main process already does — and the parent's subsequent block should either name the dead process or, at minimum, not be reported as a deadlock.

Backend note

Confirmed on the walker (interpreter). On BEAM (-R) the same program hangs rather than terminating; I did not confirm whether the underlying cause is the same, so that half needs checking before the fix is scoped.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't workingConfirmed IssueBug is reproduced on the current development versionIn ProgressActively being worked onProcesses

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0