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

fix: don't panic on invalid roll strategy, and update an error message #33

Merged
merged 4 commits into from
Dec 5, 2023

Conversation

alexander-beedie
Copy link
Contributor

Should close #32 ✌️

@MarcoGorelli
Copy link
Collaborator

thanks @alexander-beedie ! I'm seeing a really mysterious segmentation fault in CI, have no idea what's causing that, any ideas?

collecting ... collected 26 items

tests/test_business_offsets.py::test_against_np_busday_offset PASSED     [  3%]
tests/test_business_offsets.py::test_against_np_busday_offset_with_roll PASSED [  7%]
tests/test_business_offsets.py::test_extra_args[1bd-expected0] PASSED    [ 11%]
tests/test_business_offsets.py::test_extra_args[2bd-expected1] PASSED    [ 15%]
tests/test_business_offsets.py::test_extra_args[1bd2h-expected2] PASSED  [ 19%]
tests/test_business_offsets.py::test_extra_args[2h1bd-expected3] PASSED  [ 23%]
tests/test_business_offsets.py::test_extra_args[2bd1h-expected4] PASSED  [ 26%]
tests/test_business_offsets.py::test_extra_args[-1bd-expected5] PASSED   [ 30%]
tests/test_business_offsets.py::test_extra_args[-2bd-expected6] PASSED   [ 34%]
tests/test_business_offsets.py::test_extra_args[-1bd2h-expected7] PASSED [ 38%]
tests/test_business_offsets.py::test_extra_args[-2h1bd-expected8] PASSED [ 42%]
tests/test_business_offsets.py::test_extra_args[-2bd1h-expected9] PASSED [ 46%]
tests/test_business_offsets.py::test_extra_args_w_series PASSED          [ 50%]
tests/test_business_offsets.py::test_within_group_by PASSED              [ 53%]
tests/test_business_offsets.py::test_invalid_roll_strategy PASSED        [ 57%]
tests/test_date_range.py::test_eager PASSED                              [ 61%]
tests/test_date_range.py::test_expr PASSED                               [ 65%]
tests/test_date_range.py::test_invalid PASSED                            [ 69%]
tests/test_date_range.py::test_eager_custom_weekend PASSED               [ 73%]
tests/test_date_range.py::test_eager_custom_holiday PASSED               [ 76%]
tests/test_is_busday.py::test_against_np_is_busday PASSED                [ 80%]
Fatal Python error: Segmentation fault

Current thread 0x00007f0bbe42bb80 (most recent call first):
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/polars/expr/expr.py", line 9607 in register_plugin
  File "/home/runner/work/polars-business/polars-business/polars_business/polars_business/polars_business/__init__.py", line 234 in sub
  File "/home/runner/work/polars-business/polars-business/polars_business/tests/test_sub.py", line 26 in get_result
  File "/home/runner/work/polars-business/polars-business/polars_business/tests/test_sub.py", line 54 in test_against_np_busday_count
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/hypothesis/core.py", line 793 in test
  File "/home/runner/work/polars-business/polars-business/polars_business/tests/test_sub.py", line 32 in test_against_np_busday_count
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/hypothesis/core.py", line 858 in run
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/hypothesis/core.py", line 705 in default_executor
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/hypothesis/core.py", line 867 in execute_once
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/hypothesis/core.py", line 926 in _execute_once_for_engine
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/hypothesis/internal/conjecture/engine.py", line 171 in __stoppable_test_function
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/hypothesis/internal/conjecture/engine.py", line 193 in test_function
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/hypothesis/internal/conjecture/engine.py", line 717 in generate_new_examples
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/hypothesis/internal/conjecture/engine.py", line 866 in _run
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/hypothesis/internal/conjecture/engine.py", line 460 in run
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/hypothesis/core.py", line 1004 in run_engine
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/hypothesis/core.py", line 1438 in wrapped_test
  File "/home/runner/work/polars-business/polars-business/polars_business/tests/test_sub.py", line 32 in test_against_np_busday_count
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/_pytest/python.py", line 194 in pytest_pyfunc_call
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/pluggy/_callers.py", line 77 in _multicall
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/pluggy/_manager.py", line 115 in _hookexec
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/pluggy/_hooks.py", line 493 in __call__
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/_pytest/python.py", line 1792 in runtest
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/_pytest/runner.py", line 169 in pytest_runtest_call
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/pluggy/_callers.py", line 77 in _multicall
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/pluggy/_manager.py", line 115 in _hookexec
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/pluggy/_hooks.py", line 493 in __call__
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/_pytest/runner.py", line 262 in <lambda>
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/_pytest/runner.py", line 341 in from_call
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/_pytest/runner.py", line 261 in call_runtest_hook
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/_pytest/runner.py", line 222 in call_and_report
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/_pytest/runner.py", line 133 in runtestprotocol
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/_pytest/runner.py", line 114 in pytest_runtest_protocol
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/pluggy/_callers.py", line 77 in _multicall
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/pluggy/_manager.py", line 115 in _hookexec
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/pluggy/_hooks.py", line 493 in __call__
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/_pytest/main.py", line 350 in pytest_runtestloop
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/pluggy/_callers.py", line 77 in _multicall
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/pluggy/_manager.py", line 115 in _hookexec
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/pluggy/_hooks.py", line 493 in __call__
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/_pytest/main.py", line 325 in _main
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/_pytest/main.py", line 271 in wrap_session
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/_pytest/main.py", line 318 in pytest_cmdline_main
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/pluggy/_callers.py", line 77 in _multicall
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/pluggy/_manager.py", line 115 in _hookexec
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/pluggy/_hooks.py", line 493 in __call__
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/_pytest/config/__init__.py", line 169 in main
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/_pytest/config/__init__.py", line 192 in console_main
  File "/home/runner/work/polars-business/polars-business/polars_business/venv/lib/python3.9/site-packages/pytest/__main__.py", line 5 in <module>
  File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/runpy.py", line 87 in _run_code
  File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/runpy.py", line 197 in _run_module_as_main
/home/runner/work/_temp/a7f6255d-98ed-4fdb-9193-371f17ac21da.sh: line 1:  8451 Segmentation fault      (core dumped) venv/bin/python -m pytest tests -vv
tests/test_sub.py::test_against_np_busday_count 

@alexander-beedie
Copy link
Contributor Author

I just added a test and it all started blowing up 🤣
Will see what I did...

@MarcoGorelli
Copy link
Collaborator

😆 it's so odd...it only appears when running the full test suite via pytest

if I

  • run pytest tests/test_business_offsets.py::test_invalid_roll_strategy, it runs fine
  • run pytest, I get a segmentation fault
  • run pytest with test_invalid_roll_strategy commented-out, it runs fine

Don't even know how to investigate this 🤷

@alexander-beedie
Copy link
Contributor Author

alexander-beedie commented Dec 5, 2023

Reworked it slightly to trap/test earlier (and raise an even better error) at the Python level, keeping the lower level Rust-side bail in case there are any other ways of getting there 🤔

@ritchie46
Copy link
Member

What is the output of valgrind?

@MarcoGorelli
Copy link
Collaborator

I've tried running it, but I've not used valgrind before so don't know how to interpet it, will take a look

$ PYTHONMALLOC=malloc valgrind --show-leak-kinds=definite --log-file=/tmp/valgrind-output \
    python -m pytest -vv --valgrind --valgrind-log=/tmp/valgrind-output
============================================================= test session starts =============================================================
platform linux -- Python 3.10.12, pytest-7.4.3, pluggy-1.3.0 -- /home/marcogorelli/pyo3-polars-dev/polars_business/venv/bin/python
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase(PosixPath('/home/marcogorelli/pyo3-polars-dev/polars_business/.hypothesis/examples'))
pytest-valgrind: logfile=/tmp/valgrind-output
pytest-valgrind: Reporting direct+indirect leaks and ignoring the
pytest-valgrind:   `--errors-for-leak-kinds` valgrind option.
pytest-valgrind:   Python always causes "possible" leaks but you can use 
pytest-valgrind:   `--errors-for-leak-kinds=direct` to hide indirect leaks.)
rootdir: /home/marcogorelli/pyo3-polars-dev/polars_business
plugins: valgrind-0.2.0, hypothesis-6.91.0
collected 26 items                                                                                                                            

