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

Panic crash with assertion failed in Polars 1.17.0 scratch.is_empty() #20216

Closed
2 tasks done
coby-astsec opened this issue Dec 8, 2024 · 0 comments · Fixed by #20219
Closed
2 tasks done

Panic crash with assertion failed in Polars 1.17.0 scratch.is_empty() #20216

coby-astsec opened this issue Dec 8, 2024 · 0 comments · Fixed by #20219
Assignees
Labels
A-optimizer Area: plan optimization A-panic Area: code that results in panic exceptions accepted Ready for implementation bug Something isn't working P-high Priority: high python Related to Python Polars regression Issue introduced by a new release

Comments

@coby-astsec
Copy link

Checks

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of Polars.

Reproducible example

import polars as pl

col = pl.col("A")
# Only crashes with a LazyFrame
df = pl.LazyFrame([{"A": "1/1"}])

# This step is required for the crash, if I just build a df with an already split element it will not crash
df = df.with_columns(
    col.str.split("/")
)

# Just using `df.with_columns(col.list.get(0))` is not enough to crash
df = df.with_columns(
    pl.when(
        col.is_not_null()
    ).then(
        # Crash is here? Changing this to `None` stops the crash
        col.list.get(0)
    ).otherwise(
        None
    )
)

# This line will crash because of laziness
print(df.collect())

Log output

❯ POLARS_VERBOSE=1 uv run test.py
thread '<unnamed>' panicked at crates/polars-plan/src/plans/optimizer/slice_pushdown_lp.rs:52:5:
assertion failed: scratch.is_empty()
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Traceback (most recent call last):
  File "/path/to/test.py", line 20, in <module>
    print(df.collect())
          ~~~~~~~~~~^^
  File "/path/to/.venv/lib/python3.13/site-packages/polars/lazyframe/frame.py", line 2031, in collect
    return wrap_df(ldf.collect(callback))
                   ~~~~~~~~~~~^^^^^^^^^^
pyo3_runtime.PanicException: assertion failed: scratch.is_empty()

Issue description

Code that worked with Polars 1.16.0 has stopped working with 1.17.0
I'm not quite sure what the crash is, only that there has to be a very specific set of steps to cause the crash.
The reproduction is short and commented.

Expected behavior

No crash, print:

shape: (1, 1)
┌─────┐
│ A   │
│ --- │
│ str │
╞═════╡
│ 1   │
└─────┘

Installed versions

--------Version info---------
Polars:              1.17.0
Index type:          UInt32
Platform:            macOS-15.1.1-arm64-arm-64bit-Mach-O
Python:              3.13.0 (main, Oct  7 2024, 23:47:22) [Clang 18.1.8 ]
LTS CPU:             False

----Optional dependencies----
adbc_driver_manager  <not installed>
altair               <not installed>
boto3                <not installed>
cloudpickle          <not installed>
connectorx           <not installed>
deltalake            <not installed>
fastexcel            <not installed>
fsspec               <not installed>
gevent               <not installed>
google.auth          <not installed>
great_tables         <not installed>
matplotlib           <not installed>
nest_asyncio         <not installed>
numpy                <not installed>
openpyxl             <not installed>
pandas               <not installed>
pyarrow              <not installed>
pydantic             <not installed>
pyiceberg            <not installed>
sqlalchemy           <not installed>
torch                <not installed>
xlsx2csv             <not installed>
xlsxwriter           <not installed>
@coby-astsec coby-astsec added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels Dec 8, 2024
@nameexhaustion nameexhaustion self-assigned this Dec 9, 2024
@nameexhaustion nameexhaustion added regression Issue introduced by a new release A-optimizer Area: plan optimization A-panic Area: code that results in panic exceptions P-high Priority: high and removed needs triage Awaiting prioritization by a maintainer labels Dec 9, 2024
@github-project-automation github-project-automation bot moved this to Ready in Backlog Dec 9, 2024
@nameexhaustion nameexhaustion changed the title New crash in Polars 1.17.0 Panic crash with assertion failed in Polars 1.17.0 scratch.is_empty() Dec 9, 2024
@github-project-automation github-project-automation bot moved this from Ready to Done in Backlog Dec 9, 2024
bsweger added a commit to reichlab/cladetime that referenced this issue Dec 9, 2024
This changeset targets the Polars 1.17.1 release, which fixes
a bug that was impacting downstream cladetime users
bug: pola-rs/polars#20216
release: https://github.com/pola-rs/polars/releases/tag/py-1.17.1
bsweger added a commit to reichlab/cladetime that referenced this issue Dec 9, 2024
This changeset targets the Polars 1.17.1 release, which fixes
a bug that was impacting downstream cladetime users
bug: pola-rs/polars#20216
release: https://github.com/pola-rs/polars/releases/tag/py-1.17.1
@c-peters c-peters added the accepted Ready for implementation label Dec 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-optimizer Area: plan optimization A-panic Area: code that results in panic exceptions accepted Ready for implementation bug Something isn't working P-high Priority: high python Related to Python Polars regression Issue introduced by a new release
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants