Re: [pcre-dev] A clarification on pcrejit docs

Páxina inicial
Borrar esta mensaxe
Autor: Zoltán Herczeg
Data:  
Para: Giuseppe D'Angelo
CC: pcre-dev
Asunto: Re: [pcre-dev] A clarification on pcrejit docs
Hi,

different names are intentional, although we probably should emphasize it more.

JIT stack: returned by pcre_jit_stack_alloc(). Must be freed by the user. When pcre_exec runs and uses a particular JIT stack, that must not be used by other threads until pcre_exec returns (user responsibility). You can directly assign a JIT stack to a pattern or return it through the callback. The JIT stack is used only during pcre_exec, never any other time.

machine stack: when a JIT stack is not assigned or the callback returns with NULL, a function is called which defines a local variable: pcre_uint8 local_area[LOCAL_SPACE_SIZE] This area is used by the JIT in this case. LOCAL_SPACE_SIZE is 32K by default. So this is thread safe.

As long as you keep the JIT stack usage rule above, PCRE JIT is completely thread safe. Otherwise you likely get a crash :)

Regards,
Zoltan

"Giuseppe D'Angelo" <dangelog@???> írta:
>The pcre_assign_jit_stack man page says that>

"If callback is NULL and data is NULL, an internal 32K block on the>
machine stack is used.">
>

And the pcrejit man page says that>
"When the compiled JIT code runs, it needs a block of memory to use as>
a stack. By default, it uses 32K on the machine stack">
>

This makes me think that it's perfectly safe to use the same pcre* and>
JIT-compiled pcre_extra* blocks in more threads at the same time,>
because the 32k block will be taken from each thread's stack (and>
these stacks are obviously different).>
>

However, the same pcrejit man page says that "In a multithread>
application, each thread must use its own JIT stack. " and even>
suggests creating JIT stacks and putting them in thread local storage.>
>

What's the right interpretation? :-)>
>

Cheers,>
-- >
Giuseppe D'Angelo>
>

-- >
## List details at https://lists.exim.org/mailman/listinfo/pcre-dev >