Opened 8 years ago

Closed 7 years ago

Last modified 6 years ago

#767 closed bug (fixed)

withMVar family have a bug

Reported by: simonmar Owned by:
Priority: high Milestone: 6.8.1
Component: Compiler Version: 6.4.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: N/A Blocked By:
Blocking: Related Tickets:

Description

withMVar is defined like this:

withMVar :: MVar a -> (a -> IO b) -> IO b
withMVar m io = 
  block $ do
    a <- takeMVar m
    b <- catch (unblock (io a))
      	    (\e -> do putMVar m a; throw e)
    putMVar m a
    return b

unfortunately this has a (very rare) bug: catch can raise a stack overflow exception, which would leave the MVar empty.

This is a tricky one. Perhaps in the event of a stack overflow, catch should ensure that the exception is passed directly to its handler, and we always add some extra stack space for the handler.

Change History (6)

comment:1 Changed 7 years ago by igloo

  • Milestone set to 6.8
  • Test Case set to N/A

comment:2 Changed 7 years ago by igloo

  • Priority changed from normal to high

comment:3 Changed 7 years ago by simonmar

  • Resolution set to fixed
  • Status changed from new to closed

Fixed:

Fri May 18 13:25:05 BST 2007  Simon Marlow <simonmar@microsoft.com>
  * FIX #767 (withMVar family have a bug)

comment:4 Changed 6 years ago by igloo

  • Milestone changed from 6.8 branch to 6.8.1

comment:5 Changed 6 years ago by simonmar

  • Architecture changed from Unknown to Unknown/Multiple

comment:6 Changed 6 years ago by simonmar

  • Operating System changed from Unknown to Unknown/Multiple
Note: See TracTickets for help on using tickets.