You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This only happens when reusing a previous parser instance. I'm not sure whether this is by design, but if it is, it should probably be explicitly documented to avoid confusion.
It also becomes especially iffy when mixing different types:
Note that the parser holds the allocated memory. By reusing the parser from document to document, we reuse the allocated memory. The net result is to avoid memory reallocation, an expensive process. On some systems, it is more expensive to allocate memory than to parse JSON !
You can see one approach to stopping this in pysimdjson, https://github.com/TkTech/pysimdjson/blob/master/simdjson/csimdjson.pyx#L437. It's likely not our final fix, since it's a bit buggy on pypy whose garbage collector might wait a long, long time to cleanup things pointing into the Parser's document even if it's been explicitly deleted. In @ROpdebee's example above, it would have raised a RuntimeError instead of a potential segfault.
Installed via PyPI
This only happens when reusing a previous parser instance. I'm not sure whether this is by design, but if it is, it should probably be explicitly documented to avoid confusion.
It also becomes especially iffy when mixing different types:
So if it is by design, it might be worthwhile to somehow invalidate the previous reference when a new document is parsed.
The text was updated successfully, but these errors were encountered: