🪐 craturn
A Rust interpretation of the “Saturn Devouring His Son” painting.
craturn is a joke global allocator that slowly, subtly, and nondeterministically eats
allocated memory, resulting in corrupted program state over time, while remaining fully
valid Rust code.
It is inspired by Francisco Goya’s Saturn Devouring His Son.
Except Saturn here is your program, and the son is its own heap.
The allocator behaves normally at first.
Then it starts to eat.
Sometimes nothing happens.
Sometimes bits disappear.
Sometimes values decay.
Sometimes the program hangs.
Sometimes everything is fine ... until it isn’t.
⚠️ Disclaimer
This crate is intentionally unsafe, intentionally incorrect, and intentionally evil.
- Do not use in production.
- Do not use in benchmarks you care about.
- Do not file bugs saying “it broke my program”.
This crate exists for:
- jokes,
- demos,
- chaos testing,
- explaining why memory safety matters,
- terrifying coworkers.
You have been warned.
🧭 What craturn Does
Once awakened, craturn installs a custom global allocator that:
- Allocates memory exactly like the system allocator.
- Tracks long-lived heap allocations.
- Spawns a single background “eater” thread.
- Occasionally eats bits inside live heap objects.
- Replaces eaten bits with zeros.
- Scales its appetite based on a configurable hunger level.
Crucially:
- There are no panics.
- There are no explicit crashes.
- Everything compiles cleanly.
- The damage appears later, elsewhere, and without context.
In other words:
your program is being consumed from the inside.
🍖 Hunger Levels
Hunger controls how often and how much memory is eaten.
Higher hunger:
- Eats memory more frequently.
- Removes more bits per bite.
- Converges faster to visible failure.
Lower hunger:
- May take seconds, minutes, or never.
- Is ideal for subtle, deniable breakage.
🛠️ Usage
Add craturn as a dependency, then awaken it.
awaken!; // Defaults to `Hungry`.
// or
awaken!; // Explicit hunger.
That’s it. No function calls. No runtime handles. No opt-out. Once awakened, Craturn starts eating.
🧪 Example
use thread;
use ;
awaken!;
Possible outcomes
- Values slowly change in random places (some digits, chars, len, etc.).
- Collections lose elements.
- Program hangs due to eaten state.
- Everything appears fine, for now.
All outcomes are correct.
🧙 Macro Details
The allocator is installed via a macro to keep activation non-obvious:
#
Once expanded, the allocator is global and permanent for the binary.
There is no “stop eating” macro.
🧠 Design Notes
- No locks in allocation paths.
- No heap allocation inside allocator hooks.
- One background eater thread.
- Dense tracking of live allocations.
- Long-lived memory is eaten preferentially.
- Bites are small and localized by default.
This keeps the behavior:
- delayed,
- nondeterministic,
- extremely difficult to trace.
Just like real memory bugs.
🪐 Philosophy
Saturn does not crash. Saturn does not panic. Saturn simply eats his son.
craturn does the same.
📜 License
MIT OR Apache-2.0
Choose whichever lets you sleep at night.