Skip to content

Explain why the sandbox stopped when its process is killed - #51

Merged
eliotwrobson merged 1 commit into
mainfrom
claude/killed-sandbox-message
Nov 18, 2026
Merged

eliotwrobson merged 1 commit into
mainfrom
claude/killed-sandbox-message

Conversation

@eliotwrobson

Copy link
Copy Markdown
Collaborator

When student code used too much memory, the container's memory limit killed the sandbox process, and the student saw "Connection closed by peer before termination character was found." This was reported against the legacy grader in PrairieLearn issue 5083, and it applies here too.

Now, when the sandbox closes the connection, the grader waits up to a second for its process to exit and says why it stopped:

  • Killed with SIGKILL, which is what memory limits do: "The sandbox running your code was killed, probably because your code used too much memory."
  • Another exit: "The sandbox running your code stopped unexpectedly with exit code 3."

Later queries on the same sandbox, such as with module_sandbox, get the same message.

If the memory limit kills the grader's own pytest process instead, there's still no results file, and PrairieLearn shows its generic message. In my runs, the sandbox was killed every time, because it's the process using the memory.

Testing

In the grader image with docker run --memory=300m, student code that keeps allocating memory got the new message in 3 of 3 runs.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@eliotwrobson
eliotwrobson marked this pull request as ready for review November 18, 2026 21:02
@eliotwrobson
eliotwrobson merged commit 63d632b into main Nov 18, 2026
5 checks passed
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.

1 participant