Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a fix for #3319 which is related to the problem reported here.
The problem is in the Go runtime, specifically with ATNConfigSet's. In August 2021, there was a commit for a new hash set implementation for sets, which exposed a bug in ATNConfigSet's that has existed for over 5 years. It was only now revealed due to the confluence of that commit, the huge test suite of Antlr4 grammars in github.com/antlr/grammars-v4 now ported to 6 or so targets, and a bug in the GitHub Actions build for grammars-v4! Our lucky day!
The August 2021 commit implements the hash set as a two-level hash table with probing. The problem occurs if one tries to add an ATNConfig to the table with a nil lexerActionExecutor field when the ATNConfig's collide in the hash table. This only happens when two states have equal state numbers module 16. The old code would get a segv at this line of code. The solution is to first cast "other" to "othert" and then test that it is nil prior to use.
I added code to test the bug in file atnconfigset_test.go with this change. (Please read the comments in the file to see how to test.)