Skip to content
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

std::call_once throws std::system_error (Unknown error -1) after call in lexer initializer #4506

Closed
olowo726 opened this issue Jan 6, 2024 · 1 comment

Comments

@olowo726
Copy link
Contributor

olowo726 commented Jan 6, 2024

  • [ x] I have reproduced my issue using the latest version of ANTLR
  • [ x] I have asked at stackoverflow
  • [ x] Responses from the above seem to indicate that my issue could be an ANTLR bug
  • [x ] I have done a search of the existing issues to make sure I'm not sending in a duplicate

I recently updated from 4.9.3 to 4.13.1 and after that I experience std::call_once throws std::system_error (Unknown error -1) after call in lexer initializer in my application.

Build of ANTLR, my application and test of my application is performed on the same machine running Ubuntu 20.04. Linking against the static antlr library.

Researching the issue it seems like it's not the first time it appears so I wonder if it has been reintroduced.

It is mention in #3708 and #4086 (went into the 4.12 milestone). There is also stackoverflow posts https://stackoverflow.com/questions/51584960/stdcall-once-throws-stdsystem-error-unknown-error-1 and https://stackoverflow.com/questions/72688711/anltr4-cpp-demo-fails-to-run-because-of-a-gthread-problem

Several of these posts indicates that the fix is to add

find_package(Threads REQUIRED)
target_link_libraries(MyTarget Threads::Threads)

to CMakeLists.txt. This was already present in my CMakeLists.txt.

https://stackoverflow.com/questions/72688711/anltr4-cpp-demo-fails-to-run-because-of-a-gthread-problem indicates that a solution is to add

set(THREADS_PREFER_PTHREAD_FLAG ON)

This I have tried and didn't help.

I can add that it for some reason does work if the code is called directly from a gtest testcase instead of the standalone application.

Any hints on how to resolve this issue?

@olowo726
Copy link
Contributor Author

target_link_libraries(MyTarget Threads::Threads) added also to CMakeLists.txt for antlr solved it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant