Open alexander-beedie opened 1 year ago
Perhaps identical to https://github.com/pola-rs/polars/issues/10173, which was labelled as not-planned
?
Perhaps identical to #10173, which was labelled as
not-planned
?
It doesn't have to work (expressions of this scale probably indicate some poor choices being made on the user side), but equally it shouldn't segfault ;)
The segfault is what we get in rust when we overflow the stack. There is no runtime check like in python, so that's what gives this scary abort.
It isn't something we can trivially fix though and will remain if we overflow the stack in polars. At some number of expression/node nesting I would expect a stackoverflow. We can investigate this one and see if we can increase the number, but I think there should be a number where we deem it acceptable for maintenance reasons.
Note, on linux by setting RUST_MIN_STACK
or by setting .cargo/config.toml with, e.g.:
[build] rustflags = [ "-C", "link-arg=-zstack-size=104857600", ]
You can avoid this issue somewhat, so long as your stacksize is at least bounded. On OSX and other versions of clang the arguments are different but can also be set consistently with env vars, e.g.:
RUST_MIN_STACK=104857600 cargo test -- --nocapture # no capture is just to execute println! during cargo test
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.
Reproducible example
The below expansion (while not the original code) replicates the observed error:
Note; by varying the size of the
when/then
from merely ridiculously large (5,000) to ludicrously large (10,000) it seems possible to generate slightly different flavours of sefault.Log output
When size=5000:
When size=10000:
Note, this is on an Apple Silicon M2 Max; may need to vary the
size
for different architectures.Issue description
Extremely large expressions can blow up the stack.
Expected behavior
Shouldn't segfault; ideally would either succeed or (when getting into really ridiculous territory!) raise an error.
Installed versions