From c7065527dc1418e285d64daa8392e8bebccd8f4c Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Sun, 31 Mar 2019 07:45:17 -0400 Subject: [PATCH] api: make Regex UnwindSafe again This commit fixes a regression introduced in 1.1.3 where Regex was no longer UnwindSafe. The underlying reason is that the new AhoCorasick type in aho-corasick 0.7 was not UnwindSafe. This has been fixed in aho-corasick 0.7.4, so all we need to do to fix it is to increase the minimum aho-corasick version, which we do here. We also add an oibits test that ensures this particular regression can't happen again. (Along with testing Send and Sync, which surprisingly did not have seem to have tests before this.) Fixes #568 --- CHANGELOG.md | 13 +++++++++++++ Cargo.toml | 2 +- tests/test_default.rs | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5497fc3229..975ee12d4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,16 @@ +1.1.4 (2019-03-31) +================== +This release fixes a backwards compatibility regression where Regex was no +longer UnwindSafe. This was caused by the upgrade to aho-corasick 0.7, whose +AhoCorasick type was itself not UnwindSafe. This has been fixed in aho-corasick +0.7.4, which we now require. + +Bug fixes: + +* [BUG #568](https://github.com/rust-lang/regex/pull/568): + Fix an API regression where Regex was no longer UnwindSafe. + + 1.1.3 (2019-03-30) ================== This releases fixes a few bugs and adds a performance improvement when a regex diff --git a/Cargo.toml b/Cargo.toml index 4cf51a4999..16b34982bc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,7 @@ members = [ [dependencies] # For very fast prefix literal matching. -aho-corasick = "0.7.1" +aho-corasick = "0.7.3" # For skipping along search text quickly when a leading byte is known. memchr = "2.0.2" # For managing regex caches quickly across multiple threads. diff --git a/tests/test_default.rs b/tests/test_default.rs index 0f8a0c2dba..cff213b63c 100644 --- a/tests/test_default.rs +++ b/tests/test_default.rs @@ -85,3 +85,37 @@ fn disallow_octal() { fn allow_octal() { assert!(regex::RegexBuilder::new(r"\0").octal(true).build().is_ok()); } + +#[test] +fn oibits() { + use std::panic::UnwindSafe; + use regex::{Regex, RegexBuilder}; + use regex::bytes; + + fn assert_send() {} + fn assert_sync() {} + fn assert_unwind_safe() {} + + assert_send::(); + assert_sync::(); + assert_unwind_safe::(); + assert_send::(); + assert_sync::(); + assert_unwind_safe::(); + + assert_send::(); + assert_sync::(); + assert_unwind_safe::(); + assert_send::(); + assert_sync::(); + assert_unwind_safe::(); +} + +// See: https://github.com/rust-lang/regex/issues/568 +#[test] +fn oibits_regression() { + use std::panic; + use regex::Regex; + + let _ = panic::catch_unwind(|| Regex::new("a").unwrap()); +}