Skip to content

ext_store silently encodes VAL_BUFFER as null — buffers are lost on store round-trip #805

Description

@InauguralPhysicist

Found by the #738 switch-exhaustiveness conversion: when store_json_encode (src/ext_store.c) lost its default: arm, -Werror=switch immediately flagged VAL_BUFFER as unhandled — a buffer value stored through ext_store is encoded as JSON null, so the data is silently dropped and a load returns null where a buffer was saved.

Repro shape: store_set of [s, "k", buf] then store_get of [s, "k"] → null.

The exhaustive switch now names VAL_BUFFER on the null path explicitly (behavior-preserving, with a comment pointing here), so the gap is visible at the code site but still open. A real fix needs a store-format decision: JSON has no buffer type, so either encode as a numeric array (round-trips as VAL_LIST — type changes) or add a tagged encoding the decoder recognizes and rebuilds as VAL_BUFFER.

Sibling gap, same class: trace.c's full nondet formatter (write_value_ptr_full) renders VAL_JSON_RAW / VAL_TEXT_BUILDER as the opaque <heap> placeholder (the short form has <json>/<text>), so a nondet builtin returning either would tape an unreplayable record. No current nondet builtin returns them, so this is latent; noting it here rather than a separate issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions