Uploaded image for project: 'Swift'
  1. Swift
  2. SR-9332

Stack overflow in SwiftSyntax due to deep recursion

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Component/s: SwiftSyntax
    • Labels:
      None

      Description

      Due to the recursion in SwiftSyntax's SyntaxVisitor, it's easy to trigger a stack overflow due to too much recursive calls. This is especially easy to trigger if you run visitors on multiple threads concurrently, if you compile with a debug configuration or if you run with tsan. For example:

      ThreadSanitizer:DEADLYSIGNAL
      ==720==ERROR: ThreadSanitizer: stack-overflow on address 0x7e8000189b00 (pc 0x00010601afd1 bp 0x7e800018c790 sp 0x7e8000186e50 T10952)
      ThreadSanitizer:DEADLYSIGNAL
          #0 SyntaxVisitor.visit(_:) SyntaxRewriter.swift:1699 (libSwiftSyntax.dylib:x86_64+0x683fd0)
      
      SUMMARY: ThreadSanitizer: stack-overflow SyntaxRewriter.swift:1699 in SyntaxVisitor.visit(_:)
      ==720==ABORTING
      Received 'abort trap' signal
      

      Example here: https://github.com/realm/SwiftLint/pull/2480

      If it would help, I can take some time to create a more focused repro case, just ask.

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            jpsim JP Simard
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: