Skip to content

Conversation

kaby76
Copy link
Contributor

@kaby76 kaby76 commented Oct 26, 2021

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.)

@kaby76
Copy link
Contributor Author

kaby76 commented Oct 26, 2021

@ericvergnaud @parrt Please review. Hoping to add this to 4.9.3 in the Go runtime. Ty.

@parrt parrt added this to the 4.9.3 milestone Oct 26, 2021
@parrt parrt merged commit 6af4c77 into antlr:master Oct 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants