Swift Target Crashes with Multi-Threading
- I am not submitting a question on how to use ANTLR; instead, go to antlr4-discussion google group or ask at stackoverflow
- I have done a search of the existing issues to make sure I'm not sending in a duplicate
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.