tests/test_business_offsets.py::test_against_np_busday_offset XFAIL (Error, but valgrind clean, using xfail.)                           [  3%]
tests/test_business_offsets.py::test_against_np_busday_offset_with_roll FAILED                                                          [  7%]
tests/test_business_offsets.py::test_extra_args[1bd-expected0] PASSED                                                                   [ 11%]
tests/test_business_offsets.py::test_extra_args[2bd-expected1] PASSED                                                                   [ 15%]
tests/test_business_offsets.py::test_extra_args[1bd2h-expected2] FAILED                                                                 [ 19%]
tests/test_business_offsets.py::test_extra_args[2h1bd-expected3] FAILED                                                                 [ 23%]
tests/test_business_offsets.py::test_extra_args[2bd1h-expected4] FAILED                                                                 [ 26%]
tests/test_business_offsets.py::test_extra_args[-1bd-expected5] FAILED                                                                  [ 30%]
tests/test_business_offsets.py::test_extra_args[-2bd-expected6] FAILED                                                                  [ 34%]
tests/test_business_offsets.py::test_extra_args[-1bd2h-expected7] FAILED                                                                [ 38%]
tests/test_business_offsets.py::test_extra_args[-2h1bd-expected8] FAILED                                                                [ 42%]
tests/test_business_offsets.py::test_extra_args[-2bd1h-expected9] FAILED                                                                [ 46%]
tests/test_business_offsets.py::test_extra_args_w_series FAILED                                                                         [ 50%]
tests/test_business_offsets.py::test_within_group_by FAILED                                                                             [ 53%]
tests/test_business_offsets.py::test_invalid_roll_strategy PASSED                                                                       [ 57%]
tests/test_date_range.py::test_eager PASSED                                                                                             [ 61%]
tests/test_date_range.py::test_expr PASSED                                                                                              [ 65%]
tests/test_date_range.py::test_invalid PASSED                                                                                           [ 69%]
tests/test_date_range.py::test_eager_custom_weekend PASSED                                                                              [ 73%]
tests/test_date_range.py::test_eager_custom_holiday PASSED                                                                              [ 76%]
tests/test_is_busday.py::test_against_np_is_busday PASSED                                                                               [ 80%]
tests/test_sub.py::test_against_np_busday_count PASSED                                                                                  [ 84%]
tests/test_sub.py::test_against_naive_python PASSED                                                                                     [ 88%]
tests/test_sub.py::test_empty_weekmask PASSED                                                                                           [ 92%]
tests/test_sub.py::test_sub_lit PASSED                                                                                                  [ 96%]
tests/test_sub.py::test_workday_count PASSED                                                                                            [100%]

================================================================== FAILURES ===================================================================
___________________________________________________ test_against_np_busday_offset_with_roll ___________________________________________________
[VALGRIND ERROR]

Valgrind has detected an error:

**23654** 
**23654** **********************************************************************
**23654** tests/test_business_offsets.py::test_against_np_busday_offset_with_roll
**23654** **********************************************************************
==23654== Thread 22:
==23654== Conditional jump or move depends on uninitialised value(s)
==23654==    at 0xD725963: <regex_syntax::hir::translate::TranslatorI as regex_syntax::ast::visitor::Visitor>::visit_post (in /home/marcogorelli/pyo3-polars-dev/polars_business/venv/lib/python3.10/site-packages/polars/polars.abi3.so)
==23654==    by 0xD6C415F: regex_automata::meta::regex::Builder::build (in /home/marcogorelli/pyo3-polars-dev/polars_business/venv/lib/python3.10/site-packages/polars/polars.abi3.so)
==23654==    by 0xD6A3D0C: regex::builders::string::RegexBuilder::build (in /home/marcogorelli/pyo3-polars-dev/polars_business/venv/lib/python3.10/site-packages/polars/polars.abi3.so)
==23654==    by 0xD6A6007: regex::regex::string::Regex::new (in /home/marcogorelli/pyo3-polars-dev/polars_business/venv/lib/python3.10/site-packages/polars/polars.abi3.so)
==23654==    by 0xD342055: polars_plan::dsl::function_expr::strings::replace (in /home/marcogorelli/pyo3-polars-dev/polars_business/venv/lib/python3.10/site-packages/polars/polars.abi3.so)
==23654==    by 0xD33FFCE: <F as polars_plan::dsl::expr_dyn_fn::SeriesUdf>::call_udf (in /home/marcogorelli/pyo3-polars-dev/polars_business/venv/lib/python3.10/site-packages/polars/polars.abi3.so)
==23654==    by 0xC7BB761: polars_lazy::physical_plan::expressions::apply::ApplyExpr::eval_and_flatten (in /home/marcogorelli/pyo3-polars-dev/polars_business/venv/lib/python3.10/site-packages/polars/polars.abi3.so)
==23654==    by 0xC7B2EA3: <polars_lazy::physical_plan::expressions::apply::ApplyExpr as polars_lazy::physical_plan::expressions::PhysicalExpr>::evaluate (in /home/marcogorelli/pyo3-polars-dev/polars_business/venv/lib/python3.10/site-packages/polars/polars.abi3.so)
==23654==    by 0xC7C3ABD: rayon::iter::plumbing::bridge_producer_consumer::helper (in /home/marcogorelli/pyo3-polars-dev/polars_business/venv/lib/python3.10/site-packages/polars/polars.abi3.so)
==23654==    by 0xC7C465C: <rayon_core::job::StackJob<L,F,R> as rayon_core::job::Job>::execute (in /home/marcogorelli/pyo3-polars-dev/polars_business/venv/lib/python3.10/site-packages/polars/polars.abi3.so)
==23654==    by 0xA878FA8: rayon_core::registry::WorkerThread::wait_until_cold (in /home/marcogorelli/pyo3-polars-dev/polars_business/venv/lib/python3.10/site-packages/polars/polars.abi3.so)
==23654==    by 0xD6A0DE6: std::sys_common::backtrace::__rust_begin_short_backtrace (in /home/marcogorelli/pyo3-polars-dev/polars_business/venv/lib/python3.10/site-packages/polars/polars.abi3.so)
==23654== 
==23654== LEAK SUMMARY:
==23654==    definitely lost: 0 (+0) bytes in 0 (+0) blocks
==23654==    indirectly lost: 0 (+0) bytes in 0 (+0) blocks
==23654==      possibly lost: 10,632,213 (+98,020) bytes in 97,157 (+329) blocks
==23654==    still reachable: 26,630,460 (+164,079) bytes in 181,626 (+1,608) blocks
==23654==                       of which reachable via heuristic:
==23654==                         newarray           : 576 (+0) bytes in 36 (+0) blocks
==23654==         suppressed: 0 (+0) bytes in 0 (+0) blocks
==23654== Reachable blocks (those to which a pointer was found) are not shown.
==23654== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==23654== 
**23654** 
**23654** **********************************************************************
______________________________________________________ test_extra_args[1bd2h-expected2] _______________________________________________________
[VALGRIND ERROR]

Valgrind has detected an error:

**23654** 
**23654** **********************************************************************
**23654** tests/test_business_offsets.py::test_extra_args[1bd2h-expected2]
**23654** **********************************************************************
==23654== LEAK SUMMARY:
==23654==    definitely lost: 0 (+0) bytes in 0 (+0) blocks
==23654==    indirectly lost: 0 (+0) bytes in 0 (+0) blocks
==23654==      possibly lost: 10,644,651 (+1,255) bytes in 97,049 (+7) blocks
==23654==    still reachable: 26,512,383 (+1,688) bytes in 180,635 (+25) blocks
==23654==                       of which reachable via heuristic:
==23654==                         newarray           : 576 (+0) bytes in 36 (+0) blocks
==23654==         suppressed: 0 (+0) bytes in 0 (+0) blocks
==23654== Reachable blocks (those to which a pointer was found) are not shown.
==23654== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==23654== 
**23654** 
**23654** **********************************************************************
______________________________________________________ test_extra_args[2h1bd-expected3] _______________________________________________________
[VALGRIND ERROR]

Valgrind has detected an error:

**23654** 
**23654** **********************************************************************
**23654** tests/test_business_offsets.py::test_extra_args[2h1bd-expected3]
**23654** **********************************************************************
==23654== LEAK SUMMARY:
==23654==    definitely lost: 0 (+0) bytes in 0 (+0) blocks
==23654==    indirectly lost: 0 (+0) bytes in 0 (+0) blocks
==23654==      possibly lost: 10,653,177 (+8,526) bytes in 97,062 (+13) blocks
==23654==    still reachable: 26,517,708 (+5,325) bytes in 180,708 (+73) blocks
==23654==                       of which reachable via heuristic:
==23654==                         newarray           : 576 (+0) bytes in 36 (+0) blocks
==23654==         suppressed: 0 (+0) bytes in 0 (+0) blocks
==23654== Reachable blocks (those to which a pointer was found) are not shown.
==23654== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==23654== 
**23654** 
**23654** **********************************************************************
______________________________________________________ test_extra_args[2bd1h-expected4] _______________________________________________________
[VALGRIND ERROR]

Valgrind has detected an error:

**23654** 
**23654** **********************************************************************
**23654** tests/test_business_offsets.py::test_extra_args[2bd1h-expected4]
**23654** **********************************************************************
==23654== LEAK SUMMARY:
==23654==    definitely lost: 0 (+0) bytes in 0 (+0) blocks
==23654==    indirectly lost: 0 (+0) bytes in 0 (+0) blocks
==23654==      possibly lost: 10,655,893 (+2,716) bytes in 97,077 (+15) blocks
==23654==    still reachable: 26,521,989 (+4,281) bytes in 180,767 (+59) blocks
==23654==                       of which reachable via heuristic:
==23654==                         newarray           : 576 (+0) bytes in 36 (+0) blocks
==23654==         suppressed: 0 (+0) bytes in 0 (+0) blocks
==23654== Reachable blocks (those to which a pointer was found) are not shown.
==23654== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==23654== 
**23654** 
**23654** **********************************************************************
_______________________________________________________ test_extra_args[-1bd-expected5] _______________________________________________________
[VALGRIND ERROR]

Valgrind has detected an error:

**23654** 
**23654** **********************************************************************
**23654** tests/test_business_offsets.py::test_extra_args[-1bd-expected5]
**23654** **********************************************************************
==23654== LEAK SUMMARY:
==23654==    definitely lost: 0 (+0) bytes in 0 (+0) blocks
==23654==    indirectly lost: 0 (+0) bytes in 0 (+0) blocks
==23654==      possibly lost: 10,658,151 (+2,258) bytes in 97,088 (+11) blocks
==23654==    still reachable: 26,526,451 (+4,462) bytes in 180,830 (+63) blocks
==23654==                       of which reachable via heuristic:
==23654==                         newarray           : 576 (+0) bytes in 36 (+0) blocks
==23654==         suppressed: 0 (+0) bytes in 0 (+0) blocks
==23654== Reachable blocks (those to which a pointer was found) are not shown.
==23654== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==23654== 
**23654** 
**23654** **********************************************************************
_______________________________________________________ test_extra_args[-2bd-expected6] _______________________________________________________
[VALGRIND ERROR]

Valgrind has detected an error:

**23654** 
**23654** **********************************************************************
**23654** tests/test_business_offsets.py::test_extra_args[-2bd-expected6]
**23654** **********************************************************************
==23654== LEAK SUMMARY:
==23654==    definitely lost: 0 (+0) bytes in 0 (+0) blocks
==23654==    indirectly lost: 0 (+0) bytes in 0 (+0) blocks
==23654==      possibly lost: 10,660,478 (+2,327) bytes in 97,102 (+14) blocks
==23654==    still reachable: 26,530,828 (+4,377) bytes in 180,890 (+60) blocks
==23654==                       of which reachable via heuristic:
==23654==                         newarray           : 576 (+0) bytes in 36 (+0) blocks
==23654==         suppressed: 0 (+0) bytes in 0 (+0) blocks
==23654== Reachable blocks (those to which a pointer was found) are not shown.
==23654== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==23654== 
**23654** 
**23654** **********************************************************************
______________________________________________________ test_extra_args[-1bd2h-expected7] ______________________________________________________
[VALGRIND ERROR]

Valgrind has detected an error:

**23654** 
**23654** **********************************************************************
**23654** tests/test_business_offsets.py::test_extra_args[-1bd2h-expected7]
**23654** **********************************************************************
==23654== LEAK SUMMARY:
==23654==    definitely lost: 0 (+0) bytes in 0 (+0) blocks
==23654==    indirectly lost: 0 (+0) bytes in 0 (+0) blocks
==23654==      possibly lost: 10,663,292 (+2,814) bytes in 97,119 (+17) blocks
==23654==    still reachable: 26,534,952 (+4,124) bytes in 180,947 (+57) blocks
==23654==                       of which reachable via heuristic:
==23654==                         newarray           : 576 (+0) bytes in 36 (+0) blocks
==23654==         suppressed: 0 (+0) bytes in 0 (+0) blocks
==23654== Reachable blocks (those to which a pointer was found) are not shown.
==23654== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==23654== 
**23654** 
**23654** **********************************************************************
______________________________________________________ test_extra_args[-2h1bd-expected8] ______________________________________________________
[VALGRIND ERROR]

Valgrind has detected an error:

**23654** 
**23654** **********************************************************************
**23654** tests/test_business_offsets.py::test_extra_args[-2h1bd-expected8]
**23654** **********************************************************************
==23654== LEAK SUMMARY:
==23654==    definitely lost: 0 (+0) bytes in 0 (+0) blocks
==23654==    indirectly lost: 0 (+0) bytes in 0 (+0) blocks
==23654==      possibly lost: 10,666,030 (+2,738) bytes in 97,134 (+15) blocks
==23654==    still reachable: 26,539,184 (+4,232) bytes in 181,006 (+59) blocks
==23654==                       of which reachable via heuristic:
==23654==                         newarray           : 576 (+0) bytes in 36 (+0) blocks
==23654==         suppressed: 0 (+0) bytes in 0 (+0) blocks
==23654== Reachable blocks (those to which a pointer was found) are not shown.
==23654== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==23654== 
**23654** 
**23654** **********************************************************************
______________________________________________________ test_extra_args[-2bd1h-expected9] ______________________________________________________
[VALGRIND ERROR]

Valgrind has detected an error:

**23654** 
**23654** **********************************************************************
**23654** tests/test_business_offsets.py::test_extra_args[-2bd1h-expected9]
**23654** **********************************************************************
==23654== LEAK SUMMARY:
==23654==    definitely lost: 0 (+0) bytes in 0 (+0) blocks
==23654==    indirectly lost: 0 (+0) bytes in 0 (+0) blocks
==23654==      possibly lost: 10,668,768 (+2,738) bytes in 97,149 (+15) blocks
==23654==    still reachable: 26,543,416 (+4,232) bytes in 181,065 (+59) blocks
==23654==                       of which reachable via heuristic:
==23654==                         newarray           : 576 (+0) bytes in 36 (+0) blocks
==23654==         suppressed: 0 (+0) bytes in 0 (+0) blocks
==23654== Reachable blocks (those to which a pointer was found) are not shown.
==23654== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==23654== 
**23654** 
**23654** **********************************************************************
__________________________________________________________ test_extra_args_w_series ___________________________________________________________
[VALGRIND ERROR]

Valgrind has detected an error:

**23654** 
**23654** **********************************************************************
**23654** tests/test_business_offsets.py::test_extra_args_w_series
**23654** **********************************************************************
==23654== LEAK SUMMARY:
==23654==    definitely lost: 0 (+0) bytes in 0 (+0) blocks
==23654==    indirectly lost: 0 (+0) bytes in 0 (+0) blocks
==23654==      possibly lost: 10,672,286 (+3,518) bytes in 97,166 (+17) blocks
==23654==    still reachable: 26,546,055 (+2,639) bytes in 181,105 (+40) blocks
==23654==                       of which reachable via heuristic:
==23654==                         newarray           : 576 (+0) bytes in 36 (+0) blocks
==23654==         suppressed: 0 (+0) bytes in 0 (+0) blocks
==23654== Reachable blocks (those to which a pointer was found) are not shown.
==23654== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==23654== 
**23654** 
**23654** **********************************************************************
____________________________________________________________ test_within_group_by _____________________________________________________________
[VALGRIND ERROR]

Valgrind has detected an error:

**23654** 
**23654** **********************************************************************
**23654** tests/test_business_offsets.py::test_within_group_by
**23654** **********************************************************************
==23654== LEAK SUMMARY:
==23654==    definitely lost: 0 (+0) bytes in 0 (+0) blocks
==23654==    indirectly lost: 0 (+0) bytes in 0 (+0) blocks
==23654==      possibly lost: 10,688,443 (+16,157) bytes in 97,211 (+45) blocks
==23654==    still reachable: 26,552,947 (+6,892) bytes in 181,161 (+56) blocks
==23654==                       of which reachable via heuristic:
==23654==                         newarray           : 576 (+0) bytes in 36 (+0) blocks
==23654==         suppressed: 0 (+0) bytes in 0 (+0) blocks
==23654== Reachable blocks (those to which a pointer was found) are not shown.
==23654== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==23654== 
**23654** 
**23654** **********************************************************************
=========================================================== short test summary info ===========================================================
FAILED tests/test_business_offsets.py::test_against_np_busday_offset_with_roll - Failed: [VALGRIND ERROR]
FAILED tests/test_business_offsets.py::test_extra_args[1bd2h-expected2] - Failed: [VALGRIND ERROR]
FAILED tests/test_business_offsets.py::test_extra_args[2h1bd-expected3] - Failed: [VALGRIND ERROR]
FAILED tests/test_business_offsets.py::test_extra_args[2bd1h-expected4] - Failed: [VALGRIND ERROR]
FAILED tests/test_business_offsets.py::test_extra_args[-1bd-expected5] - Failed: [VALGRIND ERROR]
FAILED tests/test_business_offsets.py::test_extra_args[-2bd-expected6] - Failed: [VALGRIND ERROR]
FAILED tests/test_business_offsets.py::test_extra_args[-1bd2h-expected7] - Failed: [VALGRIND ERROR]
FAILED tests/test_business_offsets.py::test_extra_args[-2h1bd-expected8] - Failed: [VALGRIND ERROR]
FAILED tests/test_business_offsets.py::test_extra_args[-2bd1h-expected9] - Failed: [VALGRIND ERROR]
FAILED tests/test_business_offsets.py::test_extra_args_w_series - Failed: [VALGRIND ERROR]
FAILED tests/test_business_offsets.py::test_within_group_by - Failed: [VALGRIND ERROR]
============================================ 11 failed, 14 passed, 1 xfailed in 105.20s (0:01:45) =============================================

@ritchie46
Copy link
Member

This seems the culprint:

