[Issue 19481] Aborting from local/libphobos/libdruntime/core/sync/mutex.d(95) Error: pthread_mutex_init failed.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Dec 12 20:28:24 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=19481

Iain Buclaw <ibuclaw at gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ibuclaw at gdcproject.org

--- Comment #2 from Iain Buclaw <ibuclaw at gdcproject.org> ---
(In reply to kinke from comment #1)
> `Mutex.m_hndl.alignof` (as it's a CRITICAL_SECTION for Windows) doesn't
> work, as it's private.
> 

I was thinking of just doing as a quick hack.

---
version (Windows)
{
    import core.sys.windows.winbase : CRITICAL_SECTION;
    enum Mutex_alignof = CRITICAL_SECTION.alignof;
}
else version (Posix)
{
    import core.sys.posix.sys.types : pthread_mutex_t;
    enum Mutex_alignof = pthread_mutex_t.alignof;
}
---


Alternatively...

class Mutex
{
  enum alignsize = Mutex.m_hndl.alignof;
  // ...
}


> There's no way to get the class instance alignment, is there? Plus anything
> > 16 bytes isn't guaranteed by the GC either AFAIK. So class alignments seem
> a bit problematic in general.

No, there isn't a way to do that.  I'm currently waiting to hear back if
explicitly setting the alignment to 8 fixes the failure on SPARC/Solaris.

--


More information about the Digitalmars-d-bugs mailing list