Ticket #3983 (closed bug: fixed)

Opened 3 years ago

Last modified 3 years ago

-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 Difficulty:
Test Case: simplCore/should_run/T3983 Blocked By: #3959
Blocking: #4229, #4241 Related Tickets:

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

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

Change History

Changed 3 years ago by benjamin_scarlet

Changed 3 years ago by benjamin_scarlet

Changed 3 years ago by benjamin_scarlet

Changed 3 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".

Changed 3 years ago by RichardG

Ticket #3961 may be related.

Changed 3 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 :(

Changed 3 years ago by simonpj

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

Simon

Changed 3 years ago by igloo

  • owner set to simonpj
  • milestone set 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 3 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.

Changed 3 years ago by igloo

  • blocking 4241 removed
  • blockedby 3959 added

Changed 3 years ago by igloo

  • blocking 4241 added

Changed 3 years ago by igloo

  • blocking 4229 added

Changed 3 years ago by simonpj

  • status changed from new to closed
  • testcase set to simplCore/should_run/T3983
  • resolution set to fixed

Fixed, by the same patch as #3959.

Note: See TracTickets for help on using tickets.