Fix a catastrophic backtracking bug in JavaLexer#1594
Fix a catastrophic backtracking bug in JavaLexer#1594Anteru merged 2 commits intopygments:masterfrom
Conversation
|
Thanks! High time we add |
If it's okay with you and Georg, I'll work on a patch to add Let me know if that's something you'd like me to tackle. =) |
|
I have no objection, and given Georg didn't red flag it, I'd say please go ahead. It's fairly obvious to me by now that backtracking needs robust testing, and I don't see how we can do it without timeouts. |
|
Okay, then I'll create a ticket for tracking and discussion and submit a patch for review.
|
|
Sure, I'd just like a graceful behavior if the timeout plugin isn't installed. |
|
Understood. I anticipate that I'll add it as a dependency in tox so that it's guaranteed to be available when running the tests.
|
|
By the way, I just tested the pytest timeout plugin. It supports a thread-based and a signal-based method. On Windows, which only supports thread-based timeouts, the plugin is unable to interrupt catastrophic backtracking like this: import re
def test_catastrophic_backtracking():
re.search(r'\d+\d+a', '0' * 10_000)The thread-based timeouts can successfully interrupt operations like |
This closes #1586, which triggered the bug.
This patch addresses the problem by replacing the string literal regex with a sub-state for string literal parsing.