antlr / antlr4

ANTLR (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files.
http://antlr.org
BSD 3-Clause "New" or "Revised" License
17.27k stars 3.29k forks source link

[go] generated lexer is not thread safe #4400

Closed longjiquan closed 1 year ago

longjiquan commented 1 year ago

image

As the above picture showed, when antlr trying to parse text under multiple thread, the access to global variable str makes the lexer not thread safe.

longjiquan commented 1 year ago

Version: antlr-4.9 Go Target Runtime: 20210826220005-b48c857c3a0e

longjiquan commented 1 year ago

I've also tried the newest version 4.13, but the lexer and parser generated by the 4.13 are also not thread safe, since they will share the DFA. We already use the antlr in the production environment, so anyone can help me on this issue? Thanks in advance. Please let me know if any other information is required.

jimidle commented 1 year ago

They are go routine safe. This looks like your own action is not thread safe. Can you show me the actions you are using. Actions can usually be avoided, but I’d need to see your grammar

On Wed, Aug 30, 2023 at 13:44 Jiquan Long @.***> wrote:

Closed #4400 https://github.com/antlr/antlr4/issues/4400 as completed.

— Reply to this email directly, view it on GitHub https://github.com/antlr/antlr4/issues/4400#event-10228574603, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJ7TMADDFNKLJXAJVF5FRTXX3HMJANCNFSM6AAAAAA4D23MHE . You are receiving this because you are subscribed to this thread.Message ID: @.***>