[Pkg-erlang-devel] Bug#939804: Bug#939804: erlang: FTBFS on hppa - escript: exception error: bad argument
Sergei Golovan
sgolovan at gmail.com
Mon Sep 9 14:12:14 BST 2019
Hi John,
On Mon, Sep 9, 2019 at 2:13 PM John David Anglin <dave.anglin at 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.
Unfortunately, I don't know anything about stack in hppa architecture,
so I can't offer
a proper fix in this case.
I hope this'll help in debugging and developing a fix.
Cheers!
--
Sergei Golovan
More information about the Pkg-erlang-devel
mailing list