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

How to use protobuf_mutator::Mutator::Mutate #199

Open
WhereIsOops opened this issue Dec 15, 2021 · 0 comments
Open

How to use protobuf_mutator::Mutator::Mutate #199

WhereIsOops opened this issue Dec 15, 2021 · 0 comments

Comments

@WhereIsOops
Copy link

The test code I wrote is as follows:

#include "compare.pb.h"
#include "src/mutator.h"
#include <bits/stdc++.h>

using std::cin;
using std::cout;
using std::endl;

class MyMutator : public protobuf_mutator::Mutator {
};


int main(int argc, char *argv[])
{
    TEST t;
    t.set_a(101);
    t.set_b("testtest");
    cout << t.a() << endl;
    cout << t.b() << endl;

    static MyMutator mutator;
    mutator.Seed(1);
    mutator.Mutate(&t, 100);
    cout << t.a() << endl;
    cout << t.b() << endl;

    return 0;
}

Then use the following method to compile: clang++ compare.cc compare.pb.cc -lprotobuf -lprotobuf-mutator -L /usr/local/lib/ -I /usr/local/include/libprotobuf-mutator

A coredump occurs during the running.
#0 0x00000000004304d5 in TEST_default_instance ()
#1 0x000000000041137c in google::protobuf::Message::GetDescriptor (this=0x7fffffffe328) at external.protobuf/include/google/protobuf/message.h:356
#2 0x000000000040d72e in protobuf_mutator::(anonymous namespace)::CastToAny (message=0x7fffffffe328) at ../src/mutator.cc:387
#3 0x000000000040d6da in protobuf_mutator::(anonymous namespace)::UnpackIfAny (message=warning: RTTI symbol not found for class 'TEST'
...) at ../src/mutator.cc:399
#4 0x000000000040aecd in protobuf_mutator::(anonymous namespace)::UnpackAny (message=warning: RTTI symbol not found for class 'TEST'
..., result=0x7fffffffe250) at ../src/mutator.cc:404
#5 0x000000000040b688 in protobuf_mutator::Mutator::Mutate (this=0x4306e0 main::mutator, message=0x7fffffffe328, max_size_hint=100) at ../src/mutator.cc:639
#6 0x0000000000406d55 in main ()
#7 0x00007ffff77c70b3 in __libc_start_main (main=0x406b80

, argc=1, argv=0x7fffffffe468, init=, fini=, rtld_fini=, stack_end=0x7fffffffe458) at ../csu/libc-start.c:308
#8 0x0000000000406abe in _start ()

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