pthread mutex error building 6.10 on NetBSD

Matthias Kilian kili at outback.escape.de
Thu Jan 1 05:46:31 EST 2009


On Wed, Dec 31, 2008 at 10:44:07PM -0800, Donn Cave wrote:
> I tried to build GHC 6.10.1 on NetBSD 4.0 this afternoon, and ran into
> an error, where cabal-bin calls the stage2 ghc in utils/installPackage.
> 
> pthread_mutex_unlock() is called, evidently from fileLock(), with an
> invalid mutex.
> 
> NetBSD's pthread implementation differs from Linux in its intolerance
> of such things.  I have found errors where someone forgets that a mutex
> was never used and tries to unlock it.  I guess you could do that all day
> long on Linux without noticing anything, but NetBSD aborts the program.
> In the present case, I don't see anything like that wrong in rts/FileLock.c,
> though.  I'm stumped.
> 
> So I'm checking, has anyone else built 6.10 on NetBSD?

Only on OpenBSD, and there it builds fine (when bootstrapping from
either ghc-6.6 or -6.10). But what's interesting is that in
includes/OSThreads.h the return values of pthread_mutex_lock(3) and
pthread_mutex_unlock(3) aren't checked except apparently on Linux
when building with DEBUG defined.

You could either try to build with LOCK_DEBUG defined, so you see
exactly when a lock is acquired and released, or try to build with
DEBUG defined and that `&& defined(linux_HOST_OS)' removed from
OSThreads.h to see what's going wrong.

BTW: is there any pthread implementation still in the wild where
pthread_mutex_{,un}lock() does NOT indicate a deadlock by EDEADLK?
If not, the DEBUG part of OSThreads.h could be used for all systems,
not only Linux.

Ciao,
	Kili

-- 
A typo a day, keeps the dictionnary away.
		-- Miod Vallat


More information about the Glasgow-haskell-users mailing list