[Pkg-erlang-devel] Bug#939804: Bug#939804: erlang: FTBFS on hppa - escript: exception error: bad argument
John David Anglin
dave.anglin at bell.net
Wed Sep 11 12:47:05 BST 2019
On 2019-09-09 9:12 a.m., Sergei Golovan wrote:
> # 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)
The above check is wrong. ERTS_STACK_LIMIT is always NULL here resulting in stack_guard_downwards
always being selected. erts_init_bif_re is called before the stack limit is set. Think we need a different
stack direction check.
> 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.
Dave
--
John David Anglin dave.anglin at bell.net
More information about the Pkg-erlang-devel
mailing list