[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: Fix panic in multiline string with unterminated gap (#25530)
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Mon Dec 9 23:59:22 UTC 2024
Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC
Commits:
a8ceccf3 by Brandon Chinn at 2024-12-09T16:25:43-05:00
Fix panic in multiline string with unterminated gap (#25530)
- - - - -
9e464ad0 by Brandon Chinn at 2024-12-09T16:25:43-05:00
Add test case for unterminated multiline string
- - - - -
ed1ed5c6 by Rodrigo Mesquita at 2024-12-09T16:26:19-05:00
Revert mapMG renaming
We had previously renamed this function for consistency, but that caused unnecessary breakage
- - - - -
158261f7 by Sylvain Henry at 2024-12-09T16:27:01-05:00
RTS: make Cabal flags manual
Cabal shouldn't automatically try to set them. We set them explicitly.
- - - - -
dcf37372 by Matthew Stephenson at 2024-12-09T18:59:04-05:00
Add missing @since documentation for (!?) function
- - - - -
5ede1dab by Ben Gamari at 2024-12-09T18:59:04-05:00
compiler: Don't attempt to TSAN-instrument SIMD operations
TSAN only provides instrumentation for 8, 16, 32, and 64-bit memory
loads/stores. Don't attempt to instrument wider operations.
Fixes #25563.
- - - - -
11 changed files:
- compiler/GHC.hs
- compiler/GHC/Cmm/ThreadSanitizer.hs
- compiler/GHC/Parser/Lexer.x
- compiler/GHC/Unit/Module/Graph.hs
- libraries/ghc-internal/src/GHC/Internal/List.hs
- rts/rts.cabal
- + testsuite/tests/parser/should_fail/MultilineStringsUnterminated.hs
- + testsuite/tests/parser/should_fail/MultilineStringsUnterminated.stderr
- + testsuite/tests/parser/should_fail/T25530.hs
- + testsuite/tests/parser/should_fail/T25530.stderr
- testsuite/tests/parser/should_fail/all.T
Changes:
=====================================
compiler/GHC.hs
=====================================
@@ -74,7 +74,7 @@ module GHC (
compileToCoreModule, compileToCoreSimplified,
-- * Inspecting the module structure of the program
- ModuleGraph, emptyMG, mgMap, mkModuleGraph, mgModSummaries,
+ ModuleGraph, emptyMG, mapMG, mkModuleGraph, mgModSummaries,
mgLookupModule,
ModSummary(..), ms_mod_name, ModLocation(..),
pattern ModLocation,
@@ -874,7 +874,7 @@ setProgramDynFlags_ invalidate_needed dflags = do
--
invalidateModSummaryCache :: GhcMonad m => m ()
invalidateModSummaryCache =
- modifySession $ \h -> h { hsc_mod_graph = mgMap inval (hsc_mod_graph h) }
+ modifySession $ \h -> h { hsc_mod_graph = mapMG inval (hsc_mod_graph h) }
where
inval ms = ms { ms_hs_hash = fingerprint0 }
=====================================
compiler/GHC/Cmm/ThreadSanitizer.hs
=====================================
@@ -209,8 +209,9 @@ tsanTarget fn formals args =
tsanStore :: Env
-> CmmType -> CmmExpr
-> Block CmmNode O O
-tsanStore env ty addr =
- mkUnsafeCall env ftarget [] [addr]
+tsanStore env ty addr
+ | typeWidth ty < W128 = mkUnsafeCall env ftarget [] [addr]
+ | otherwise = emptyBlock
where
ftarget = tsanTarget fn [] [AddrHint]
w = widthInBytes (typeWidth ty)
@@ -219,8 +220,9 @@ tsanStore env ty addr =
tsanLoad :: Env
-> AlignmentSpec -> CmmType -> CmmExpr
-> Block CmmNode O O
-tsanLoad env align ty addr =
- mkUnsafeCall env ftarget [] [addr]
+tsanLoad env align ty addr
+ | typeWidth ty < W128 = mkUnsafeCall env ftarget [] [addr]
+ | otherwise = emptyBlock
where
ftarget = tsanTarget fn [] [AddrHint]
w = widthInBytes (typeWidth ty)
=====================================
compiler/GHC/Parser/Lexer.x
=====================================
@@ -2204,14 +2204,15 @@ tok_string_multi startSpan startBuf _len _buf2 = do
case alexScan i0 string_multi_content of
AlexToken i1 len _
| Just i2 <- lexDelim i1 -> pure (i1, i2)
- | -- is the next token a tab character?
- -- need this explicitly because there's a global rule matching $tab
- Just ('\t', _) <- alexGetChar' i1 -> setInput i1 >> lexError LexError
- | isEOF i1 -> checkSmartQuotes >> lexError LexError
- | len == 0 -> panic $ "parsing multiline string got into infinite loop at: " ++ show i0
+ | isEOF i1 -> checkSmartQuotes >> setInput i1 >> lexError LexError
+ -- is the next token a tab character?
+ -- need this explicitly because there's a global rule matching $tab
+ | Just ('\t', _) <- alexGetChar' i1 -> setInput i1 >> lexError LexError
+ -- Can happen if no patterns match, e.g. an unterminated gap
+ | len == 0 -> setInput i1 >> lexError LexError
| otherwise -> goContent i1
AlexSkip i1 _ -> goContent i1
- _ -> lexError LexError
+ _ -> setInput i0 >> lexError LexError
lexDelim =
let go 0 i = Just i
=====================================
compiler/GHC/Unit/Module/Graph.hs
=====================================
@@ -46,7 +46,7 @@ module GHC.Unit.Module.Graph
-- (without changing the 'ModuleGraph' structure itself!).
-- 'mgModSummaries' lists out all 'ModSummary's, and
-- 'mgLookupModule' looks up a 'ModSummary' for a given module.
- , mgMap, mgMapM
+ , mapMG, mgMapM
, mgModSummaries
, mgLookupModule
@@ -239,8 +239,8 @@ lengthMG = length . mg_mss
-- | Map a function 'f' over all the 'ModSummaries'.
-- To preserve invariants, 'f' can't change the isBoot status.
-mgMap :: (ModSummary -> ModSummary) -> ModuleGraph -> ModuleGraph
-mgMap f mg at ModuleGraph{..} = mg
+mapMG :: (ModSummary -> ModSummary) -> ModuleGraph -> ModuleGraph
+mapMG f mg at ModuleGraph{..} = mg
{ mg_mss = flip fmap mg_mss $ \case
InstantiationNode uid iuid -> InstantiationNode uid iuid
LinkNode uid nks -> LinkNode uid nks
=====================================
libraries/ghc-internal/src/GHC/Internal/List.hs
=====================================
@@ -1643,6 +1643,8 @@ xs !! n
--
-- WARNING: This function takes linear time in the index.
--
+-- @since base-4.19.0.0
+--
-- ==== __Examples__
--
-- >>> ['a', 'b', 'c'] !? 0
=====================================
rts/rts.cabal
=====================================
@@ -30,38 +30,55 @@ source-repository head
flag libm
default: False
+ manual: True
flag librt
default: False
+ manual: True
flag libdl
default: False
+ manual: True
flag use-system-libffi
default: False
+ manual: True
flag libffi-adjustors
default: False
+ manual: True
flag need-pthread
default: False
+ manual: True
flag libbfd
default: False
+ manual: True
flag need-atomic
default: False
+ manual: True
flag libdw
default: False
+ manual: True
flag libnuma
default: False
+ manual: True
flag libzstd
default: False
+ manual: True
flag static-libzstd
default: False
+ manual: True
flag leading-underscore
default: False
+ manual: True
flag unregisterised
default: False
+ manual: True
flag tables-next-to-code
default: False
+ manual: True
flag smp
default: True
+ manual: True
flag find-ptr
default: False
+ manual: True
-- Some cabal flags used to control the flavours we want to produce
-- for libHSrts in hadrian. By default, we just produce vanilla and
-- threaded. The flags "compose": if you enable debug and profiling,
@@ -69,18 +86,23 @@ flag find-ptr
-- _thr_debug_p and so on.
flag profiling
default: False
+ manual: True
flag debug
default: False
+ manual: True
flag dynamic
default: False
+ manual: True
flag threaded
default: False
+ manual: True
flag thread-sanitizer
description:
Enable checking for data races using the ThreadSanitizer (TSAN)
mechanism supported by GCC and Clang. See Note [ThreadSanitizer]
in @rts/include/rts/TSANUtils.h at .
default: False
+ manual: True
library
-- rts is a wired in package and
=====================================
testsuite/tests/parser/should_fail/MultilineStringsUnterminated.hs
=====================================
@@ -0,0 +1,9 @@
+{-# LANGUAGE MultilineStrings #-}
+
+x :: String
+x =
+ """
+ test
+
+y :: Int
+y = 0
=====================================
testsuite/tests/parser/should_fail/MultilineStringsUnterminated.stderr
=====================================
@@ -0,0 +1,3 @@
+MultilineStringsUnterminated.hs:10:1: error: [GHC-21231]
+ lexical error at end of input
+
=====================================
testsuite/tests/parser/should_fail/T25530.hs
=====================================
@@ -0,0 +1,9 @@
+{-# LANGUAGE MultilineStrings #-}
+
+foo =
+ """
+ a\
+ b
+ """
+
+main = print foo
=====================================
testsuite/tests/parser/should_fail/T25530.stderr
=====================================
@@ -0,0 +1,2 @@
+T25530.hs:5:4: error: [GHC-21231] lexical error at character '\\'
+
=====================================
testsuite/tests/parser/should_fail/all.T
=====================================
@@ -231,9 +231,13 @@ test('T17879a', normal, compile_fail, [''])
test('T17879b', normal, compile_fail, [''])
test('Or1', normal, compile_fail, [''])
test('OrPatInExprErr', normal, compile_fail, [''])
+
+# Multiline Strings
test('MultilineStringsError', [normalise_whitespace_fun(lambda s: s)], compile_fail, [''])
test('MultilineStringsSmartQuotes', normal, compile_fail, [''])
test('MultilineStringsInnerTab', normal, compile_fail, [''])
+test('MultilineStringsUnterminated', normal, compile_fail, [''])
test('T25258a', normal, compile_fail, [''])
test('T25258b', normal, compile_fail, [''])
test('T25258c', normal, compile_fail, [''])
+test('T25530', normal, compile_fail, [''])
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bcee6f20f4c86fad233d2aea35b8453adb8093e3...5ede1dab5fbf9d67d9adcd2686b98bc5445fd447
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bcee6f20f4c86fad233d2aea35b8453adb8093e3...5ede1dab5fbf9d67d9adcd2686b98bc5445fd447
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20241209/f8742569/attachment-0001.html>
More information about the ghc-commits
mailing list