Skip to content

replace with invalid args crashes python #22591

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

Open
2 tasks done
cmdlineluser opened this issue May 3, 2025 · 0 comments
Open
2 tasks done

replace with invalid args crashes python #22591

cmdlineluser opened this issue May 3, 2025 · 0 comments
Labels
A-panic Area: code that results in panic exceptions accepted Ready for implementation bug Something isn't working P-medium Priority: medium python Related to Python Polars

Comments

@cmdlineluser
Copy link
Contributor

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

pl.Series([1]).replace([pl.lit(1)], [pl.lit(2)])

Log output

thread '<unnamed>' panicked at crates/polars-core/src/chunked_array/object/extension/drop.rs:24:17:
assertion failed: matches!(dtype, ArrowDataType::Extension(_))
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

thread '<unnamed>' panicked at crates/polars-core/src/chunked_array/object/extension/drop.rs:24:17:
assertion failed: matches!(dtype, ArrowDataType::Extension(_))
stack backtrace:
   0:        0x1086fc2df - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hd10546497cf799c2
   1:        0x102a32b23 - core::fmt::write::h88deaf71aebf30bb
   2:        0x1086f5942 - std::io::Write::write_fmt::h2f457d3610ab3dc2
   3:        0x1086fc112 - std::sys::backtrace::BacktraceLock::print::ha706331827d8baba
   4:        0x1086fee6d - std::panicking::default_hook::{{closure}}::h6d90e1bde173341c
   5:        0x1086fe99b - std::panicking::default_hook::h18d84560171a6066
   6:        0x1086ff8f3 - std::panicking::rust_panic_with_hook::hf324d21c781986a7
   7:        0x1086ff475 - std::panicking::begin_panic_handler::{{closure}}::h0ed16e835e1e6d0e
   8:        0x1086fc7c9 - std::sys::backtrace::__rust_end_short_backtrace::hf7830e5bbc191c57
   9:        0x1086ff0e4 - __rustc[e5679b3fd213e125]::rust_begin_unwind
  10:        0x102a2f36f - core::panicking::panic_fmt::h8dbafa136fd3aa27
  11:        0x102a2f414 - core::panicking::panic::h1a61685b0da64332
  12:        0x103ab3262 - polars_core::chunked_array::object::extension::drop::drop_list::h180a5529582c6c72
  13:        0x1043f5525 - core::ptr::drop_in_place<polars_core::chunked_array::ChunkedArray<polars_core::datatypes::ListType>>::heacb2ddb9abe2ea9
  14:        0x103af84bc - alloc::sync::Arc<T,A>::drop_slow::ha0636fa5936e6316
  15:        0x1044e5445 - <polars_expr::expressions::apply::ApplyExpr as polars_expr::expressions::PhysicalExpr>::evaluate::h5216aea498604d16
  16:        0x104b5a4ae - <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter::hbba88bb2e714ad02
  17:        0x104b98290 - core::iter::adapters::try_process::hbdbba28efa3e223f
  18:        0x104c542ec - polars_mem_engine::executors::projection_utils::run_exprs_seq::h564bce0b749eb00a
  19:        0x104ccc97f - polars_mem_engine::executors::projection::ProjectionExec::execute_impl::hfce3c84086d7806f
  20:        0x104ccd146 - <polars_mem_engine::executors::projection::ProjectionExec as polars_mem_engine::executors::executor::Executor>::execute::hc5288f5c3b701423
  21:        0x104ccbc04 - <polars_mem_engine::executors::executor::SinkExecutor as polars_mem_engine::executors::executor::Executor>::execute::hf2b13ba60d7ea173
  22:        0x104a48bbb - polars_lazy::frame::LazyFrame::collect_with_engine::h447ca1d5a7e5749a
  23:        0x1071ac13f - <pyo3::marker::Python as polars_python::utils::EnterPolarsExt>::enter_polars::h58843c3da8789e3f
  24:        0x1075b105c - polars_python::lazyframe::general::<impl polars_python::lazyframe::PyLazyFrame>::__pymethod_collect__::hb81a593fa0efe8cd
  25:        0x107374ec0 - pyo3::impl_::trampoline::trampoline::h523fd4eaeca03265
  26:        0x1073bfd28 - polars_python::lazyframe::general::_::__INVENTORY::trampoline::h092d9dcf3d228e46
  27:        0x10130fa5e - _method_vectorcall_VARARGS_KEYWORDS
  28:        0x101405eba - _call_function
  29:        0x101403be3 - __PyEval_EvalFrameDefault
  30:        0x1013f73c3 - __PyEval_Vector
  31:        0x10130296c - _PyVectorcall_Call
  32:        0x101403eb3 - __PyEval_EvalFrameDefault
  33:        0x1013f73c3 - __PyEval_Vector
  34:        0x1013057d9 - _method_vectorcall
  35:        0x101405eba - _call_function
  36:        0x101403d4a - __PyEval_EvalFrameDefault
  37:        0x1013f73c3 - __PyEval_Vector
  38:        0x101405eba - _call_function
  39:        0x101403be3 - __PyEval_EvalFrameDefault
  40:        0x1013f73c3 - __PyEval_Vector
  41:        0x101405eba - _call_function
  42:        0x101403be3 - __PyEval_EvalFrameDefault
  43:        0x1013f73c3 - __PyEval_Vector
  44:        0x1013f7254 - _PyEval_EvalCode
  45:        0x10145e1be - _run_eval_code_obj
  46:        0x10145e5d5 - _run_mod
  47:        0x101460851 - _PyRun_StringFlags
  48:        0x101460736 - _PyRun_SimpleStringFlags
  49:        0x10147d3e8 - _Py_RunMain
  50:        0x10147e867 - _pymain_main
  51:        0x10147e9dd - _Py_BytesMain

thread '<unnamed>' panicked at library/core/src/panicking.rs:226:5:
panic in a destructor during cleanup
thread caused non-unwinding panic. aborting.
Abort trap: 6

Issue description

I had some Exprs accidentally wrapped in a list and hit this.

If the LHS is invalid, it just panics.

pl.Series([1]).replace([pl.lit(1)], 2)
# PanicException: assertion failed: matches!(dtype, ArrowDataType::Extension(_))

Expected behavior

No crash/panic.

Installed versions

--------Version info---------
Polars:              1.29.0
Index type:          UInt32
Platform:            macOS-13.6.1-arm64-arm-64bit-Mach-O
Python:              3.13.0 (main, Oct  7 2024, 05:02:14) [Clang 15.0.0 (clang-1500.1.0.2.5)]
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            0.12.0
fsspec               <not installed>
gevent               <not installed>
google.auth          <not installed>
great_tables         0.14.0
matplotlib           <not installed>
nest_asyncio         <not installed>
numpy                2.1.3
openpyxl             3.1.5
pandas               2.2.3
pyarrow              18.0.0
pydantic             <not installed>
pyiceberg            <not installed>
sqlalchemy           <not installed>
torch                <not installed>
xlsx2csv             <not installed>
xlsxwriter           3.2.0
@cmdlineluser cmdlineluser added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels May 3, 2025
@cmdlineluser cmdlineluser changed the title replace with invalid args causes crash replace with invalid args crashes python May 3, 2025
@orlp orlp added accepted Ready for implementation P-medium Priority: medium A-panic Area: code that results in panic exceptions and removed needs triage Awaiting prioritization by a maintainer labels May 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-panic Area: code that results in panic exceptions accepted Ready for implementation bug Something isn't working P-medium Priority: medium python Related to Python Polars
Projects
None yet
Development

No branches or pull requests

2 participants