alignment of thread-local storage

dt71 at gmx.com dt71 at gmx.com
Wed Nov 6 06:50:23 UTC 2013


Konstantin Belousov wrote, On 11/06/2013 03:33:
> On Wed, Nov 06, 2013 at 02:42:29AM +0100, dt71 at gmx.com wrote:
>> Starting with revision 191847 of Clang/LLVM, a bus error tends to happen in realloc() under special circumstances.
>>
> As I understand, the rev. of clang referenced is higher than what we have
> in src/contrib, right ?

Correct.

>> - The __jemalloc_thread_allocated_tls variable is updated using a processor instruction that requires alignment (paddq), that is, as of Clang/LLVM r191847. The variable is defined as:
>> __thread thread_allocated_t __attribute__((tls_model("initial-exec"))) thread_allocated_tls = {0,0};
>>
>> - The variable turns out to be insufficiently aligned, having only 4-byte alignment.
>
> I do not see anything in the jemalloc sources which indicate that
> thread_allocated must be 16-bytes aligned. The natural aligment for the
> structure is 8 bytes.

Which is still strictly more than the actual alignment (8 vs 4).

Clang even attempts to use certain vector-instructions or what, so it supposedly increases its alignment-request appropriately.


More information about the freebsd-hackers mailing list