-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Bounds exception when using deepcopy with regex #31260
Comments
While inspecting the Regex/PCRE code, I also noticed that the call to |
Is it actually meaningful to copy a regex, or could we make |
@JeffBezanson Dunno, what about multithreading, I can imagine people might be tempted to use |
This seems like it would be fine and the simplest solution to this, although it doesn't address the multithreading issue. But that issue would still exist anyway since multiple threads could have references to the same uncopied regex object, which means that if we want to make regexes threadsafe, we'd either need to put a mutex around the use of |
Is this already fixed? julia> match(deepcopy(r""), "")
RegexMatch("") |
Well, I was experimenting for this issue, and I found out for |
Depends on what you think "deepcopy" should mean. There's bits of internal state (mostly write-once/immutable), and an allocation cache (mutable) inside. But otoh, there's no |
I think the issue is often with types that have a |
As discussed on Slack with @StefanKarpinski and @vtjnash, the right fix is probably to provide an overload of
deepcopy_internal
forRegex
which makes a copy of the underlying PCRE object, ideally through the PCRE API if such functionality exists.The text was updated successfully, but these errors were encountered: