On Wed, Dec 26, 2018 at 7:39 AM Cherry Zhang <cherr...@google.com> wrote:
>
> Finally I found an ARM machine and was able to build ARM32 gcc on it, and 
> reproduced the failures. The Go programs aborted, in parse_lsda_header, 
> called from probestackmaps in the runtime startup. It seems that 
> _Unwind_GetLanguageSpecificData doesn't return a valid LSDA when called from 
> a callback from _Unwind_Backtrace.
>
> Reading the unwinder's source code in libgcc, it seems that a function may 
> have a "predefined" personality function, and in this case an ARM-specific 
> "compact" model is used, which doesn't use the standard LSDA. 
> _Unwind_GetLanguageSpecificData doesn't distinguish this and simply assumes 
> the "generic" model is used, i.e. not used with a "predefined" personality 
> function. This works fine if _Unwind_GetLanguageSpecificData is called from a 
> non-predefined personality function, but it doesn't work if it is called 
> during _Unwind_Backtrace.
>
> The patch below (also CL 
> https://go-review.googlesource.com/c/gofrontend/+/155758) will fix the 
> problem, by checking which model is used before calling 
> _Unwind_GetLanguageSpecificData.
>
> Alternatively, we could change _Unwind_GetLanguageSpecificData in libgcc to 
> returning NULL when a predefined personality function is used.
>
> Let me know what you think.
>
> Thanks,
> Cherry
>
> diff --git a/libgo/runtime/go-unwind.c b/libgo/runtime/go-unwind.c
> index f4bbfb60..388d7c70 100644
> --- a/libgo/runtime/go-unwind.c
> +++ b/libgo/runtime/go-unwind.c
> @@ -646,6 +646,17 @@ findstackmaps (struct _Unwind_Context *context, 
> _Unwind_Ptr *ip, _Unwind_Ptr *sp
>    _sleb128_t index;
>    int size;
>
> +#ifdef __ARM_EABI_UNWINDER__
> +  {
> +    _Unwind_Control_Block *ucbp;
> +    ucbp = (_Unwind_Control_Block *) _Unwind_GetGR (context, 12);
> +    if (*ucbp->pr_cache.ehtp & (1u << 31))
> +      // The "compact" model is used, with one of the predefined
> +      // personality functions. It doesn't have standard LSDA.
> +      return NOTFOUND_OK;
> +  }
> +#endif
> +
>    language_specific_data = (const unsigned char *)
>      _Unwind_GetLanguageSpecificData (context);
>

Thanks.

Committed to mainline.

Ian

Reply via email to