Skip to content

Idea: Throw SimdJsonException for a far lower user-provided max depth, in a subsequent major release #90

@TysonAndre

Description

@TysonAndre

C programs usually have a small stack size by default, and https://www.php.net/fiber is also low for the few use cases of fibers

Applications that override $depth in simdjson_decode to a much larger value may have a stack overflow and crash when they actually attempt to parse json (e.g. user-provided) of that depth by calling simdjson_decode.

  • (PHP's json_decode currently uses a parser based on bison, so the emitted code to convert json to php values doesn't actually use the C stack recursively, and doesn't have this problem)

The current default depth of 512 is fine (2097152 bytes of data), but the current max depth is only chosen to avoid running out of C memory when allocating buffers or allocating more than needed. It should be much lower

Zend/zend_fibers.h
28:#define ZEND_FIBER_DEFAULT_C_STACK_SIZE (4096 * (((sizeof(void *)) < 8) ? 256 : 512))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions