Thread overview | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
December 12, 2018 [Issue 19481] Aborting from local/libphobos/libdruntime/core/sync/mutex.d(95) Error: pthread_mutex_init failed. | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19481 kinke@gmx.net changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kinke@gmx.net --- Comment #1 from kinke@gmx.net --- `Mutex.m_hndl.alignof` (as it's a CRITICAL_SECTION for Windows) doesn't work, as it's private. 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. -- |
December 12, 2018 [Issue 19481] Aborting from local/libphobos/libdruntime/core/sync/mutex.d(95) Error: pthread_mutex_init failed. | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19481 Iain Buclaw <ibuclaw@gdcproject.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ibuclaw@gdcproject.org --- Comment #2 from Iain Buclaw <ibuclaw@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. -- |
December 13, 2018 [Issue 19481] Aborting from local/libphobos/libdruntime/core/sync/mutex.d(95) Error: pthread_mutex_init failed. | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19481 --- Comment #3 from Iain Buclaw <ibuclaw@gdcproject.org> --- According to response, the alignment of _locks[0] is fine, _locks[1] is the problem. >>> Unfortunately, this doesn't work: the first time through, _locks[0] was already 8-byte aligned and everything worked fine. This remained when using align(8) instead. However, Mutex is 44 bytes on 32-bit Solaris/x86, so again _locks[1] lands on a non-8 byte boundary and pthread_mutex_init fails. I tried rouding up the size of the _locks array members to a multiple of 8, but that let the constructor already fail the first time through where _d_arraycopy checks that the right amount of data is copied: _d_arraycopy -> rt.util.array.enforceRawArraysConformable -> rt.util.array._enforceSameLength <<< -- |
December 13, 2018 [Issue 19481] Aborting from local/libphobos/libdruntime/core/sync/mutex.d(95) Error: pthread_mutex_init failed. | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19481 --- Comment #4 from kinke@gmx.net --- Argh, it's an array, and class instances aren't padded... - the error stems from the manual initialization in `initLocks()`, right? That should be easily adaptable; the ctor only gets the `this` pointer and shouldn't have any idea about the actual size. -- |
December 13, 2018 [Issue 19481] Aborting from local/libphobos/libdruntime/core/sync/mutex.d(95) Error: pthread_mutex_init failed. | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19481 --- Comment #5 from Iain Buclaw <ibuclaw@gdcproject.org> --- (In reply to kinke from comment #4) > Argh, it's an array, and class instances aren't padded... - the error stems from the manual initialization in `initLocks()`, right? That should be easily adaptable; the ctor only gets the `this` pointer and shouldn't have any idea about the actual size. Correct. This line: __gshared align(Mutex.alignof) void[__traits(classInstanceSize, Mutex)][2] _locks; The size should be rounded up to a suitable align boundary, then this line: lock[] = typeid(Mutex).initializer[]; The slice assignment is adjusted to only initialize up to __traits(classInstanceSize, Mutex). So we end up with something that looks like: --- version (Windows) { import core.sys.windows.winbase : CRITICAL_SECTION; enum lockAlign = CRITICAL_SECTION.alignof; } else version (Posix) { import core.sys.posix.sys.types : pthread_mutex_t; enum lockAlign = pthread_mutex_t.alignof; } enum mutexInstanceSize = __traits(classInstanceSize, Mutex) enum lockAlignedSize = (mutexInstanceSize + lockAlign - 1) & ~(lockAlign - 1); __gshared align(lockAlign) void[lockAlignedSize][2] _locks; static void initLocks() @nogc { foreach (ref lock; _locks) { lock[0 .. mutexInstanceSize] = typeid(Mutex).initializer[]; (cast(Mutex)lock.ptr).__ctor(); } } --- I don't think `align(lockAlign)` is really necessary based on feedback, but it covers us "just incase". -- |
December 13, 2018 [Issue 19481] Aborting from local/libphobos/libdruntime/core/sync/mutex.d(95) Error: pthread_mutex_init failed. | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19481 --- Comment #6 from kinke@gmx.net --- Yep, looks fine, and definitely keep the `align(mutexAlign)`. :) - You could get away with a single `alignedMutexInstanceSize` enum (and no `mutexInstanceSize`) by using `const init = typeid(Mutex).initializer; lock[0 .. init.length] = init[];`. -- |
March 16, 2019 [Issue 19481] Aborting from local/libphobos/libdruntime/core/sync/mutex.d(95) Error: pthread_mutex_init failed. | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19481 Dlang Bot <dlang-bot@dlang.rocks> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull --- Comment #7 from Dlang Bot <dlang-bot@dlang.rocks> --- @ibuclaw updated dlang/druntime pull request #2411 "Fix Issue 19481: mutex.d(95) Error: pthread_mutex_init failed" fixing this issue: - Fix Issue 19481: mutex.d(95) Error: pthread_mutex_init failed https://github.com/dlang/druntime/pull/2411 -- |
March 31, 2019 [Issue 19481] Aborting from local/libphobos/libdruntime/core/sync/mutex.d(95) Error: pthread_mutex_init failed. | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19481 --- Comment #8 from Dlang Bot <dlang-bot@dlang.rocks> --- @ibuclaw created dlang/druntime pull request #2534 "[dmd-cxx] Fix Issue 19481: mutex.d(95) Error: pthread_mutex_init failed" fixing this issue: - Fix Issue 19481: mutex.d(95) Error: pthread_mutex_init failed https://github.com/dlang/druntime/pull/2534 -- |
April 01, 2019 [Issue 19481] Aborting from local/libphobos/libdruntime/core/sync/mutex.d(95) Error: pthread_mutex_init failed. | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19481 Dlang Bot <dlang-bot@dlang.rocks> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |FIXED --- Comment #9 from Dlang Bot <dlang-bot@dlang.rocks> --- dlang/druntime pull request #2534 "[dmd-cxx] Fix Issue 19481: mutex.d(95) Error: pthread_mutex_init failed" was merged into dmd-cxx: - 505e88f5b2983ffc286ed7c66442480433db3c9e by Iain Buclaw: Fix Issue 19481: mutex.d(95) Error: pthread_mutex_init failed https://github.com/dlang/druntime/pull/2534 -- |
April 01, 2019 [Issue 19481] Aborting from local/libphobos/libdruntime/core/sync/mutex.d(95) Error: pthread_mutex_init failed. | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19481 Iain Buclaw <ibuclaw@gdcproject.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|FIXED |--- --- Comment #10 from Iain Buclaw <ibuclaw@gdcproject.org> --- Not fixed, as patch still not in master. -- |
Copyright © 1999-2021 by the D Language Foundation