google / google/libprotobuf-mutator

How to use protobuf_mutator::Mutator::Mutate

Open
#199 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
667
Forks
134
PR merge metrics
No merged PRs in 30d

Description

The test code I wrote is as follows:
```
#include "compare.pb.h"
#include "src/mutator.h"
#include

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 , 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 ()

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.