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

Deprecate regexp ok and error() methods #17245

Merged
merged 1 commit into from
Feb 24, 2021
Merged

Deprecate regexp ok and error() methods #17245

merged 1 commit into from
Feb 24, 2021

Conversation

leekillough
Copy link

This deprecates the regexp ok and error() methods, since they were replaced with exceptions.

This also fixes segfaults in ok and error() when the regexp is not successfully compiled, or when it is default-initialized.

The error() method returns the same string as the compiler deprecation warning, since we do not have an easy way to access the original error message, because the regexp being returned from compile() is not assigned to a variable if an exception is thrown, so even if the exception is caught, the variable being assigned the compile() result does not contain the error message -- only the exception does.

This deserves a separate PR from #17189, since it is actually adding functionality, not removing it. It is not simply a reversion of PR #17189.

Copy link
Member

@mppf mppf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing it. I think it is reasonable to merge this PR in case anybody has old code that used these functions, and the modifications you made to re2-interface.cc seem reasonable. (I would also have found it OK to just make these functions call compilerError since they were not working).

I don't particularly care in this case (because it wasn't working before as you said) but note that the normal practice when deprecating is to include the deprecated functions in the module docs along with a note that they are deprecated.

test/deprecated/regexp_error.good Outdated Show resolved Hide resolved
Signed-off-by: Lee Killough <lee.killough@hpe.com>
@leekillough leekillough merged commit a40fe14 into chapel-lang:master Feb 24, 2021
@leekillough leekillough deleted the deprecate_regexp_ok_error branch February 24, 2021 20:46
e-kayrakli added a commit that referenced this pull request Mar 4, 2021
Close the leak coming from regexp.compile's error message

QIO creates an error message when it fails to compile a regular expression. It
returns a `const char *`. Then, we create a Chapel string from it. However, we
aren't owning the error string buffer returned by QIO and that causes memory
leaks. This PR makes the Chapel string own the buffer.

This was a leak that we didn't know until @leekillough added deprecation test
that hit that leak in #17245.

But that test will disappear once we remove the functionality, so this PR adds
a watered down version of the test to lock the behavior.

[Reviewed by @mppf]

#### Test status
- [x] quickstart asan in `release/examples` and `regexp`
- [x] standard
e-kayrakli added a commit that referenced this pull request Mar 4, 2021
Add memory leak annotations

Annotates the following PRs that changed memory leaks:

- This PR added a test that exercised a Regexp code that we have never before
  and that leaks:

  #17245

  (This is resolved today)

- New leaky tests:

  #17291

  - That were resolved by:

    #17320

[Trivial, not reviewed]
@leekillough leekillough added this to the Jelly Sprint 62 milestone Apr 6, 2021
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.

4 participants