Bug 16636 – Memory corruption when using OSX pthread function in 32-bit with -g enabled

Status
RESOLVED
Resolution
WONTFIX
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Mac OS X
Creation time
2016-10-24T14:48:58Z
Last change time
2019-03-27T11:16:33Z
Assigned to
No Owner
Creator
ponce

Comments

Comment #0 by aliloko — 2016-10-24T14:48:58Z
DMD version: DMD64 D Compiler v2.072.0-b2 OS: macOS Sierra 10.12 on x86 processor Build test case with comand: $ rdmd -m32 -g main.d What happens is that there is a deadlock instead of finishing. Many ways not to work-around the bug: - remove the _created bool from the structure (44-byte struct instead of 48) - change the size of this boolean to 8-bytes (52 byte struct) - compile for 64-bit - remove the -g flags Source: ------------------- main.d ------------------------- import core.sys.posix.pthread; UncheckedMutex makeMutex() nothrow @nogc { return UncheckedMutex(42); } struct UncheckedMutex { private this(int dummyArg) nothrow @nogc { pthread_mutex_init( &m_hndl, null ); } ~this() nothrow @nogc { pthread_mutex_destroy(&m_hndl); } @disable this(this); /// Lock mutex void lock() nothrow @nogc { int res = pthread_mutex_lock(&m_hndl); if (res != 0) assert(false); } // undocumented function for internal use void unlock() nothrow @nogc { int res = pthread_mutex_unlock(&m_hndl ); if (res != 0) assert(false); } private: pthread_mutex_t m_hndl = cast(pthread_mutex_t)0; // removing this fix the deadlock bool _created; } void main() { auto mutex = makeMutex(); foreach(i; 0..2) { mutex.lock(); // the second call will deadlock here mutex.unlock(); } mutex.destroy(); } ------------------- main.d -------------------------
Comment #1 by aliloko — 2016-10-24T15:09:24Z
> Many ways not to work-around the bug: Many ways *to* work-around the bug
Comment #2 by greensunny12 — 2019-03-27T11:16:33Z
Closing as WONTFIX as OSX 32-bit is no longer supported.