==23654== Thread 22:
==23654== Conditional jump or move depends on uninitialised value(s)
==23654==    at 0xD725963: <regex_syntax::hir::translate::TranslatorI as regex_syntax::ast::visitor::Visitor>::visit_post (in /home/marcogorelli/pyo3-polars-dev/polars_business/venv/lib/python3.10/site-packages/polars/polars.abi3.so)
==23654==    by 0xD6C415F: regex_automata::meta::regex::Builder::build (in /home/marcogorelli/pyo3-polars-dev/polars_business/venv/lib/python3.10/site-packages/polars/polars.abi3.so)
==23654==    by 0xD6A3D0C: regex::builders::string::RegexBuilder::build (in /home/marcogorelli/pyo3-polars-dev/polars_business/venv/lib/python3.10/site-packages/polars/polars.abi3.so)
==23654==    by 0xD6A6007: regex::regex::string::Regex::new (in /home/marcogorelli/pyo3-polars-dev/polars_business/venv/lib/python3.10/site-packages/polars/polars.abi3.so)
==23654==    by 0xD342055: polars_plan::dsl::function_expr::strings::replace (in /home/marcogorelli/pyo3-polars-dev/polars_business/venv/lib/python3.10/site-packages/polars/polars.abi3.so)
==23654==    by 0xD33FFCE: <F as polars_plan::dsl::expr_dyn_fn::SeriesUdf>::call_udf (in /home/marcogorelli/pyo3-polars-dev/polars_business/venv/lib/python3.10/site-packages/polars/polars.abi3.so)
==23654==    by 0xC7BB761: polars_lazy::physical_plan::expressions::apply::ApplyExpr::eval_and_flatten (in /home/marcogorelli/pyo3-polars-dev/polars_business/venv/lib/python3.10/site-packages/polars/polars.abi3.so)
==23654==    by 0xC7B2EA3: <polars_lazy::physical_plan::expressions::apply::ApplyExpr as polars_lazy::physical_plan::expressions::PhysicalExpr>::evaluate (in /home/marcogorelli/pyo3-polars-dev/polars_business/venv/lib/python3.10/site-packages/polars/polars.abi3.so)
==23654==    by 0xC7C3ABD: rayon::iter::plumbing::bridge_producer_consumer::helper (in /home/marcogorelli/pyo3-polars-dev/polars_business/venv/lib/python3.10/site-packages/polars/polars.abi3.so)
==23654==    by 0xC7C465C: <rayon_core::job::StackJob<L,F,R> as rayon_core::job::Job>::execute (in /home/marcogorelli/pyo3-polars-dev/polars_business/venv/lib/python3.10/site-packages/polars/polars.abi3.so)
==23654==    by 0xA878FA8: rayon_core::registry::WorkerThread::wait_until_cold (in /home/marcogorelli/pyo3-polars-dev/polars_business/venv/lib/python3.10/site-packages/polars/polars.abi3.so)
==23654==    by 0xD6A0DE6: std::sys_common::backtrace::__rust_begin_short_backtrace (in /home/marcogorelli/pyo3-polars-dev/polars_business/venv/lib/python3.10/site-packages/polars/polars.abi3.so)

@ritchie46
Copy link
Member

All good now?

@MarcoGorelli
Copy link
Collaborator

all good by working around it by doing the check in Python 😆 :

        if roll not in (valid_roll_strategies := get_args(RollStrategy)):
            allowed = ", ".join(repr(m) for m in valid_roll_strategies)
            raise ValueError(
                f"`roll` strategy must be one of {{{allowed}}}, got {roll!r}"
            )

Removing that, and letting the error be raised from within Rust, and the segfault still appears

Going to merge and release for now, as the error doesn't seem related to this PR itself if the culprit is

            n = (by.str.extract(r"^(-?)") + by.str.extract(r"(\d+)bd")).cast(pl.Int32)
            by = by.str.replace(r"(\d+bd)", "")

(but even then, I don't see what's uninitialised)

thanks @alexander-beedie for the PR and @ritchie46 for taking a look!

I've opened #34 to make sure the issue isn't forgotten

@MarcoGorelli MarcoGorelli merged commit b48bdfd into pola-rs:main Dec 5, 2023
@alexander-beedie alexander-beedie deleted the minor-roll-param-tweaks branch December 5, 2023 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Outdated exception message and unreachable code using offset_by's roll argument
3 participants