-
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
CPP Target: Unknown error -1 #4499
Comments
Please provide a stack trace for the crash. Best if you provide a repo containing the example too. |
Yeah sure, but you can reproduce the same with the Stack Trace#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50 #1 0x00007ffff7bf0859 in __GI_abort () at abort.c:79 #2 0x00007ffff7e798d1 in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6 #3 0x00007ffff7e8537c in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6 #4 0x00007ffff7e853e7 in std::terminate() () from /lib/x86_64-linux-gnu/libstdc++.so.6 #5 0x00007ffff7e85699 in __cxa_throw () from /lib/x86_64-linux-gnu/libstdc++.so.6 #6 0x00007ffff7e7c6fd in std::__throw_system_error(int) () from /lib/x86_64-linux-gnu/libstdc++.so.6 #7 0x0000555555570b65 in std::call_once (__once=..., __f=@0x55555556b503: {void (void)} 0x55555556b503 <(anonymous namespace)::tlexerLexerInitialize()>) at /usr/include/c++/9/mutex:691 #8 0x000055555556fb9f in antlr4::internal::call_once (onceFlag=..., callable=@0x55555556b503: {void (void)} 0x55555556b503 <(anonymous namespace)::tlexerLexerInitialize()>) at ~/Downloads/antlr4/runtime/Cpp/runtime/src/internal/Synchronization.h:150 #9 0x000055555556e57b in antlrcpptest::TLexer::initialize () at ~/Downloads/antlr4/runtime/Cpp/demo/generated/TLexer.cpp:285 #10 0x000055555556e108 in antlrcpptest::TLexer::TLexer (this=0x7fffffffdc80, input=0x7fffffffdb30) at ~/Downloads/antlr4/runtime/Cpp/demo/generated/TLexer.cpp:181 --Type for more, q to quit, c to continue without paging-- #11 0x000055555556a314 in main () at ~/Downloads/antlr4/runtime/Cpp/demo/Linux/main.cpp:24 Edit 2: Added the stack trace |
The demo cmake files are ancient. Let's start with the basics. Forget CMake. Install g++, java, python3, pip, and antlr4-tools. This Bash script works on my Linux box.
And, here's the output.
|
I agree, they are ancient. But if so, then shouldn't they be updated to ensure that the instructions are applicable for the latest version of ANTLR? Also, I was already including pthread for compilation, and the error was still there.
Thank you! This works on mine too, but I can't use g++ directly for compilation in my project. Do you know what changes I need to make in order to ensure that ANTLR version 4.13.1 works with CMake + Ninja? I am providing the relevant parts of my cmake_minimum_required(VERSION 3.28.1)
project(Agohya VERSION 0.1.0 LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 17)
# Adding the source files
file(GLOB_RECURSE SRC_FILES "src/*.cpp" "src/*.h")
include(CTest)
enable_testing()
# Include -lpthreads, mandatory for ANTLR to work
find_package(Threads REQUIRED)
set(ANTLR4_JAR_LOCATION ${CMAKE_SOURCE_DIR}/external/antlr-4.13.1-complete.jar)
set(ANTLR4_ZIP_REPOSITORY ${CMAKE_SOURCE_DIR}/external/antlr4-master.zip)
LIST( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake )
include( ExternalAntlr4Cpp )
# Set the path to the Generated Files Directory
set(ANTLR4_GENERATED_SRC_DIR ${CMAKE_SOURCE_DIR}/src/antlr_gen)
# Add a custom target to generate lexer and parser files
add_custom_target(antlr4_generate
COMMAND java -jar external/antlr-4.13.1-complete.jar -Dlanguage=Cpp -o ${ANTLR4_GENERATED_SRC_DIR} -listener -visitor -package nsagohya ${CMAKE_CURRENT_SOURCE_DIR}/grammar/AgohyaLexer.g4 ${CMAKE_CURRENT_SOURCE_DIR}/grammar/AgohyaParser.g4
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Generating lexer and parser files with ANTLR4"
)
include_directories( ${ANTLR4_INCLUDE_DIRS} )
link_directories( ${ANTLR4_SHARED_LIBRARIES} )
message(STATUS "Found antlr4cpp libs: ${ANTLR4_SHARED_LIBRARIES} and includes: ${ANTLR4_INCLUDE_DIRS} ")
# Include the generated files
include_directories(${ANTLR4_INCLUDE_DIRS})
# Include the generated source directory for headers
include_directories(${ANTLR4_GENERATED_SRC_DIR})
add_executable(Agohya ${ANTLR4_GENERATED_SRC_DIR} ${SRC_FILES} )
add_dependencies(Agohya antlr4_generate)
target_link_libraries(Agohya Threads::Threads antlr4_shared) |
I'm not sure how to best modify your CMakeList.txt to get things to work as I'm not an expert at CMake. Instead, I took the one from the demo/ directory then modified a few things, adjust the flags for compiling with Here is a bash file that works on Ubuntu. And the output from the build. Indeed, the demo should be updated with build files that work. |
Ohh okay, Thank you very much though! @kaby76 Since this issue is occurring by following the Demo, I suppose it is an ANTLR issue. I don't think I'll be able to fix this myself, but I'll try to check if I can tweak some stuff and fix this. But I would be really grateful if someone from the maintainers can help me with the |
My ANTLR Version: 4.13.1
Target: Cpp
Compiler: Ninja, CMake and GCC, CMAKE both give this error
I am using Ubuntu 20.04
Clarification: I have not asked at StackOverflow about my issue, but there already exists an question about this issue there, which can be found here which uses ANTLR version 4.11.1, and the response there indicates that it might be an ANTLR bug.
Also, I am able to reproduce this in the latest ANTLR release too. Hence I am filing the issue here.
This issue can be reproduced using the runtime/Cpp/demo project too, hence I am not providing a minimum reproducible grammar or code.
Expected Behaviour: Correct Lexing and Parsing without error.
Actual Behaviour:
Also, I tried to do some debugging, and it turns out that this error is throws when the TLexer object is initialized. More specifically, the error comes from the static method named initialize inside the generated lexer class.
Please note that the build and linking is successfull, and I have linked the PThreads library.
Please look into this as soon as possible. Thank you very much! :)
The text was updated successfully, but these errors were encountered: