Ticket #2892 (closed bug: fixed)

Opened 4 years ago

Last modified 16 months ago

(threadDelay (-1)) hangs

Reported by: dancor Owned by:
Priority: lowest Milestone: 7.6.1
Component: Compiler Version: 6.10.1
Keywords: Cc:
Operating System: Linux Architecture: x86
Type of failure: None/Unknown Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description (last modified by igloo) (diff)

threadDelay silently hangs forever given a negative delay interval. It seems like this should at least be documented, but further is probably suboptimal magical behavior that leads to harder-to-find bugs; instead this should be an error. Conceivably threadDelay could take Maybe Int but that seems kind of out there.

Here is some discussion from #haskell:

06:39 < dancor> do other ppl agree that (threadDelay (-1)) hanging silently is 
                bug?
06:39 < dancor> i guess you might want infinite hang, hm
06:39 < Cale> dancor: I think I might agree with that, though now that you 
              mention it, it's very handy.
06:39 < Cale> dancor: A lot of things which would cause a thread to block 
              forever will throw an exception and kill the thread.
06:40 < Cale> (an exception which you'd often wish were silent)
06:40 < Cale> But threadDelay is the wrong place for that
06:40 < b_jonas> dancor: yeah, the thread should just be garbage-collected
06:42  * quicksilver uses "forever (threadDelay maxBound)"

I'm on Debian lenny:

~ uname -a
Linux pima 2.6.26-1-686-bigmem #1 SMP Sat Nov 8 19:46:36 UTC 2008 i686 GNU/Linux
~ ghc --version
The Glorious Glasgow Haskell Compilation System, version 6.10.1
~ cat threadHang.hs
import Control.Concurrent
main = threadDelay (-1)

Change History

Changed 4 years ago by dancor

Very sorry, here is the description with proper formatting:

threadDelay silently hangs forever given a negative delay interval. It seems like this should at least be documented, but further is probably suboptimal magical behavior that leads to harder-to-find bugs; instead this should be an error. Conceivably threadDelay could take Maybe Int but that seems kind of out there.

Here is some discussion from #haskell:

06:39 < dancor> do other ppl agree that (threadDelay (-1)) hanging silently is 
                bug?
06:39 < dancor> i guess you might want infinite hang, hm
06:39 < Cale> dancor: I think I might agree with that, though now that you 
              mention it, it's very handy.
06:39 < Cale> dancor: A lot of things which would cause a thread to block 
              forever will throw an exception and kill the thread.
06:40 < Cale> (an exception which you'd often wish were silent)
06:40 < Cale> But threadDelay is the wrong place for that
06:40 < b_jonas> dancor: yeah, the thread should just be garbage-collected
06:42  * quicksilver uses "forever (threadDelay maxBound)"

I'm on Debian lenny:

~ uname -a
Linux pima 2.6.26-1-686-bigmem #1 SMP Sat Nov 8 19:46:36 UTC 2008 i686 GNU/Linux
~ ghc --version
The Glorious Glasgow Haskell Compilation System, version 6.10.1
~ cat threadHang.hs
import Control.Concurrent
main = threadDelay (-1)

Changed 4 years ago by igloo

  • difficulty set to Unknown
  • description modified (diff)

Changed 4 years ago by igloo

  • milestone set to 6.12 branch

Changed 3 years ago by igloo

  • milestone changed from 6.12 branch to 6.12.3

Changed 3 years ago by igloo

  • priority changed from normal to low
  • milestone changed from 6.12.3 to 6.14.1

Changed 2 years ago by igloo

  • milestone changed from 7.0.1 to 7.0.2

Changed 2 years ago by igloo

  • milestone changed from 7.0.2 to 7.2.1

Changed 20 months ago by igloo

  • milestone changed from 7.2.1 to 7.4.1

Changed 16 months ago by igloo

  • priority changed from low to lowest
  • milestone changed from 7.4.1 to 7.6.1

Changed 16 months ago by dancor

  • status changed from new to closed
  • failure set to None/Unknown
  • resolution set to fixed

these days (in ghc 7.0.3 anyway), threadDelay on a negative value immediately returns, so i consider this bug closed

Note: See TracTickets for help on using tickets.