OMH4ck / PolyGlot

MIT License
36 stars 6 forks source link

Error when compiling #52

Open vanhauser-thc opened 4 months ago

vanhauser-thc commented 4 months ago

I try to follow the example commands from the README with the supplied LUA grammar, but building polyglot fails:

$ cmake -DCMAKE_BUILD_TYPE=Release -Bbuild -G Ninja -DBUILD_TESTING=OFF -DGRAMMAR_FILE=grammars/lua/Lua.g4
...
LEXER_NAME: Lua
PARSER_NAME: Lua
-- Configuring done
-- Generating done
-- Build files have been written to: /PolyGlot/build

$ ninja -C build
ninja: Entering directory `build'
ninja: error: '../srcs/antlr/grammars/lua/Lua.g4', needed by 'srcs/antlr/generated/LuaBaseListener.cpp', missing and no known rule to make it

what am I doing wrong?

Changochen commented 4 months ago

Sorry about the confusion. You need to specify the full absolute path for the grammar file, please try:

cmake -DCMAKE_BUILD_TYPE=Release -Bbuild -G Ninja -DBUILD_TESTING=OFF -DGRAMMAR_FILE=`pwd`/grammars/lua/Lua.g4

instead.

vanhauser-thc commented 4 months ago

Thanks, yes this makes it work!

Now that I have built Polyglot I try to fuzz mruby, but apparently not much is happening:

AFL_DISABLE_TRIM=1 AFL_FAST_CAL=1 AFL_CUSTOM_MUTATOR_ONLY=1 POLYGLOT_CONFIG=/PolyGlot/grammars/ruby/semantic.yml AFL_CUSTOM_MUTATOR_LIBRARY=/PolyGlot/build/libpolyglot_mutator.so afl-fuzz -i /mruby/test/t -o /share/out-polyglot -- /mruby/bin/mruby @@

image

Changochen commented 4 months ago

Is it not running or not finding new paths? Could you try build/corpus_evaluate --corpus_dir your_corpus to see whether you have a good corpus?

vanhauser-thc commented 4 months ago

Hmm I get this:

/PolyGlot (main) # build/corpus_evaluate --corpus_dir grammars/ruby/corpus/
Unparsable files: (TOTAL42 )
grammars/ruby/corpus/float.rb
[...]
grammars/ruby/corpus/basicobject.rb
Missing types in corpus: 
statement
args
program
val
sntart

the corpus directory has 42 files and it lists all files as unparsable (these files are the mruby test files)

for completeness, this is the grammars/ruby/semantic.yml file:

---
__comments: ''
InitFileDir: grammars/ruby/corpus/
BuiltinObjFile: ''
IsWeakType: true
SyntaxOnly: true
BasicTypes:
  - ANYTYPE
Changochen commented 4 months ago

The semantic files are not related. Unparsable means the corpus files are not accepted by the grammar. Would you confirm that whether the g4 file is correct? Like, if you build a antlr parser on it, does it parse the corpus file?