public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Matheus Castanho <msc@linux.ibm.com>
To: GNU C Library <libc-alpha@sourceware.org>
Cc: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>,
	bergner@linux.ibm.com
Subject: Question about alignment of struct _Unwind_Exception
Date: Wed, 4 Nov 2020 09:44:19 -0300	[thread overview]
Message-ID: <dd1b26d3-7025-97a7-c738-57c788790b02@linux.ibm.com> (raw)

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

             reply	other threads:[~2020-11-04 12:44 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-04 12:44 Matheus Castanho [this message]
2020-11-04 13:10 ` Matheus Castanho
2020-11-04 13:38 ` Florian Weimer
2020-11-04 19:07   ` Matheus Castanho
2020-11-04 19:25 ` Peter Bergner
2020-11-04 19:31   ` Florian Weimer
2020-11-06 23:16     ` Peter Bergner
2020-11-10 17:47       ` Matheus Castanho
2020-11-10 18:13         ` Florian Weimer
2020-11-10 19:53           ` Matheus Castanho
2020-11-11  9:27             ` Florian Weimer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dd1b26d3-7025-97a7-c738-57c788790b02@linux.ibm.com \
    --to=msc@linux.ibm.com \
    --cc=bergner@linux.ibm.com \
    --cc=libc-alpha@sourceware.org \
    --cc=tuliom@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).