Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
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

feat(rust): Support jumping into a debugger breakpoint on errors #17849

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

itamarst
Copy link
Contributor

Currently POLARS_PANIC_ON_ERR turns an error into a panic. This PR extends that functionality to allow jumping into a debugger breakpoint instead of panicking.

This is a nicer than panic plus setting a breakpoint on rust_panic, because it doesn't distort the way the code runs, you can poke around, then tell the debugger to continue and the program runs as usual.

$ export POLARS_PANIC_ON_ERR=breakpoint
$ rust-gdb  --args python ../9188.py 
...
(gdb) run
Starting program: /home/itamarst/devel/polars/.venv/bin/python ../9188.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
original shape: (2,)
Series: 's' [list[i64]]
[
        [1, 2]
        [3]
]

Program received signal SIGTRAP, Trace/breakpoint trap.
0x00007ffff5094824 in polars_error::{impl#0}::from<alloc::string::String> (msg=...) at crates/polars-error/src/lib.rs:31
31                      unsafe { std::intrinsics::breakpoint(); }
(gdb) up
#1  0x00007ffff509a4fe in core::convert::{impl#3}::into<alloc::string::String, polars_error::ErrString> (self=...)
    at /rustc/3cb521a4344f0b556b81c55eec8facddeb1ead83/library/core/src/convert/mod.rs:759
759             U::from(self)
(gdb) up
#2  0x00007ffff3e25356 in polars_core::series::series_trait::private::PrivateSeries::add_to<polars_core::series::implementations::SeriesWrap<polars_core::chunked_array::ChunkedArray<polars_core::datatypes::ListType>>> (self=0x7fffe66562d0, 
    _rhs=0x7ffff6d37040) at crates/polars-core/src/series/series_trait.rs:145
145                 polars_bail!(opq = add, self._dtype());
(gdb) up
#3  0x00007ffff424f546 in polars_core::series::arithmetic::borrowed::{impl#7}::add (
    self=0x7ffff6d37040, rhs=0x7ffff6d37040)
    at crates/polars-core/src/series/arithmetic/borrowed.rs:503
503                     lhs.add_to(rhs.as_ref())
(gdb) c
Continuing.
Traceback (most recent call last):
  File "/home/itamarst/devel/polars/py-polars/../9188.py", line 5, in <module>
    added = s + s
  File "/home/itamarst/devel/polars/py-polars/polars/series/series.py", line 1053, in __add__
    return self._arithmetic(other, "add", "add_<>")
  File "/home/itamarst/devel/polars/py-polars/polars/series/series.py", line 1000, in _arithmetic
    return self._from_pyseries(getattr(self._s, op_s)(other._s))
polars.exceptions.InvalidOperationError: `add` operation not supported for dtype `list[i64]`
[Inferior 1 (process 861482) exited with code 01]

@github-actions github-actions bot added enhancement New feature or an improvement of an existing feature rust Related to Rust Polars labels Jul 24, 2024
@itamarst
Copy link
Contributor Author

If there's any interest I'll figure out how to do the conditional compilation bit for stable, otherwise I'll just close.

Copy link

codecov bot commented Jul 24, 2024

Codecov Report

Attention: Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.

Project coverage is 80.50%. Comparing base (c537ba3) to head (e774f62).

Files Patch % Lines
crates/polars-error/src/lib.rs 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #17849      +/-   ##
==========================================
- Coverage   80.50%   80.50%   -0.01%     
==========================================
  Files        1504     1504              
  Lines      197162   197167       +5     
  Branches     2806     2806              
==========================================
- Hits       158732   158724       -8     
- Misses      37909    37922      +13     
  Partials      521      521              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or an improvement of an existing feature rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants