Opened 22 months ago

Last modified 22 months ago

#14987 new bug

Memory usage exploding for complex pattern matching

Reported by: vmiraldo Owned by:
Priority: normal Milestone:
Component: Compiler Version: 8.4.1
Keywords: PatternMatchWarnings Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Compile-time crash or panic Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


It seems like complex pattern matching is consuming a prohibitive amount of memory. From a discussion in ghc-devs,, the exhaustiveness checker could be the culprit.

We have tried with 7.10.3, 8.0.2, 8.4.1 and ghc-HEAD. They show similar results.

The "-fmax-pmchecker-iterations=0" option seems to help slightly. Bigger cases will run out of memory even with the option enabled.

I'm attaching a "minimal" example to help diagnosing. The majority of the code has been generated by Template Haskell.

Attachments (1)

Minimal.hs (46.1 KB) - added by vmiraldo 22 months ago.
Self-contained repro for the bug.

Download all attachments as: .zip

Change History (4)

Changed 22 months ago by vmiraldo

Attachment: Minimal.hs added

Self-contained repro for the bug.

comment:1 Changed 22 months ago by Ben Gamari <ben@…>

In c054162/ghc:

Revert "Fix #14838 by marking TH-spliced code as FromSource"

This reverts commit ffb2738f86c4e4c3f0eaacf0a95d7326fdd2e383.

Due to #14987.

Reviewers: goldfire, RyanGlScott

Reviewed By: RyanGlScott

Subscribers: RyanGlScott, thomie, carter

GHC Trac Issues: #14987, #14838

Differential Revision:

comment:2 Changed 22 months ago by bgamari

The patch that triggered this has been reverted. However, this is just a workaround; ultimately we will want to apply this patch again as it fixed #14838.

comment:3 Changed 22 months ago by simonpj

Keywords: PatternMatchWarnings added
Note: See TracTickets for help on using tickets.