[Pkg-erlang-devel] Bug#939804: Bug#939804: erlang: FTBFS on hppa - escript: exception error: bad argument

John David Anglin dave.anglin at bell.net
Thu Sep 12 02:29:08 BST 2019


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;
>
> 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.
The patch fixes the build.

Thanks,
Dave

-- 
John David Anglin  dave.anglin at bell.net



More information about the Pkg-erlang-devel mailing list