Opened 9 months ago

Closed 3 months ago

#15053 closed bug (fixed)

Compiler panic on invalid syntax (unterminated pragma)

Reported by: AndreasK Owned by: RolandSenn
Priority: normal Milestone: 8.6.2
Component: Compiler (Parser) Version: 8.2.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Compile-time crash or panic Test Case: make test TEST=T15053
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D4883 Phab:D5093
Wiki Page:

Description

The following minimal example causes a compiler panic.

{-# OPTIONS_GHC -O1 }
"
  #-}
ghc-stage2.exe: panic! (the 'impossible' happened)
  (GHC version 8.5.20180413 for x86_64-unknown-mingw32):
        getOptions'.parseToks: Couldn't read "\r\n\"\r\n  " as String

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

Happens in HEAD and 8.2.2 at least. Double quotes seem to confuse the parser. Also panics if there are two doublequotes.

Change History (10)

comment:1 Changed 7 months ago by bgamari

Differential Rev(s): Phab:D4883

comment:2 Changed 7 months ago by osa1

This is easy to fix, we just need to decide on an error message. If current message is fine that we could just throw an exception instead of panicking.

comment:3 Changed 6 months ago by Ben Gamari <ben@…>

In f03f0d61/ghc:

testsuite: Add test for #15053

Reviewers: Phyx

Reviewed By: Phyx

Subscribers: Phyx, rwbarton, thomie, carter

GHC Trac Issues: #15053

Differential Revision: https://phabricator.haskell.org/D4883

comment:4 Changed 5 months ago by bgamari

Milestone: 8.6.18.8.1

These won't be fixed for in GHC 8.6.

comment:5 Changed 5 months ago by RolandSenn

Owner: set to RolandSenn

I'll work on this.

comment:6 Changed 5 months ago by RolandSenn

Differential Rev(s): Phab:D4883Phab:D4883 Phab:D5093
Status: newpatch
Test Case: make test TEST=T15053

comment:7 Changed 4 months ago by Krzysztof Gogolewski <krz.gogolewski@…>

In df363a6/ghc:

Compiler panic on invalid syntax (unterminated pragma)

Summary: After a parse error in OPTIONS_GHC issue an error message instead of a compiler panic.

Test Plan: make test TEST=T15053

Reviewers: Phyx, thomie, bgamari, monoidal, osa1

Reviewed By: Phyx, monoidal, osa1

Subscribers: tdammers, osa1, rwbarton, carter

GHC Trac Issues: #15053

Differential Revision: https://phabricator.haskell.org/D5093

comment:8 Changed 4 months ago by monoidal

Status: patchmerge

comment:9 Changed 3 months ago by RyanGlScott

Milestone: 8.8.18.6.2

Moving to the 8.6.2 milestone, since these tickets were all recently marked as merge.

comment:10 Changed 3 months ago by bgamari

Resolution: fixed
Status: mergeclosed
Note: See TracTickets for help on using tickets.