melange-community / melange-community/jsonkit

Native runtime uses non tailrec functions which cause failure on large json

Open
#68 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
OCaml
Stars
24
Forks
7
Avg merge
1d 15h
Merged PRs (30d)
5

Description

We faced at ahrefs a problem with json that contained large arrays. We have some segfaults because of Stdlib.List.map. This isn't a problem for people using ocaml 5, but it's still a problem with ocaml 4.

I did a quick fix for us
https://github.com/melange-community/melange-json/compare/main...ahrefs:melange-json:louis/native-list-tailrec

The fact that melange_json.ml doesn't have a corresponding .mli meant that I couldn't just create a List module with the few necessary functions.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with melange_json.ml and the linked native-list-tailrec comparison to understand the existing workaround for large arrays. Check how the native runtime uses Stdlib.List.map and related functions under OCaml 4. Done means large JSON arrays no longer trigger stack overflow or segmentation faults on OCaml 4 while preserving the OCaml 5 behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
40/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.