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

[BUG] Exceptions thrown in regcomp.cpp seem to not propagate up to Cython (leads to SIGABRT) #13052

Closed
shwina opened this issue Apr 4, 2023 · 0 comments · Fixed by #13054
Closed
Assignees
Labels
bug Something isn't working

Comments

@shwina
Copy link
Contributor

shwina commented Apr 4, 2023

Exceptions that are thrown in the C++ code in regcomp.cpp seem to not propagate all the way up to Python and lead to a SIGABRT. For example:

>>> import cudf
>>> s = cudf.Series(["a"])
>>> s.str.extract("{\}")
terminate called after throwing an instance of 'cudf::logic_error'
  what():  CUDF failure at:/cudf/cpp/src/strings/regex/regcomp.cpp:565: invalid regex pattern: nothing to repeat at position 0
fish: “pythonterminated by signal SIGABRT (Abort)

Our bindings to the extract function are marked except +, which means that the C++ code generated by Cython will catch any C++ exceptions thrown by cudf::strings::extract and rethrow them as Python errors. For example, this all works as expected when the error is thrown from outside regcomp.cpp:

>>> s.str.extract("blah")
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
...
...
RuntimeError: CUDF failure at: /cudf/cpp/src/strings/extract/extract.cu:98: Group indicators not found in regex pattern

cc: @davidwendt is there something internally within libcudf that may be preventing exceptions from regcomp.cpp from being propagated up to the Python caller?

@shwina shwina added bug Something isn't working Needs Triage Need team to review and classify labels Apr 4, 2023
@davidwendt davidwendt self-assigned this Apr 4, 2023
rapids-bot bot pushed a commit that referenced this issue Apr 5, 2023
…13054)

Add the `except +` declaration to the `cudf::strings::regex_program::create()` function in the Cython `regex_program.pxd` interface since invalid regex patterns are thrown by this call. This allows the normal Cython exception handling to pass the exception to the Python logic without aborting the process.

Closes #13052

Authors:
  - David Wendt (https://github.com/davidwendt)

Approvers:
  - Bradley Dice (https://github.com/bdice)
  - Ashwin Srinath (https://github.com/shwina)

URL: #13054
@bdice bdice removed the Needs Triage Need team to review and classify label Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants