Skip to content

🐛 Replace runtime-dependent memory admission in makeSlice with deterministic quota #32

@ccamel

Description

@ccamel

Summary

makeSlice (engine/malloc.go:21-42) currently bases its allocation gate on debug.SetMemoryLimit(-1) and runtime.ReadMemStats, then compares the reported "free" bytes against the requested slice length. Go's allocator and GC are non-deterministic; two replicas can observe different stats.Sys or stats.HeapReleased, so one node may reject the allocation with errOutOfMemory while another succeeds. That divergence breaks determinism.

Why it matters

Any predicate that allocates via makeSlice (e.g., copy_term/2, setof/3, list/dict helpers) can yield different outcomes across validators. On a blockchain this can fork consensus.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    📆 To do

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions