Created attachment 72166 [details] Sample C code that causes the assertion failure. I've written a simple multithreaded program and wanted to run memcheck 3.7.0 on it. It sometimes works, but sometimes fails due to an assertion failure which seems to occur randomly. The C source code of the sample program is attached. Removing manual thread stack size settings does not remedy the problem AFAICS. I ran Valgrind on an early 2008 MacBook Pro with OS X 10.7.4, equipped with a 2.26 GHz Intel Core 2 Duo. Here's the full output: ==26310== Memcheck, a memory error detector ==26310== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al. ==26310== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info ==26310== Command: ./a.out ==26310== valgrind: m_syscall.c:152 (vgPlain_mk_SysRes_x86_darwin): Assertion 'sizeof(UWord) == sizeof(UInt)' failed. ==26310== at 0x2380373EB: ??? ==26310== by 0x2380376BF: ??? ==26310== by 0x23804DC85: ??? ==26310== by 0x2380C12DD: ??? ==26310== by 0x2380A2202: ??? ==26310== by 0x2380A001F: ??? ==26310== by 0x2380CA4ED: ??? sched status: running_tid=1 Thread 1: status = VgTs_Runnable ==26310== at 0x2BF67A: mach_msg_trap (in /usr/lib/system/libsystem_kernel.dylib) ==26310== by 0x2BA847: thread_terminate (in /usr/lib/system/libsystem_kernel.dylib) ==26310== by 0x17F157: _pthread_exit (in /usr/lib/system/libsystem_c.dylib) ==26310== by 0x17F27C: pthread_exit (in /usr/lib/system/libsystem_c.dylib) ==26310== by 0x100000D69: main (dirthread.c:76) Thread 7: status = VgTs_WaitSys ==26310== at 0x2BF67A: mach_msg_trap (in /usr/lib/system/libsystem_kernel.dylib) ==26310== by 0x2B7D38: semaphore_create (in /usr/lib/system/libsystem_kernel.dylib) ==26310== by 0x17E0F7: new_sem_from_pool (in /usr/lib/system/libsystem_c.dylib) ==26310== by 0x17F199: _pthread_exit (in /usr/lib/system/libsystem_c.dylib) ==26310== by 0x17F27C: pthread_exit (in /usr/lib/system/libsystem_c.dylib) ==26310== by 0x100000B8F: handleFile (dirthread.c:43) ==26310== by 0x17D8BE: _pthread_start (in /usr/lib/system/libsystem_c.dylib) ==26310== by 0x180B74: thread_start (in /usr/lib/system/libsystem_c.dylib) Thread 8: status = VgTs_Yielding ==26310== at 0x1D1367: spin_lock$VARIANT$mp (in /usr/lib/system/libsystem_c.dylib) ==26310== by 0x17F199: _pthread_exit (in /usr/lib/system/libsystem_c.dylib) ==26310== by 0x17F27C: pthread_exit (in /usr/lib/system/libsystem_c.dylib) ==26310== by 0x100000B8F: handleFile (dirthread.c:43) ==26310== by 0x17D8BE: _pthread_start (in /usr/lib/system/libsystem_c.dylib) ==26310== by 0x180B74: thread_start (in /usr/lib/system/libsystem_c.dylib) Thread 10: status = VgTs_WaitSys ==26310== at 0x1D1385: spin_lock$VARIANT$mp (in /usr/lib/system/libsystem_c.dylib) ==26310== by 0x17F199: _pthread_exit (in /usr/lib/system/libsystem_c.dylib) ==26310== by 0x17F27C: pthread_exit (in /usr/lib/system/libsystem_c.dylib) ==26310== by 0x100000B8F: handleFile (dirthread.c:43) ==26310== by 0x17D8BE: _pthread_start (in /usr/lib/system/libsystem_c.dylib) ==26310== by 0x180B74: thread_start (in /usr/lib/system/libsystem_c.dylib) Thread 14: status = VgTs_WaitSys ==26310== at 0x1D1385: spin_lock$VARIANT$mp (in /usr/lib/system/libsystem_c.dylib) ==26310== by 0x17F199: _pthread_exit (in /usr/lib/system/libsystem_c.dylib) ==26310== by 0x17F27C: pthread_exit (in /usr/lib/system/libsystem_c.dylib) ==26310== by 0x100000B8F: handleFile (dirthread.c:43) ==26310== by 0x17D8BE: _pthread_start (in /usr/lib/system/libsystem_c.dylib) ==26310== by 0x180B74: thread_start (in /usr/lib/system/libsystem_c.dylib) Thread 18: status = VgTs_WaitSys ==26310== at 0x1D1385: spin_lock$VARIANT$mp (in /usr/lib/system/libsystem_c.dylib) ==26310== by 0x17F199: _pthread_exit (in /usr/lib/system/libsystem_c.dylib) ==26310== by 0x17F27C: pthread_exit (in /usr/lib/system/libsystem_c.dylib) ==26310== by 0x100000B8F: handleFile (dirthread.c:43) ==26310== by 0x17D8BE: _pthread_start (in /usr/lib/system/libsystem_c.dylib) ==26310== by 0x180B74: thread_start (in /usr/lib/system/libsystem_c.dylib)
This seems like some build time configuration error, or something. I doubt it is related to the test program. Does this still happen with a clean build of valgrind?
I was just about to file what seems the same bug. I have a MacBookPro 15-inch Mid 2010 running Mac OS X Lion 10.7.4 (11E53). I 'm also running valgrind 3.7.0 and I built it very recently. It occurred to me after inserting pthread_exit into the main thread which I did in order to wait for the other threads to shutdown before exiting. valgrind: m_syscall.c:152 (vgPlain_mk_SysRes_x86_darwin): Assertion 'sizeof(UWord) == sizeof(UInt)' failed. ==80767== at 0x2380373EB: ??? ==80767== by 0x2380376BF: ??? ==80767== by 0x23804DC85: ??? ==80767== by 0x2380C12DD: ??? ==80767== by 0x2380A2202: ??? ==80767== by 0x2380A001F: ??? ==80767== by 0x2380CA4ED: ??? sched status: running_tid=1 Thread 1: status = VgTs_Runnable ==80767== at 0x2BF67A: mach_msg_trap (in /usr/lib/system/libsystem_kernel.dylib) ==80767== by 0x2BA847: thread_terminate (in /usr/lib/system/libsystem_kernel.dylib) ==80767== by 0x17F157: _pthread_exit (in /usr/lib/system/libsystem_c.dylib) ==80767== by 0x17F27C: pthread_exit (in /usr/lib/system/libsystem_c.dylib) ==80767== by 0x1000A5488: main (in ./main_simple_Main) Thread 2: status = VgTs_WaitSys ==80767== at 0x2C0BF2: __psynch_mutexwait (in /usr/lib/system/libsystem_kernel.dylib) ==80767== by 0x1C5209: flockfile (in /usr/lib/system/libsystem_c.dylib) ==80767== by 0x170FA5: vfprintf_l (in /usr/lib/system/libsystem_c.dylib) ==80767== by 0x1000A3D17: gc_log (in ./main_simple_Main) ==80767== by 0x1000A376D: thread_main (in ./main_simple_Main) ==80767== by 0x17D8BE: _pthread_start (in /usr/lib/system/libsystem_c.dylib) ==80767== by 0x180B74: thread_start (in /usr/lib/system/libsystem_c.dylib)
(In reply to comment #1) > Does this still happen with a clean build of valgrind? Yes, it's with a clean build of 3.7.0 using the Xcode 4.3.2 toolchain.
Discovered reproducible with the below regression test on affected platforms: $ perl tests/vg_regtest none/tests/pth_exit This was with the below clang compiler and OS X version: $ clang --version Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn) Target: x86_64-apple-darwin-12.0.0 Thread model: posix $ uname -mrs Darwin 12.0.0 x86_64 It is not present on OS X 10.9 (clang-600.0.57 based on LLVM 3.5svn) or OS X 10.10.
*** Bug 326797 has been marked as a duplicate of this bug. ***
Resolved in r15329.