https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88462

--- Comment #11 from ro at CeBiTec dot Uni-Bielefeld.DE <ro at CeBiTec dot 
Uni-Bielefeld.DE> ---
> --- Comment #10 from Johannes Pfau <johannespfau at gmail dot com> ---
> I guess the proper fix to the alignment problem is using
> 'https://dlang.org/phobos/std_traits.html#classInstanceAlignment' (or rather
> the druntime equivalent) instead of Mutex.alignof + the rounding / slice
> assignment fixes?

Seems plausible: the current situation is nothing more than a hack to
get me further along, and I've only just started reading up on D.

> Regarding the ModuleInfo problem: Although ModuleInfo does have a variable
> size, _flags ist the first field in the struct. So the whole struct instance
> has to be misaligned for some reason? Is the minfo section aligned properly?

It is: both minfo sections on libgdruntime.so and libgphobos.so are:

libdruntime/.libs/libgdruntime.so:


Section Header[28]:  sh_name: minfo
    sh_addr:      0x17b834        sh_flags:   [ SHF_WRITE SHF_ALLOC ]
    sh_size:      0x344           sh_type:    [ SHT_PROGBITS ]
    sh_offset:    0x16b834        sh_entsize: 0
    sh_link:      0               sh_info:    0
    sh_addralign: 0x4       

src/.libs/libgphobos.so:


Section Header[28]:  sh_name: minfo
    sh_addr:      0x6ff014        sh_flags:   [ SHF_WRITE SHF_ALLOC ]
    sh_size:      0x224           sh_type:    [ SHT_PROGBITS ]
    sh_offset:    0x6ef014        sh_entsize: 0
    sh_link:      0               sh_info:    0
    sh_addralign: 0x4       

And looking at a statically linked test program (gdc283.exe), I see

Thread 2 received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1 (LWP 1)]
0x0007c970 in object.ModuleInfo.flags() const (this=...)
    at /vol/gcc/src/hg/trunk/solaris/libphobos/libdruntime/object.d:1541
1541        @property uint flags() nothrow pure @nogc { return _flags; }
(gdb) p this
$1 = (const object.ModuleInfo &) @0x12ab33: {_flags = 4100, _index = 0}
(gdb) up
#1  0x0007d118 in object.ModuleInfo.importedModules() const (this=...)
    at /vol/gcc/src/hg/trunk/solaris/libphobos/libdruntime/object.d:1580
1580            if (flags & MIimportedModules)
(gdb) up
#2  0x0008ed74 in rt.minfo.ModuleGroup.sortCtors(immutable(char)[]) (this=..., 
    cycleHandling=...)
    at /vol/gcc/src/hg/trunk/solaris/libphobos/libdruntime/rt/minfo.d:259
259                     foreach (imp; m.importedModules)
(gdb) p this
$2 = (rt.minfo.ModuleGroup &) @0x12f228: {_modules = {
      0x12932c <ModuleInfo for gdc283>, 
      0x1297ac <ModuleInfo for core.exception>, 
      0x129acc <ModuleInfo for gcc.deh>, 
      0x129ae4 <ModuleInfo for gcc.unwind.pe>, 
      0x12a99c <ModuleInfo for object>, 0x12aafc <ModuleInfo for rt.aaA>, 
      0x12ab33 <ModuleInfo for rt.adi>, 0x12ab42 <ModuleInfo for rt.arraycat>, 
      0x12ab56 <ModuleInfo for rt.cast_>, 0x12ab67 <ModuleInfo for rt.deh>, 
      0x12ab77 <ModuleInfo for rt.dmain2>, 
      0x12ab89 <ModuleInfo for invariant>, 

i.e. everything starts off alright, but goes astray from 0x12ab33
<ModuleInfo for rt.adi> onwards.

Reply via email to