Opened 6 years ago

Closed 6 years ago

#2508 closed bug (fixed)

exception handling: exitWith ExitSuccess results in abnormal termination with Control.OldException

Reported by: int-e Owned by: igloo
Priority: normal Milestone: 6.10.1
Component: libraries/base Version: 6.9
Keywords: Cc:
Operating System: Linux Architecture: x86
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

Consider this program.

import System.Exit
import Control.OldException

main = exitWith ExitSuccess `finally` return ()

It should not produce any output and return 0 as its exit code. Instead we get:

# runhaskell test.hs
exit: ExitSuccess
# echo $?
1

The problem is that finally catches the exception and rethrows it. In the process, the OldException module maps exceptions to old exceptions, but never maps them back when they're thrown.

Attachments (1)

OldException.patch (18.1 KB) - added by int-e 6 years ago.
a possible fix.

Download all attachments as: .zip

Change History (4)

Changed 6 years ago by int-e

a possible fix.

comment:1 follow-up: Changed 6 years ago by igloo

  • Difficulty set to Unknown
  • Milestone set to 6.10.1
  • Owner set to igloo

Ah, I think we actually want TopHandler to also try catching the old Exception type. I'll look into this, although I might leave it until after the base splitting has happened.

comment:2 in reply to: ↑ 1 Changed 6 years ago by int-e

Replying to igloo:

Ah, I think we actually want TopHandler to also try catching the old Exception type. I'll look into this, although I might leave it until after the base splitting has happened.

I think we've already lost the game if the old Exception type ever gets thrown - then any library using the new exception mechanism will not recognize the exceptions. As far as I understand the new mechanism, implementing the full Exception class instance should take care of that - that's what my proposed patch does.

(Hmm, by that reasoning, the Caster (\e -> e) can be safely removed from the list of attempted casts in said patch.)

comment:3 Changed 6 years ago by igloo

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

Ah, I see, so we just never actually throw the old Exception type. Makes sense, patch applied; thanks!

Note: See TracTickets for help on using tickets.