Skip to content

pjullrich/peterandcode

Back Add unsafe binary mutation demo showing shared-reference dangers

Commit details

Add unsafe binary mutation demo showing shared-reference dangers

Description

Standalone script (bench/unsafe_demo.exs) demonstrating why in-place NIF mutation of a refc binary is dangerous: 1. Two variables pointing to the same binary — both see the mutation 2. Sub-binary corruption — a slice into the original sees new values 3. Cross-process mutation — another process's copy changes silently 4. The safe alternative — :binary.copy/1 isolates the mutation Run with: mix run bench/unsafe_demo.exs https://claude.ai/code/session_011hHr17m5LkPkM75FU47Hxj

Metadata

Author
Claude noreply@anthropic.com
Committed
Commit

Contributors

  • Claude noreply@anthropic.com Author