Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
TysonAndre opened this issue Oct 21, 2022 · 0 comments

Comments

@TysonAndre
Copy link
Collaborator

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))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant