https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88462
Bug ID: 88462 Summary: All D execution tests FAIL on Solaris/SPARC Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: d Assignee: ibuclaw at gdcproject dot org Reporter: ro at gcc dot gnu.org Target Milestone: --- Target: sparc*-sun-solaris2.* Even with the latest patch for PR d/88150 to use sections_elf_shared.d on Solaris, which allows the vast majority of gdc execution tests to PASS on Solaris 11.4/x86, I have no such luck on Solaris 11.5/SPARC: all tests FAIL with Aborting from local/libphobos/libdruntime/core/sync/mutex.d(95) Error: pthread_mutex_init failed. Thread 2 received signal SIGABRT, Aborted. [Switching to Thread 1 (LWP 1)] 0xfec7e044 in __lwp_sigqueue () from /lib/libc.so.1 (gdb) where #0 0xfec7e044 in __lwp_sigqueue () from /lib/libc.so.1 #1 0xfebb9898 in raise () from /lib/libc.so.1 #2 0xfeb8b1d0 in abort () from /lib/libc.so.1 #3 0x000c150c in core.internal.abort.abort(immutable(char)[], immutable(char)[], uint) (msg=..., filename=<error reading variable: Cannot access memory at address 0x5f>, line=95) at /vol/gcc/src/hg/trunk/solaris/libphobos/libdruntime/core/internal/abort.d:44 #4 0x000fe32c in core.sync.mutex.Mutex.this!(core.sync.mutex.Mutex).this(bool) (this=0x12de34 <core.thread.Thread._locks+44>, _unused_=true) at /vol/gcc/src/hg/trunk/solaris/libphobos/libdruntime/core/sync/mutex.d:94 #5 0x000fdeac in core.sync.mutex.Mutex.this() ( this=0x12de34 <core.thread.Thread._locks+44>) at /vol/gcc/src/hg/trunk/solaris/libphobos/libdruntime/core/sync/mutex.d:63 #6 0x000c64d0 in core.thread.Thread.initLocks() () at /vol/gcc/src/hg/trunk/solaris/libphobos/libdruntime/core/thread.d:1726 #7 0x000c69d8 in thread_init () at /vol/gcc/src/hg/trunk/solaris/libphobos/libdruntime/core/thread.d:2022 #8 0x000a232c in gc_init () at /vol/gcc/src/hg/trunk/solaris/libphobos/libdruntime/gc/proxy.d:56 #9 0x00080684 in rt_init () at /vol/gcc/src/hg/trunk/solaris/libphobos/libdruntime/rt/dmain2.d:187 #10 0x000810c8 in runAll (this=0xffbfe904) at /vol/gcc/src/hg/trunk/solaris/libphobos/libdruntime/rt/dmain2.d:485 #11 0x00081020 in tryExec (this=0xffbfe904, dg=...) at /vol/gcc/src/hg/trunk/solaris/libphobos/libdruntime/rt/dmain2.d:461 #12 0x00080f2c in _d_run_main (argc=1, argv=0xffbfea34, mainFunc=0x6b2bc <D main>) at /vol/gcc/src/hg/trunk/solaris/libphobos/libdruntime/rt/dmain2.d:494 #13 0x0006b24c in main (argc=1, argv=0xffbfea34) at /vol/gcc/src/hg/trunk/solaris/libphobos/libdruntime/__entrypoint.di:44 #14 0x0006b014 in _start () Backtrace stopped: previous frame identical to this frame (corrupt stack?) !pthread_mutex_init(cast(pthread_mutex_t*) &m_hndl, &attr) || abort("Error: pthread_mutex_init failed."); After much digging and head scratching, I found what's wrong: pthread_mutex_init expects the mutex to be long long (i.e. 8 byte) aligned. I'd thought this would happen automatically given the declaration in core/sys/posix/sys/types.d with the ulong __pthread_mutex_data field which has a natural alignment of 64 bits. Whatever I do, however, I only end up with the mutex being 4-byte aligned: * apply align(8): at the beginning of the pthread_mutex_t fields, * apply align(8) to the struct pthread_mutex_t declaration, or * apply align(8) to the m_hndl member of Class Mutex in core/sync/mutex.d. To guard against incomplete dependencies that could lead to some parts not being recompiled when they should, I've always recompiled all of libphobos to be sure I didn't miss something. I've no idea what I'm doing wrong here.