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

Do not use @[ThreadLocal] for PCRE2's JIT stack #13056

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/regex/pcre2.cr
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,12 @@ module Regex::PCRE2
#
# Only a single `match` function can run per thread at any given time, so there
# can't be any concurrent access to the JIT stack.
@[ThreadLocal]
class_getter jit_stack : LibPCRE2::JITStack do
jit_stack = LibPCRE2.jit_stack_create(32_768, 1_048_576, Regex::PCRE2.general_context)
if jit_stack.null?
raise "Error allocating JIT stack"
@@jit_stack = Crystal::ThreadLocalValue(LibPCRE2::JITStack).new

def self.jit_stack
@@jit_stack.get do
LibPCRE2.jit_stack_create(32_768, 1_048_576, general_context) || raise "Error allocating JIT stack"
end
jit_stack
end

private def match_data(str, byte_index, options)
Expand Down