Skip to content

Swift parser crashes on invalid multi-line string literal #3097

@hamishknight

Description

@hamishknight

The following crashes the new parser:

#sourceLocation """\("
SwiftParser/StringLiterals.swift:346: Fatal error: String segment produced by the lexer should not have unexpected text or trivia because we would drop it during post-processing Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace. Stack dump: 0. Program arguments: /Users/hamish/src/swift-dev/build/Fuzz/swift-macosx-arm64/bin/swift-frontend -typecheck -sdk /Users/hamish/src/MacOSX.sdk /Users/hamish/src/swift-test-arena/main.swift 1. Swift version 6.2-dev (LLVM 4e0a8255b12089a, Swift 1398b316fee6062) 2. Compiling with effective version 5.10 3. While evaluating request ParseTopLevelDeclsRequest(source_file "/Users/hamish/src/swift-test-arena/main.swift") 4. While evaluating request ParseSourceFileRequest(source_file "/Users/hamish/src/swift-test-arena/main.swift") 5. With parser at source location: /Users/hamish/src/swift-test-arena/main.swift:1236:17 Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): 0 swift-frontend 0x000000010c2b719c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56 1 swift-frontend 0x000000010c2b58ec llvm::sys::RunSignalHandlers() + 112 2 swift-frontend 0x000000010c2b77e4 SignalHandler(int, __siginfo*, void*) + 296 3 libsystem_platform.dylib 0x0000000182672744 _sigtramp + 56 4 libswiftCore.dylib 0x0000000195d809ac $ss17_assertionFailure__4file4line5flagss5NeverOs12StaticStringV_SSAHSus6UInt32VtF + 176 5 lib_CompilerSwiftParser.dylib 0x0000000119801fbc $s20_CompilerSwiftParser0C0V33postProcessMultilineStringLiteral33_78149DB072C20084E7D780D86E26C3AFLL03rawG15DelimitersToken9openQuote8segments05closeU0Say01_aB6Syntax03RawsX0VG023unexpectedBeforeOpeningU0_AL07openingU0SayAJ0ygh11SegmentListX0V7ElementOGAhM0z13BeforeClosingU0AL07closingU0tALSg_AltLtF + 3080 6 lib_CompilerSwiftParser.dylib 0x00000001197fef84 $s20_CompilerSwiftParser0C0V17parseSimpleString01_aB6Syntax03Rawef11LiteralExprG0VyF + 3908 7 lib_CompilerSwiftParser.dylib 0x000000011972dce8 $s20_CompilerSwiftParser0C0V33parsePoundSourceLocationDirective01_aB6Syntax03RawefgI0VyF + 2968 8 lib_CompilerSwiftParser.dylib 0x0000000119809d74 $s20_CompilerSwiftParser0C0V9parseItem33_008C1B0E0A90478841CED0DF9A7053A1LL12isAtTopLevel13allowInitDecl01_aB6Syntax012RawCodeBlockeU0V0E0OSb_SbtF + 132 9 lib_CompilerSwiftParser.dylib 0x00000001198095e8 $s20_CompilerSwiftParser0C0V18parseCodeBlockItem12isAtTopLevel13allowInitDecl01_aB6Syntax03RawefgO0VSgSb_SbtF + 840 10 lib_CompilerSwiftParser.dylib 0x0000000119806b30 $s20_CompilerSwiftParser0C0V22parseCodeBlockItemList12isAtTopLevel13allowInitDecl5until01_aB6Syntax03RawefghQ0VSb_S2bACzXEtF05$s20_ab17Parser0C0V27parseklef25Items01_aB6Syntax03Rawgh8gH15J0VyFSbACzXEfU_Tf1nncn_n + 100 11 lib_CompilerSwiftParser.dylib 0x000000011987024c $s20_CompilerSwiftSyntax010SourceFileC0V01_aB6ParserE5parse4fromAcD0F0Vz_tFZ + 132 12 swift-frontend 0x00000001078997a0 $s11swiftASTGen15parseSourceFile6buffer10moduleName8filename14declContextPtr4kindSVSo16BridgedStringRefV_A2ISvSgSo0n9GenerateddE4KindVtF + 1188 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions