-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is the C++ target Multithread safe? #1790
Comments
Any chance of getting it done in the foreseeable future? That would save me from the multi-process, shared memory tricky approach. |
@alainmarcel Unlikely. This is non-trivial and the C++ maintainer is currently not very active. |
Just interesting: does this issue related to cache clearing? C# runtime also not thread safe but it can be resolved with using of ReadWriterLockSlim synchronization primitive |
I fixed a bug wrt. multithreading. Try the next release, which is due soon and see if that helps you. |
Will certainly do.
Thanks,
Alain
… On Mar 30, 2017, at 1:01 PM, Mike Lischke ***@***.***> wrote:
I fixed a bug wrt. multithreading. Try the next release, which is due soon and see if that helps you.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
I think I'm seeing a similar problem. I'm using antlr-4.7-complete.jar and antlr4-cpp-runtime-4.7-source.zip. Here are two different backtraces:
Also:
|
If I run the program with a single thread it doesn't seem to crash. |
@ksedgwic How do you use the parser in threads? I hope you are not sharing them between threads. From your stacktrace I see it's crashing in the same code in different threads (when manipulating an IntervalSet. That doesn't make much sense, since this is not a shared structure. Maybe it's failing on certain values, not because of concurrent access to something? |
The two backtraces are from two separate runs. Each thread creates a parser and uses it by itself, no inter-thread sharing at all. |
4.7 works like a charm in multi thread and is also faster! Just be extra careful with caching any parser (like caching pre-compiled headers in some thread) and accessing (walking a listener) the resulting created parser in another thread. |
I started a large project with the C++ target a few months back with great success so far, Kudos!
A few days ago though, I tried for the 1rst time to run some of the lexers and parsers in parallel in different threads, no data shared (no statics, all allocated objects) but my code base is quite large at this point so coding errors are possible. I get mostly core dumps at runtime and occasionally good results (Typical of bad multithread coding).
I want to rule out options, the primary one being, are the lexers, parsers and listeners Multithread safe?
Most of the time I crash here:
Thread 2 "myproject" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff6f4f700 (LWP 25394)]
0x000000000080f9a9 in std::vector<antlr4::misc::Interval, std::allocatorantlr4::misc::Interval >::operator=(std::vector<antlr4::misc::Interval, std::allocatorantlr4::misc::Interval > const&) ()
(gdb) where
#0 0x000000000080f9a9 in std::vector<antlr4::misc::Interval, std::allocatorantlr4::misc::Interval >::operator=(std::vector<antlr4::misc::Interval, std::allocatorantlr4::misc::Interval > const&) ()
#1 0x0000000000817d79 in antlr4::atn::ATN::nextTokens(antlr4::atn::ATNState*) const ()
#2 0x00000000008136a2 in antlr4::DefaultErrorStrategy::sync(antlr4::Parser*) ()
...
Thanks
The text was updated successfully, but these errors were encountered: