Skip to content

std.parseJson / std.parseYaml: number overflow (out_of_range.406) aborts the process #1337

Description

@liuyi1231

std.parseJson only catches nlohmann::json::parse_error. Overflowing numbers raise out_of_range.406, which escapes to CATCH in libjsonnet.cpp and abort()s. Same for std.parseYaml("1E999") (RapidYAML → json::parse without catching out_of_range).

Same gap as #680 / #951 (parse_error only). Tip 2ef32ab / CLI v0.22.0.

Repro

git clone https://github.com/google/jsonnet.git
cd jsonnet && make -j$(nproc)
./jsonnet -e 'std.parseJson("1E999")'
… out_of_range.406 … number overflow parsing '1E999'
Aborted (core dumped)  # exit 134

./jsonnet -e 'std.parseYaml("1E999")' → same abort.
./jsonnet -e 'std.parseJson("{")' → RuntimeError, no abort.
./jsonnet -e 'std.parseJson("1e2")'100.

Fix

Catch json::exception (or out_of_range) in builtinParseJson and around json::parse in builtinParseYaml; throw makeError(...) like #951.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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