Question about alignment of struct _Unwind_Exception

Matheus Castanho msc@linux.ibm.com
Wed Nov 4 13:10:07 GMT 2020


+CC: bergner@linux.ibm.com

On 11/4/20 9:44 AM, Matheus Castanho via Libc-alpha wrote:
> Hi,
> 
> Recently I've been investigating an issue with an invalid TLS access on
> powerpc64le when __libc_malloc tries to read SINGLE_THREAD_P [1]. The
> issue could only be reproduced when using a glibc compiled with
> -mcpu=power10. We found out that the size of 'struct pthread' was
> changing between compiling with -mcpu=power9 and -mcpu=power10.
> 
> After inspecting that struct we found out that one specific field was
> changing sizes:
> 	struct _Unwind_Exception exc;
> 
> That struct is declared without a fixed alignment value:
> 
> struct _Unwind_Exception
> {
>   _Unwind_Exception_Class exception_class;
>   _Unwind_Exception_Cleanup_Fn exception_cleanup;
>   _Unwind_Word private_1;
>   _Unwind_Word private_2;
>   /* @@@ The IA-64 ABI says that this structure must be double-word aligned.
>      Taking that literally does not make much sense generically.  Instead we
>      provide the maximum alignment required by any type for the machine.  */
> } __attribute__((__aligned__));
> 
> The GCC manual says [2]:
> 
>> Specifying no alignment argument implies the maximum alignment for the
> target
> 
> The maximum alignment has been recently increased for P10, which we
> suspect is causing the behavior we see.
> 
> Is there an specific reason why a fixed alignment value was not used for
> struct _Unwind_Exception?
> 
> [1] https://github.com/advancetoolchain/advance-toolchain/issues/1780
> [2]
> https://gcc.gnu.org/onlinedocs/gcc-10.1.0/gcc/Common-Variable-Attributes.html#Common-Variable-Attributes
> 
> Thanks,
> Matheus Castanho
> 


More information about the Libc-alpha mailing list