Debian Bug report logs - #681621
use of logging functions by hPipeFrom, etc, causes hangs with threaded runtime

version graph

Package: libghc-missingh-dev; Maintainer for libghc-missingh-dev is Debian Haskell Group <pkg-haskell-maintainers@lists.alioth.debian.org>; Source for libghc-missingh-dev is src:missingh.

Reported by: Joey Hess <joeyh@debian.org>

Date: Sat, 14 Jul 2012 20:24:01 UTC

Severity: normal

Found in version missingh/1.1.0.3-6

Reply or subscribe to this bug.

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to debian-bugs-dist@lists.debian.org, Debian Haskell Group <pkg-haskell-maintainers@lists.alioth.debian.org>:
Bug#681621; Package libghc-missingh-dev. (Sat, 14 Jul 2012 20:24:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Joey Hess <joeyh@debian.org>:
New Bug report received and forwarded. Copy sent to Debian Haskell Group <pkg-haskell-maintainers@lists.alioth.debian.org>. (Sat, 14 Jul 2012 20:24:04 GMT) Full text and rfc822 format available.

Message #5 received at submit@bugs.debian.org (full text, mbox):

From: Joey Hess <joeyh@debian.org>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: use of logging functions by hPipeFrom, etc, causes hangs with threaded runtime
Date: Sat, 14 Jul 2012 16:11:40 -0400
[Message part 1 (text/plain, inline)]
Package: libghc-missingh-dev
Version: 1.1.0.3-6+b3
Severity: normal

As described in this thread:
http://thread.gmane.org/gmane.comp.lang.haskell.cafe/99334/focus=99338

The attached testcase will hang after a short while once compiled with -threaded.
Comment out the "LINE OF DEATH" and it runs as expected.

Apparently hPipeFrom etc's use of System.Log.Logger is the culprit. logM uses
a MVar, and this is a MVar deadlock. But I don't understand exactly why this
happens only with the threaded runtime, or really, why the attempt to use the MVar
*before* forkProcess causes problems at all.

This also seems disturbingly similar to #624389. In both cases System.Cmd.Utils
falls over under heavy load, or is somehow racy.

-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'stable'), (1, 'experimental')
Architecture: i386 (x86_64)

Kernel: Linux 3.2.0-2-amd64 (SMP w/1 CPU core)
Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages libghc-missingh-dev depends on:
ii  ghc [libghc-unix-dev-2.5.1.0-b1af7]                        7.4.1-4
ii  libc6                                                      2.13-32
ii  libffi5                                                    3.0.10-3
ii  libghc-array-dev-0.4.0.0-0b32f                             <none>
ii  libghc-base-dev-4.5.0.0-c8e71                              <none>
ii  libghc-containers-dev-0.4.2.1-7c545                        <none>
ii  libghc-directory-dev-1.1.0.2-89575                         <none>
ii  libghc-filepath-dev-1.3.0.0-674b8                          <none>
ii  libghc-hslogger-dev [libghc-hslogger-dev-1.1.4-94350]      1.1.4+dfsg1-2+b3
ii  libghc-hunit-dev [libghc-hunit-dev-1.2.4.2-6a847]          1.2.4.2-2+b1
ii  libghc-mtl-dev [libghc-mtl-dev-2.1.1-ae9b4]                2.1.1-1
ii  libghc-network-dev [libghc-network-dev-2.3.0.13-6b330]     2.3.0.13-1+b2
ii  libghc-old-locale-dev-1.0.0.4-29bd5                        <none>
ii  libghc-old-time-dev-1.1.0.0-681e9                          <none>
ii  libghc-parsec3-dev [libghc-parsec-dev-3.1.2-ad4f8]         3.1.2-1+b3
ii  libghc-process-dev-1.1.0.1-91185                           <none>
ii  libghc-random-dev [libghc-random-dev-1.0.1.1-3bece]        1.0.1.1-1+b1
ii  libghc-regex-compat-dev [libghc-regex-compat-dev-0.95.1-c  0.95.1-2+b1
ii  libgmp10                                                   2:5.0.5+dfsg-2

libghc-missingh-dev recommends no packages.

Versions of packages libghc-missingh-dev suggests:
pn  libghc-missingh-doc   <none>
pn  libghc-missingh-prof  <none>

-- no debconf information

-- 
see shy jo
[test.hs (text/x-haskell, attachment)]

Information forwarded to debian-bugs-dist@lists.debian.org, Debian Haskell Group <pkg-haskell-maintainers@lists.alioth.debian.org>:
Bug#681621; Package libghc-missingh-dev. (Wed, 18 Jul 2012 23:12:07 GMT) Full text and rfc822 format available.

Acknowledgement sent to Joey Hess <joey@kitenet.net>:
Extra info received and forwarded to list. Copy sent to Debian Haskell Group <pkg-haskell-maintainers@lists.alioth.debian.org>. (Wed, 18 Jul 2012 23:12:07 GMT) Full text and rfc822 format available.

Message #10 received at 681621@bugs.debian.org (full text, mbox):

From: Joey Hess <joey@kitenet.net>
To: haskell-cafe@haskell.org, 681621@bugs.debian.org
Subject: Re: [Haskell-cafe] strange hangs with -threaded runtime (now with test case)
Date: Wed, 18 Jul 2012 19:01:30 -0400
[Message part 1 (text/plain, inline)]
Just following up to my problem, I was seeing lots of hangs in various
places in my program when it was built with the threaded runtime.

I eventually tracked every single hang back to calls to MissingH's
System.Cmd.Utils, including pipeFrom, pipeTo, pipeBoth, and pOpen.

I was at this point running my program in a loop 1000 times, and it'd
hang between 1 and 10 times on average, since these hangs seem to be
timing-related.

In all cases, when it hung, it had forked a child, and the child
was blocked in a futex() call. Each of these functions calls
forkProcess, and then does some very simple setup before it calls
executeFile -- but as far as I could see, the forked process never
ran a single thing before hanging.

The solution, for me, was to convert all my code to use System.Process
instead of System.Cmd.Utils. It seems that System.Process does all
its setup between fork and exec using C code, and so avoids this
problem.

I think it'd make sense to either add deprecation warnings to
System.Cmd.Utils, or to rewrite it to be a wrapper around
System.Process.

-- 
see shy jo
[signature.asc (application/pgp-signature, inline)]

Send a report that this bug log contains spam.


Debian bug tracking system administrator <owner@bugs.debian.org>. Last modified: Mon Apr 21 07:04:47 2014; Machine Name: buxtehude.debian.org

Debian Bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.