Dataset Viewer
Auto-converted to Parquet Duplicate
created_at
stringlengths
20
20
instance_id
stringlengths
19
21
repo
stringclasses
1 value
test_patch
stringlengths
407
699k
issue_numbers
sequencelengths
1
3
base_commit
stringlengths
40
40
patch
stringlengths
473
11.4M
pull_number
int64
19
1.11k
problem_statement
stringlengths
84
7.1k
version
stringlengths
3
4
hints_text
stringlengths
0
30.7k
environment_setup_commit
stringlengths
40
40
2023-10-16T14:23:23Z
rust-lang__regex-1111
rust-lang/regex
diff --git a/testdata/regression.toml b/testdata/regression.toml index 2954c9118..53b0701a3 100644 --- a/testdata/regression.toml +++ b/testdata/regression.toml @@ -813,3 +813,18 @@ name = "hir-optimization-out-of-order-class" regex = '^[[:alnum:]./-]+$' haystack = "a-b" matches = [[0, 3]] + +# This is a regression test for an improper reverse suffix optimization. This +# occurred when I "broadened" the applicability of the optimization to include +# multiple possible literal suffixes instead of only sticking to a non-empty +# longest common suffix. It turns out that, at least given how the reverse +# suffix optimization works, we need to stick to the longest common suffix for +# now. +# +# See: https://github.com/rust-lang/regex/issues/1110 +# See also: https://github.com/astral-sh/ruff/pull/7980 +[[test]] +name = 'improper-reverse-suffix-optimization' +regex = '(\\N\{[^}]+})|([{}])' +haystack = 'hiya \N{snowman} bye' +matches = [[[5, 16], [5, 16], []]]
[ "1110" ]
e7bd19dd3ebf4b1a861275f0353202bf93a39ab1
diff --git a/regex-automata/src/meta/strategy.rs b/regex-automata/src/meta/strategy.rs index 4cb3b29b9..04f2ba3c3 100644 --- a/regex-automata/src/meta/strategy.rs +++ b/regex-automata/src/meta/strategy.rs @@ -1167,21 +1167,34 @@ impl ReverseSuffix { return Err(core); } let kind = core.info.config().get_match_kind(); - let suffixseq = crate::util::prefilter::suffixes(kind, hirs); - let Some(suffixes) = suffixseq.literals() else { - debug!( - "skipping reverse suffix optimization because \ - the extract suffix sequence is not finite", - ); - return Err(core); + let suffixes = crate::util::prefilter::suffixes(kind, hirs); + let lcs = match suffixes.longest_common_suffix() { + None => { + debug!( + "skipping reverse suffix optimization because \ + a longest common suffix could not be found", + ); + return Err(core); + } + Some(lcs) if lcs.is_empty() => { + debug!( + "skipping reverse suffix optimization because \ + the longest common suffix is the empty string", + ); + return Err(core); + } + Some(lcs) => lcs, }; - let Some(pre) = Prefilter::new(kind, suffixes) else { - debug!( - "skipping reverse suffix optimization because \ + let pre = match Prefilter::new(kind, &[lcs]) { + Some(pre) => pre, + None => { + debug!( + "skipping reverse suffix optimization because \ a prefilter could not be constructed from the \ longest common suffix", - ); - return Err(core); + ); + return Err(core); + } }; if !pre.is_fast() { debug!( @@ -1268,7 +1281,7 @@ impl ReverseSuffix { e.try_search_half_rev_limited(&input, min_start) } else if let Some(e) = self.core.hybrid.get(&input) { trace!( - "using lazy DFA for reverse inner search at {:?}, \ + "using lazy DFA for reverse suffix search at {:?}, \ but will be stopped at {} to avoid quadratic behavior", input.get_span(), min_start,
1,111
broadening of reverse suffix optimization has led to incorrect matches Specifically, this program succeeds in `regex 1.9.x` but fails in `regex 1.10.1`: ```rust fn main() -> anyhow::Result<()> { let re = regex::Regex::new(r"(\\N\{[^}]+})|([{}])").unwrap(); let hay = r#"hiya \N{snowman} bye"#; let matches = re.find_iter(hay).map(|m| m.range()).collect::<Vec<_>>(); assert_eq!(matches, vec![5..16]); Ok(()) } ``` Its output with `1.10.1`: ``` $ cargo run -q thread 'main' panicked at main.rs:7:5: assertion `left == right` failed left: [7..8, 15..16] right: [5..16] note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ``` I believe the issue here was my change to broaden the reverse suffix optimization to use one of many possible literals. But this turns out to be not be quite correct since the rules that govern prefixes don't apply to suffixes. In this case, the literal optimization extracts `{` and `}` as suffixes. It looks for a `{` first and finds a match at that position via the second alternate in the regex. But this winds up missing the match that came before it with the first alternate since the `{` isn't a suffix of the first alternate. This is why we should, at least at present, only use this optimization when there is a non-empty longest common suffix. In that case, and only that case, we know that it is a suffix of every possible path through the regex. Thank you to @charliermarsh for finding this! See: https://github.com/astral-sh/ruff/pull/7980
1.10
e7bd19dd3ebf4b1a861275f0353202bf93a39ab1
2023-10-06T15:45:29Z
rust-lang__regex-1098
rust-lang/regex
"diff --git a/fuzz/regressions/clusterfuzz-testcase-minimized-ast_fuzz_match-5990349284442112 b/fuzz(...TRUNCATED)
[ "1047", "1043" ]
17284451f10aa06c6c42e622e3529b98513901a8
"diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml\nindex 08cc60d9a8..2813a16763 1006(...TRUNCATED)
1,098
"internal error when translating Ast to Hir\n#### What version of regex are you using?\r\n\r\nregex-(...TRUNCATED)
1.9
17284451f10aa06c6c42e622e3529b98513901a8
2023-08-26T12:53:23Z
rust-lang__regex-1072
rust-lang/regex
"diff --git a/testdata/regression.toml b/testdata/regression.toml\nindex a2efa2ad3..03b15d6d5 100644(...TRUNCATED)
[ "1070" ]
7536e055840f74f1f7bda8ffecf851cb3e500147
"diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml\nindex 25df2b301..2035178a4 100644(...TRUNCATED)
1,072
"RegexSet and Regex give different results for the same pattern in 1.9\n#### What version of regex a(...TRUNCATED)
1.9
17284451f10aa06c6c42e622e3529b98513901a8
2023-08-05T21:38:26Z
rust-lang__regex-1063
rust-lang/regex
"diff --git a/testdata/regression.toml b/testdata/regression.toml\nindex bb5e4fd46..a2efa2ad3 100644(...TRUNCATED)
[ "1060" ]
bbf0b38df618734b92d7b92acc8a8bf31b6d0046
"diff --git a/regex-automata/src/meta/limited.rs b/regex-automata/src/meta/limited.rs\nindex 005878a(...TRUNCATED)
1,063
"reverse inner literal optimization results in incorrect match offsets in some cases\n#### What vers(...TRUNCATED)
1.9
"CLI reproduction:\r\n\r\n```\r\n$ regex-cli find match meta -p '(?:(\\d+)[:.])?(\\d{1,2})[:.](\\d{2(...TRUNCATED)
17284451f10aa06c6c42e622e3529b98513901a8
2023-07-12T13:56:35Z
rust-lang__regex-1038
rust-lang/regex
"diff --git a/testdata/anchored.toml b/testdata/anchored.toml\nindex cca561de1..0f2248d09 100644\n--(...TRUNCATED)
[ "1036", "1036" ]
bbb285b81fd1108536eedc52990a95f30ca6bdf5
"diff --git a/regex-automata/src/meta/strategy.rs b/regex-automata/src/meta/strategy.rs\nindex 2de2c(...TRUNCATED)
1,038
"Anchored search with reverse suffix strategy does not work\n#### What version of regex are you usin(...TRUNCATED)
1.9
17284451f10aa06c6c42e622e3529b98513901a8
2023-05-25T15:45:45Z
rust-lang__regex-1000
rust-lang/regex
"diff --git a/tests/regression.rs b/tests/regression.rs\nindex 1ff4cba9f..291062a77 100644\n--- a/te(...TRUNCATED)
[ "999" ]
d555d6122d1d1a354c45361d029571413beca8ef
"diff --git a/src/exec.rs b/src/exec.rs\nindex c449b38cf..ee8b589d2 100644\n--- a/src/exec.rs\n+++ b(...TRUNCATED)
1,000
"regex with many literal alternates can erroneously match the empty string\nThis program panics:\r\n(...TRUNCATED)
1.8
This was originally reported via ripgrep: https://github.com/rust-lang/regex/issues/999
d555d6122d1d1a354c45361d029571413beca8ef
2023-05-22T21:31:35Z
rust-lang__regex-996
rust-lang/regex
"diff --git a/tests/regression.rs b/tests/regression.rs\nindex e24fecbc5..1ff4cba9f 100644\n--- a/te(...TRUNCATED)
[ "995" ]
65ec58cbd4dd9a0fcfa0823876b7dd0bb1736bd1
"diff --git a/regex-syntax/src/hir/mod.rs b/regex-syntax/src/hir/mod.rs\nindex e5ea3701b..062d4dcab (...TRUNCATED)
996
"integer overflow on a particular regex\n#### What version of regex are you using?\r\n\r\n1.8.1 (lat(...TRUNCATED)
1.8
d555d6122d1d1a354c45361d029571413beca8ef
2023-04-21T11:29:01Z
rust-lang__regex-984
rust-lang/regex
"diff --git a/tests/regression.rs b/tests/regression.rs\nindex e8b252538..e24fecbc5 100644\n--- a/te(...TRUNCATED)
[ "981" ]
93316a3b1adc43cc12fab6c73a59f646658cd984
"diff --git a/regex-syntax/src/hir/mod.rs b/regex-syntax/src/hir/mod.rs\nindex bdf2fb2c6..e5ea3701b (...TRUNCATED)
984
"Regex matching changed in 1.8.0\n#### What version of regex are you using?\r\n\r\nThis appears to b(...TRUNCATED)
1.8
d555d6122d1d1a354c45361d029571413beca8ef
2023-04-18T18:52:44Z
rust-lang__regex-978
rust-lang/regex
"diff --git a/regex-automata/test b/regex-automata/test\nnew file mode 100755\nindex 0000000000..df3(...TRUNCATED)
[ "656" ]
1d9ce15402aa176542f9ec10285a70584855f83c
"diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml\nindex bacb4b0873..25df2b3014 1006(...TRUNCATED)
978
"plan: moving regex engines to regex-automata\nIn discussions in #524, it became clearer to me that (...TRUNCATED)
1.8
"You probably already plan to do something like this, but just in case you have not already planned (...TRUNCATED)
d555d6122d1d1a354c45361d029571413beca8ef
2023-04-17T18:35:26Z
rust-lang__regex-977
rust-lang/regex
"diff --git a/regex-syntax/test b/regex-syntax/test\nindex 4b1b9fb1a9..a4d6cfaba5 100755\n--- a/rege(...TRUNCATED)
[ "547", "975" ]
fd1d95b1bd15db8a31efa82585a1842ad34091f1
"diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml\nindex 5171d79363..bacb4b0873 1006(...TRUNCATED)
977
"Missing method Regex::captures_at\nThe `Regex` type has `_at` variants of most searching methods, e(...TRUNCATED)
1.7
"It wasn't an oversight. The intent was for folks to use [`captures_read_at`](https://docs.rs/regex/(...TRUNCATED)
fd1d95b1bd15db8a31efa82585a1842ad34091f1
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
1