Opened 9 years ago

Closed 9 years ago

#3983 closed bug (fixed)

-O2 makes exception disappear

Reported by: benjamin_scarlet Owned by: simonpj
Priority: low Milestone: 7.0.1
Component: Compiler Version: 6.12.1
Keywords: exception optimization Cc:
Operating System: Unknown/Multiple Architecture: x86_64 (amd64)
Type of failure: None/Unknown Test Case: simplCore/should_run/T3983
Blocked By: #3959 Blocking: #4229, #4241
Related Tickets: Differential Rev(s):
Wiki Page:

Description

In this example, an exception throw/catch seems not to happen when optimization is turned on. The behavior seems to be quite finicky. Collapsing the code into fewer than the three given modules seems either to make the bug go away or to produce a "internal error: PAP object entered!" message. Other seemingly innocuous changes produce similar results.

On both Linux and MacOS, this program produces "False" with no optimization flags to ghc, or "True" with -O2.

On 6.10.4 on Linux, it produces "False" with or without -O2.

Attachments (3)

Test.hs (64 bytes) - added by benjamin_scarlet 9 years ago.
Foo.hs (180 bytes) - added by benjamin_scarlet 9 years ago.
Bar.hs (328 bytes) - added by benjamin_scarlet 9 years ago.

Download all attachments as: .zip

Change History (14)

Changed 9 years ago by benjamin_scarlet

Attachment: Test.hs added

Changed 9 years ago by benjamin_scarlet

Attachment: Foo.hs added

Changed 9 years ago by benjamin_scarlet

Attachment: Bar.hs added

comment:1 Changed 9 years ago by benjamin_scarlet

The Bar module has two functions, one to throw an exception and one to catch it. Think "boiled down HUnit": the throw is a boiled down assert, the catch is a boiled down test-runner function.

The Foo module has a function which conditionally uses the throw function with conditionally-chosen data. Think "boiled down test case." With the arguments given, the test should fail.

The Test module contains main, which calls the function in Foo so as to cause an exception, and tries to catch that exception. Think "test driver".

comment:2 Changed 9 years ago by RichardG

Ticket #3961 may be related.

comment:3 Changed 9 years ago by batterseapower

I've had a bug report about a similar problem with my test-framework package. The reporter found that the problem was caused by by the full-laziness optimisation.

I haven't had time to look at it in detail yet :(

comment:4 Changed 9 years ago by simonpj

I suspect this is related to #3959, which I'm working on.

Simon

comment:5 Changed 9 years ago by igloo

Milestone: 6.12.3
Owner: set to simonpj

comment:6 Changed 9 years ago by igloo

Milestone: 6.12.36.14.1
Priority: normallow

comment:7 Changed 9 years ago by igloo

Blocking: 4241 added

(In #4241) I suspect this is #3983, but I'll leave it open so we can check and make sure once #3983 is fixed.

comment:7 Changed 9 years ago by igloo

Blocked By: 3959 added
Blocking: 4241 removed

comment:8 Changed 9 years ago by igloo

Blocking: 4241 added

comment:9 Changed 9 years ago by igloo

Blocking: 4229 added

comment:11 Changed 9 years ago by simonpj

Resolution: fixed
Status: newclosed
Test Case: simplCore/should_run/T3983

Fixed, by the same patch as #3959.

Note: See TracTickets for help on using tickets.