Re: assertion "ALIGNED_P(offset, obj->tlsalign)" failed: file "/usr/src/libexec/ld.elf_so/tls.c", line 549

Robert Elz <[email protected]> Wed, 22 Jul 2026 16:39:33 +0700
Newsgroups gmane.os.netbsd.current
Message-ID <[email protected]>
    Date:        Wed, 22 Jul 2026 10:57:52 +0200
    From:        Martin Husemann <[email protected]>
    Message-ID:  <[email protected]>

  | I can reproduce it on 32bit arm too.

I think I see what is happening, and it is just this (new) assertion
which is the issue.

From the comments, I suspect that arm hosts are ones which
have __HAVE_TLS_VARIANT_I defined, and do not have __HAVE___LWP_GETTCB_FAST

So, it runs this piece of code:

        offset = roundup2(_rtld_tls_static_offset, obj->tlsalign);
        next_offset = offset + obj->tlssize;
	offset -= sizeof(struct tls_tcb);

	assert(ALIGNED_P(offset, obj->tlsalign));

offset will certainly be aligned after the first of those lines, the
second is irrelevant, but when the third happens, if sizeof(struct tls_tcb)
is not a multiple of obj->tlsalign, which it almost certainly isn't,
then BANG.

If you can, try just deleting the assert() and see what happens then.

kre