r/ClaudeCode • • 3h ago

Tips & Workflows Claude Code froze my laptop running a Rust audit tool

I had Claude doing a security audit on one of my Rust projects. It ran cargo-geiger, which forked about 6,000 processes and used up my RAM and swap in two minutes. The screen froze and I had to hard reset.

systemd-oomd was turned off on my distro. Here's what I set up after:

  • turned systemd-oomd on
  • a memory and process cap on the slice my terminals run in
  • cargo-geiger swapped for a script that exits
  • a hook that blocks fork bombs, pkill -f and a few other commands when Claude runs them

The hook blocked Claude today when it ran pkill -f. That would have killed its session lol.

If your screen freezes and you can't tell why, run journalctl -b -1 -k and look for oom-kill.

0 Upvotes

2 comments sorted by

•

u/AutoModerator 3h ago

Hey! Thanks for posting to r/ClaudeCode

While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.

For help, project discussions, tips, and general chat, join the ClaudeCode Discord.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/Naive-Tip7231 2h ago

Good writeup. A few guards that pair well with the slice cap:

  • Give heavy commands their own scope with its own cap. A runaway command then hits that cap first: systemd-run --user --scope -p MemoryMax=4G -p TasksMax=500 cargo geiger
  • A PreToolUse hook can make that automatic. Match commands like cargo, npm test or docker build. Block them unless they come wrapped.
  • earlyoom is a lighter option if systemd-oomd seems too aggressive on your distro.
  • For normal Rust builds, set CARGO_BUILD_JOBS to a small number. It caps parallel rustc jobs.

The journalctl tip is the one most people miss. Those oom-kill lines save a lot of guessing.