Ticket #1963 (closed bug: fixed)

Opened 5 years ago

Last modified 5 years ago

Pressing ^C at the right moment can trash GHC's package list

Reported by: igloo Owned by: simonmar
Priority: normal Milestone: 6.10 branch
Component: Compiler Version: 6.8.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

In  http://www.haskell.org/pipermail/libraries/2007-December/008727.html Peter Gammie says

To my surprise, if you type ^C at the right moment you can trash GHC's
(system-wide) package list.

I'm not sure if this is in ghc-pkg or ghc, but we should check that this can't happen with either program.

Change History

  Changed 5 years ago by simonmar

  • owner set to simonmar

I haven't quite finished working on this yet

  Changed 5 years ago by simonmar

  • owner changed from simonmar to igloo
  • type changed from bug to merge

Fixed:

Thu Dec 13 07:40:56 PST 2007  Simon Marlow <simonmar@microsoft.com>
  * FIX #1963: catch Ctrl-C and clean up properlyFri Dec 14 04:33:45 PST 2007  Simon Marlow <simonmar@microsoft.com>
  * always try to remove the new file before restoring the old one (#1963)

On Unix I think this is robust now. On Windows I occasionally get a "permission denied" failure when ghc-pkg tries to restore the old package database after Ctrl-C, but I don't know why this happens, or how to avoid it.

  Changed 5 years ago by igloo

  • status changed from new to closed
  • resolution set to fixed

Merged

  Changed 5 years ago by duncan

Instead of the dodgy backing up of the old file, it should use the writeFileAtomic from Cabal. On Unix it is genuinely atomic (assuming C is turned into an exception) and on Windows there is a very narrow race condition but it's probably a good deal narrower than in ghc-pkg's current impl.

  Changed 5 years ago by simonmar

  • status changed from closed to reopened
  • resolution fixed deleted
  • milestone changed from 6.8.3 to 6.10 branch

follow-up: ↓ 7   Changed 5 years ago by igloo

writeFileAtomic sounds like it belongs in base, not Cabal.

in reply to: ↑ 6   Changed 5 years ago by duncan

Replying to igloo:

writeFileAtomic sounds like it belongs in base, not Cabal.

Yeah it does. See #2298.

  Changed 5 years ago by igloo

  • type changed from merge to bug

  Changed 5 years ago by igloo

  • owner igloo deleted
  • status changed from reopened to new

  Changed 5 years ago by simonmar

  • owner set to simonmar

  Changed 5 years ago by simonmar

  • status changed from new to closed
  • resolution set to fixed

Fixed:

Wed Aug 13 15:37:38 BST 2008  Simon Marlow <marlowsd@gmail.com>
  * FIX #1963: use Cabal's writeFileAtomic to write the new package.conf
  This depends on #2298 also being fixed, which I'll do shortly

  Changed 5 years ago by simonmar

  • architecture changed from Unknown to Unknown/Multiple

  Changed 5 years ago by simonmar

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