Skip to content

Swift Target Crashes with Multi-Threading #3271

@rmehta33

Description

@rmehta33

Reproducing Error

Running via Xcode for iOS 13
Project Swift Version: 4.2
Compiled swift target from 4.9.2 release

Grammar

grammar math;

NUMBER : [0-9] ;
WS : [ \r\n\t] + -> skip ;

operation : l=NUMBER op='+' r=NUMBER  ;

Swift Code

for _ in 0...10 {
    DispatchQueue.global().async {
        let chars = ANTLRInputStream("1+1")
        let lexer = mathLexer(chars)
        
        let tokenStream = CommonTokenStream(lexer)
        let parser = try! mathParser(tokenStream)
        
        let node = try? parser.operation()
    }
}

What Happened

The program crashes in LexerATNSimulator.swift on line 721 with EXC_BAD_ACCESS. There was a double free at some point in the stack.

Any help is greatly appreciated! Hopefully this is just user error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions