On 2019-09-11 7:21 a.m., Sergei Golovan wrote: > May be. As a quick fix I can suggest a separate check for the stack > direction in erl_bif_re.c, here's a patch. > > --- a/erts/emulator/beam/erl_bif_re.c > +++ b/erts/emulator/beam/erl_bif_re.c > @@ -90,6 +90,15 @@ > return erts_check_above_limit(&c, limit - ERTS_PCRE_STACK_MARGIN); > } > > +__attribute__((noinline)) static int stack_grows_downwards(char *prev_c) > +{ > + char c; > + if (&c < prev_c) > + return 1; > + else > + return 0; > +} > + > void erts_init_bif_re(void) > { > char c; > @@ -97,7 +106,7 @@ > erts_pcre_free = &erts_erts_pcre_free; > erts_pcre_stack_malloc = &erts_erts_pcre_stack_malloc; > erts_pcre_stack_free = &erts_erts_pcre_stack_free; > - if ((char *) erts_ptr_id(&c) > ERTS_STACK_LIMIT) > + if (stack_grows_downwards(&c)) > erts_pcre_stack_guard = stack_guard_downwards; > else > erts_pcre_stack_guard = stack_guard_upwards; Yes. Will try tonight. Have to run. > > I don't think it can be accepted upstream as a permanent fix though. I > think it'd > be better to fix the stack limit initialization somehow.
erts_init_bif_re needs to be called after stack limit is set in thr_wrapper. Thanks, Dave -- John David Anglin dave.ang...@bell.net