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

Seems broken with latest AFL++ ? #53

Open
20urc3 opened this issue Oct 23, 2024 · 3 comments
Open

Seems broken with latest AFL++ ? #53

20urc3 opened this issue Oct 23, 2024 · 3 comments

Comments

@20urc3
Copy link
Contributor

20urc3 commented Oct 23, 2024

/home/s0urc3/Downloads/Grammar-Mutator/third_party/antlr4-cpp-runtime/antlr4-cpp-runtime-src/runtime/src/support/Any.h:125:51: error: self-comparison always evaluates to true [-Werror=tautological-compare]
  125 |     template<int N = 0, typename std::enable_if<N == N && std::is_nothrow_copy_constructible<T>::value, int>::type = 0>
      |                                                 ~~^~~~
/home/s0urc3/Downloads/Grammar-Mutator/third_party/antlr4-cpp-runtime/antlr4-cpp-runtime-src/runtime/src/support/Any.h:130:51: error: self-comparison always evaluates to true [-Werror=tautological-compare]
  130 |     template<int N = 0, typename std::enable_if<N == N && !std::is_nothrow_copy_constructible<T>::value, int>::type = 0>
      |                                                 ~~^~~~
/home/s0urc3/Downloads/Grammar-Mutator/third_party/antlr4-cpp-runtime/antlr4-cpp-runtime-src/runtime/src/tree/ParseTree.h:49:18: error: ‘virtual bool antlr4::tree::ParseTree::operator==(const antlr4::tree::ParseTree&) const’ was hidden [-Werror=overloaded-virtual=]
   49 |     virtual bool operator == (const ParseTree &other) const;
      |                  ^~~~~~~~
/home/s0urc3/Downloads/Grammar-Mutator/third_party/antlr4-cpp-runtime/antlr4-cpp-runtime-src/runtime/src/RuleContext.h:131:10: note:   by ‘bool antlr4::RuleContext::operator==(const antlr4::RuleContext&)’
  131 |     bool operator == (const RuleContext &other) { return this == &other; } // Simple address comparison.
      |          ^~~~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [Makefile:51: antlr4_shim.o] Error 1
make[2]: Leaving directory '/home/s0urc3/Downloads/Grammar-Mutator/lib/antlr4_shim'
make[1]: *** [Makefile:25: antlr4_shim] Error 2
make[1]: Leaving directory '/home/s0urc3/Downloads/Grammar-Mutator/lib'
make: *** [GNUmakefile:120: build_lib] Error 2
@domenukk
Copy link
Member

Maybe try either updating antlr4-cpp-runtime or disable these errors?

@20urc3
Copy link
Contributor Author

20urc3 commented Oct 25, 2024

Tried latest version of antlr4 and the one from the readme. Got this error again, which is weird bc it used to work perfectly fine

gnu++14 -fPIC -Wno-attributes -Wall -Wextra -Werror -O3 -o antlr4_shim.o -c antlr4_shim.cpp
In file included from /home/s0urc3/Downloads/Grammar-Mutator/third_party/antlr4-cpp-runtime/antlr4-cpp-runtime-src/runtime/src/tree/ParseTree.h:8,
                 from /home/s0urc3/Downloads/Grammar-Mutator/third_party/antlr4-cpp-runtime/antlr4-cpp-runtime-src/runtime/src/RuleContext.h:8,
                 from /home/s0urc3/Downloads/Grammar-Mutator/third_party/antlr4-cpp-runtime/antlr4-cpp-runtime-src/runtime/src/ParserRuleContext.h:8,
                 from /home/s0urc3/Downloads/Grammar-Mutator/third_party/antlr4-cpp-runtime/antlr4-cpp-runtime-src/runtime/src/InterpreterRuleContext.h:8,
                 from /home/s0urc3/Downloads/Grammar-Mutator/third_party/antlr4-cpp-runtime/antlr4-cpp-runtime-src/runtime/src/antlr4-runtime.h:30,
                 from antlr4_shim.cpp:21:
/home/s0urc3/Downloads/Grammar-Mutator/third_party/antlr4-cpp-runtime/antlr4-cpp-runtime-src/runtime/src/support/Any.h:125:51: error: self-comparison always evaluates to true [-Werror=tautological-compare]
  125 |     template<int N = 0, typename std::enable_if<N == N && std::is_nothrow_copy_constructible<T>::value, int>::type = 0>
      |                                                 ~~^~~~
/home/s0urc3/Downloads/Grammar-Mutator/third_party/antlr4-cpp-runtime/antlr4-cpp-runtime-src/runtime/src/support/Any.h:130:51: error: self-comparison always evaluates to true [-Werror=tautological-compare]
  130 |     template<int N = 0, typename std::enable_if<N == N && !std::is_nothrow_copy_constructible<T>::value, int>::type = 0>
      |                                                 ~~^~~~
/home/s0urc3/Downloads/Grammar-Mutator/third_party/antlr4-cpp-runtime/antlr4-cpp-runtime-src/runtime/src/tree/ParseTree.h:49:18: error: ‘virtual bool antlr4::tree::ParseTree::operator==(const antlr4::tree::ParseTree&) const’ was hidden [-Werror=overloaded-virtual=]
   49 |     virtual bool operator == (const ParseTree &other) const;
      |                  ^~~~~~~~
/home/s0urc3/Downloads/Grammar-Mutator/third_party/antlr4-cpp-runtime/antlr4-cpp-runtime-src/runtime/src/RuleContext.h:131:10: note:   by ‘bool antlr4::RuleContext::operator==(const antlr4::RuleContext&)’
  131 |     bool operator == (const RuleContext &other) { return this == &other; } // Simple address comparison.
      |          ^~~~~~~~
In file included from antlr4_shim.cpp:22:
./generated/GrammarLexer.h:263:16: error: ‘SerializedATNView’ in namespace ‘antlr4::atn’ does not name a type
  263 |   antlr4::atn::SerializedATNView getSerializedATN() const override;
      |                ^~~~~~~~~~~~~~~~~
In file included from antlr4_shim.cpp:23:
./generated/GrammarParser.h:256:64: error: ‘ParserATNSimulatorOptions’ in namespace ‘antlr4::atn’ does not name a type; did you mean ‘ParserATNSimulator’?
  256 |   GrammarParser(antlr4::TokenStream *input, const antlr4::atn::ParserATNSimulatorOptions &options);
      |                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                                ParserATNSimulator
./generated/GrammarParser.h:268:16: error: ‘SerializedATNView’ in namespace ‘antlr4::atn’ does not name a type
  268 |   antlr4::atn::SerializedATNView getSerializedATN() const override;
      |                ^~~~~~~~~~~~~~~~~
antlr4_shim.cpp: In function ‘tree_t* tree_from_buf(const uint8_t*, size_t)’:
antlr4_shim.cpp:84:22: error: cannot declare variable ‘lexer’ to be of abstract type ‘GrammarLexer’
   84 |     GrammarLexer     lexer(&input);
      |                      ^~~~~
./generated/GrammarLexer.h:12:8: note:   because the following virtual functions are pure within ‘GrammarLexer’:
   12 | class  GrammarLexer : public antlr4::Lexer {
      |        ^~~~~~~~~~~~
In file included from /home/s0urc3/Downloads/Grammar-Mutator/third_party/antlr4-cpp-runtime/antlr4-cpp-runtime-src/runtime/src/Lexer.h:8,
                 from /home/s0urc3/Downloads/Grammar-Mutator/third_party/antlr4-cpp-runtime/antlr4-cpp-runtime-src/runtime/src/antlr4-runtime.h:31:
/home/s0urc3/Downloads/Grammar-Mutator/third_party/antlr4-cpp-runtime/antlr4-cpp-runtime-src/runtime/src/Recognizer.h:28:45: note:     ‘virtual const std::vector<std::__cxx11::basic_string<char> >& antlr4::Recognizer::getTokenNames() const’
   28 |     virtual std::vector<std::string> const& getTokenNames() const = 0;
      |                                             ^~~~~~~~~~~~~
antlr4_shim.cpp:91:19: error: cannot declare variable ‘parser’ to be of abstract type ‘GrammarParser’
   91 |     GrammarParser parser(&tokens);
      |                   ^~~~~~
./generated/GrammarParser.h:12:8: note:   because the following virtual functions are pure within ‘GrammarParser’:
   12 | class  GrammarParser : public antlr4::Parser {
      |        ^~~~~~~~~~~~~
/home/s0urc3/Downloads/Grammar-Mutator/third_party/antlr4-cpp-runtime/antlr4-cpp-runtime-src/runtime/src/Recognizer.h:28:45: note:     ‘virtual const std::vector<std::__cxx11::basic_string<char> >& antlr4::Recognizer::getTokenNames() const’
   28 |     virtual std::vector<std::string> const& getTokenNames() const = 0;
      |                                             ^~~~~~~~~~~~~

@strongHunter
Copy link

I have three options to fix the broken build:

  1. Use an older compiler version
  2. Disable the -Werror flag in the build system
  3. Fix the root cause of the problem

1. Older Compiler

The build fails with g++-13 but succeeds with g++-11 (I haven't tested at other compilers). Install the older compiler and run the build:

apt install -y g++-11
mkdir build && cd build
cmake .. -DANTLR_JAR_LOCATION=/path/to/antlr-4.8-complete.jar -DGRAMMAR_FILE=/path/to/Grammar-Mutator/grammars/ruby.json -DCMAKE_CXX_COMPILER=g++-11
cmake --build .

2. Disabling -Werror flag

  1. Create a file named disable_Werror.patch with the following content:
    diff --git a/CMakeLists.txt b/CMakeLists.txt
    index c94eba0..32ba7cf 100644
    --- a/CMakeLists.txt
    +++ b/CMakeLists.txt
    @@ -49,7 +49,7 @@ endif ()
    
    # Set -Wall -Wextra -Werror
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror")
    -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror")
    +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
    
    # Do not disable assertions based on CMAKE_BUILD_TYPE.
    foreach (_build_type "Release" "MinSizeRel" "RelWithDebInfo")
    
  2. Apply the patch:
    git apply disable_Werror.patch
    
  3. Build the project:
    mkdir build && cd build
    cmake .. -DANTLR_JAR_LOCATION=/path/to/antlr-4.8-complete.jar -DGRAMMAR_FILE=/path/to/Grammar-Mutator/grammars/ruby.json
    cmake --build .
    

3. Fix the Root Cause

A Pull Request with the fixes has been created, but it is unlikely to be accepted: PR with fixes. Therefore, here are the instructions to apply the fixes manually:

  1. Start build the project:

    mkdir build && cd build
    cmake .. -DANTLR_JAR_LOCATION=/path/to/antlr-4.8-complete.jar -DGRAMMAR_FILE=/path/to/Grammar-Mutator/grammars/ruby.json
    cmake --build .
    

    * After some time, the build error will appear *

  2. Make changes to build/third_party/antlr4-cpp-runtime/antlr4-cpp-runtime-src/runtime/src/RuleContext.h:

    diff --git a/runtime/src/RuleContext.h b/runtime/src/RuleContext.h
    index 9ee0d2d..9de977a 100755
    --- a/runtime/src/RuleContext.h
    +++ b/runtime/src/RuleContext.h
    @@ -128,6 +128,7 @@ namespace antlr4 {
    
        virtual std::string toString(const std::vector<std::string> &ruleNames, RuleContext *stop);
    
    +    using ParseTree::operator==;
        bool operator == (const RuleContext &other) { return this == &other; } // Simple address comparison.
    
    private:
    
  3. Continue the build with the changes applied:

    cmake --build .
    

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

3 participants