Skip to content
This repository has been archived by the owner on Nov 18, 2022. It is now read-only.

Add Polyjuice Generator Fuzzer and test contracts on x86 with sanitizers #49

Merged
merged 33 commits into from
Jul 2, 2021

Conversation

Flouse
Copy link
Collaborator

@Flouse Flouse commented Jul 1, 2021

These three file were created to simulate gw_syscalls:

  • polyjuice-tests/fuzz/ckb_syscalls.h
  • polyjuice-tests/fuzz/mock_generator_utils.h (will be deprecated and follow the newest version of deps/godwoken-scripts/c/generator_utils.h)
  • polyjuice-tests/fuzz/mock_godwoken.hpp

FuzzTest CI status

FuzzTest

Polyjuice Generator Fuzzer

cd polyjuice-tests/fuzz
make build/polyjuice_generator_fuzzer
./build/polyjuice_generator_fuzzer

General Algorithm

// pseudo code
Instrument program for code coverage
load pre-defined transactions such as contracts deploying and then execute run_polyjuice()
while(true) {
  Choose random input from corpus
  Mutate/populate input into transactions
  Execute run_polyjuice() and collect coverage
  If new coverage/paths are hit add it to corpus (corpus - directory with test-cases)
}

test_contracts on x86 with sanitizers

cd polyjuice-tests/fuzz

make build/test_contracts
./build/test_contracts

make build/test_rlp
./build/test_rlp

Coverage Report[WIP]

TBD

floustar added 27 commits July 1, 2021 13:36
[debug] success => 279
LLVMSymbolizer: error reading file: No such file or directory

=================================================================
==1038102==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 6770 byte(s) in 286 object(s) allocated from:
    #0 0x49908d in malloc /home/nnelson/Documents/llvm-project/llvm/utils/release/final/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:145:3
    #1 0x54a4f0 in hex2bin(char const*, unsigned char**, unsigned long*) /home/flouse/godwoken-polyjuice/polyjuice-tests/fuzz/../../c/tests/./test_utils.h:11:21
    #2 0x7ffcb5cfcea7  ([stack]+0x1fea7)

Direct leak of 5720 byte(s) in 286 object(s) allocated from:
    #0 0x49908d in malloc /home/nnelson/Documents/llvm-project/llvm/utils/release/final/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:145:3
    #1 0x54a4f0 in hex2bin(char const*, unsigned char**, unsigned long*) /home/flouse/godwoken-polyjuice/polyjuice-tests/fuzz/../../c/tests/./test_utils.h:11:21
    #2 0x4084ff  (/home/flouse/godwoken-polyjuice/polyjuice-tests/fuzz/build/test_rlp+0x4084ff)

Direct leak of 5720 byte(s) in 286 object(s) allocated from:
    #0 0x49908d in malloc /home/nnelson/Documents/llvm-project/llvm/utils/release/final/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:145:3
    #1 0x54a4f0 in hex2bin(char const*, unsigned char**, unsigned long*) /home/flouse/godwoken-polyjuice/polyjuice-tests/fuzz/../../c/tests/./test_utils.h:11:21
    #2 0x7f5fc8bf11af  (/lib/x86_64-linux-gnu/libstdc++.so.6+0x2151af)

SUMMARY: AddressSanitizer: 18210 byte(s) leaked in 858 allocation(s).
* compile with -DNO_DEBUG_LOG to erase debug logs
- sanitize=address,undefined
@Flouse Flouse changed the title Fuzz v1 Add Polyjuice Generator Fuzzer and test contracts on x86 with sanitizers Jul 1, 2021
@TheWaWaR TheWaWaR merged commit 4021a6b into godwokenrises:main Jul 2, 2021
@Flouse Flouse deleted the fuzz-v1 branch July 26, 2021 06:06
@Flouse Flouse mentioned this pull request Aug 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants