On 2019-09-09 9:12 a.m., Sergei Golovan wrote: > Hi John, > > On Mon, Sep 9, 2019 at 2:13 PM John David Anglin <dave.ang...@bell.net> wrote: >> If you know how to reduce one of these regexp problems, I could look again. >> Debugging >> across forks is problematic (i.e., the error doesn't occur in escript). > I seem to find the problematic code. If you look into > erts/emulator/beam/erl_bif_re.c then > you'll find the following lines after line 66: > > #define ERTS_PCRE_STACK_MARGIN (10*1024) > > # define ERTS_STACK_LIMIT ((char *) ethr_get_stacklimit()) > > static int > stack_guard_downwards(void) > { > char *limit = ERTS_STACK_LIMIT; > char c; > > ASSERT(limit); > > return erts_check_below_limit(&c, limit + ERTS_PCRE_STACK_MARGIN); > } > > static int > stack_guard_upwards(void) > { > char *limit = ERTS_STACK_LIMIT; > char c; > > ASSERT(limit); > > return erts_check_above_limit(&c, limit - ERTS_PCRE_STACK_MARGIN); > } > > void erts_init_bif_re(void) > { > char c; > erts_pcre_malloc = &erts_erts_pcre_malloc; > 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) > erts_pcre_stack_guard = stack_guard_downwards; > else > erts_pcre_stack_guard = stack_guard_upwards; > default_table = NULL; /* ISO8859-1 default, forced into pcre */ > max_loop_limit = CONTEXT_REDS * LOOP_FACTOR; > > erts_init_trap_export(&re_exec_trap_export, am_erlang, am_re_run_trap, 3, > &re_exec_trap); > > grun_trap_exportp = erts_export_put(am_re,am_grun,3); > urun_trap_exportp = erts_export_put(am_re,am_urun,3); > ucompile_trap_exportp = erts_export_put(am_re,am_ucompile,2); > > return; > } > > The code > > if ((char *) erts_ptr_id(&c) > ERTS_STACK_LIMIT) > erts_pcre_stack_guard = stack_guard_downwards; > else > erts_pcre_stack_guard = stack_guard_upwards; > > has been introduces in version 20, and it is used to protect stack > during PCRE calls. > It seems that this stack protection doesn't work for hppa and always > fails. As a result, > every call to a regexp routine fails. > > After I remove the erts_pcre_stack_guard assignment, Erlang started to > build on hppa > just fine. > I added some printfs to the code.
thr_wrapper: stacksize=0x0 thr_wrapper: stacksize=0x0 thr_wrapper: stacksize=0x0 thr_wrapper: stacksize=0x10000 thr_wrapper: stacksize=0x10000 thr_wrapper: stacksize=0x10000 erts_init_bif_re: &c=0xf9730748 ERTS STACK LIMIT=0x0 erts_init_bif_re: &c=0xf9df6748 ERTS STACK LIMIT=0x0 erts_init_bif_re: &c=0xf90b0748 ERTS STACK LIMIT=0x0 erts_init_bif_re: &c=0xf908c748 ERTS STACK LIMIT=0x0 thr_wrapper: stacksize=0x80000 thr_wrapper: stacksize=0x80000 thr_wrapper: stacksize=0x80000 thr_wrapper: stacksize=0x80000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x80000 thr_wrapper: stacksize=0x80000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x80000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x80000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x80000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x80000 thr_wrapper: stacksize=0x80000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x80000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x80000 thr_wrapper: stacksize=0x80000 thr_wrapper: stacksize=0x80000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x80000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 thr_wrapper: stacksize=0x28000 stack_guard_downwards: &c=0xf7778b08 limit=0xf77f7000 ERTS STACK LIMIT=0x2800 stack_guard_downwards: &c=0xf787eb08 limit=0xf78fd000 ERTS STACK LIMIT=0x2800 stack_guard_downwards: &c=0xf787eb08 limit=0xf78fd000 ERTS STACK LIMIT=0x2800 stack_guard_downwards: &c=0xf77fbb08 limit=0xf787a000 ERTS STACK LIMIT=0x2800 escript: exception error: bad argument in function re:split/3 called as re:split(<<"<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<!DOCTYPE comref SYSTEM \"comref.dtd\">\n\n<comref>\n <header>\n <copyright>\n <year>1996</year><year>2016</year>\n <holder>Ericsson AB. All Right"...>>, "\n",[]) make[1]: *** [/home/dave/debian/erlang/erlang-22.0.7+dfsg/make/otp_release_targets.mk:47: ../xml/epmd.xml] Error 127 make[1]: *** Waiting for unfinished jobs.... It would seem to me that ERTS_STACK_LIMIT is incorrect. As a result, stack_guard_downwards is called instead of stack_guard_upwards. It's also a bit odd that twd->stacksize in thr_wrapper is sometimes 0. Think ethr_thr_create needs looking at. Dave -- John David Anglin dave.ang...@bell.net