polars
polars copied to clipboard
`.write_json()` with a struct column causes a segfault
Polars version checks
-
[X] I have checked that this issue has not already been reported.
-
[X] I have confirmed this bug exists on the latest version of Polars.
Issue description
.write_json()
on a dataframe containing a struct column is causing python to segfault.
Setting json_lines=True
or using .write_ndjson()
work as expected.
Reproducible example
import polars as pl
pl.DataFrame({"a": [{"b": "c"}]}).write_json()
# Segmentation fault: 11
Expected behavior
Not to segfault.
Installed versions
---Version info---
Polars: 0.15.15
Index type: UInt32
Python: 3.10.9 (main, Jan 14 2023, 16:56:26)
---Optional dependencies---
pyarrow: 9.0.0
pandas: 1.5.3
numpy: 1.23.5
fsspec: 2022.8.2
connectorx: <not installed>
xlsx2csv: 0.8
deltalake: <not installed>
matplotlib: 3.5.1
Valgrind says it is a stackoverflow, so I assume we recurse somewhere.
It looks like the issue is with serde_json::to_writer()
https://github.com/pola-rs/polars/blob/master/py-polars/src/dataframe.rs#L395 seems to be codepath taken.