mc-imperial / dredd

Framework for evaluating C/C++ compiler testing tools
Apache License 2.0
11 stars 3 forks source link

Error writing JSON data to mutation-info-file due to "Message too deep" #258

Closed JonathanFoo0523 closed 1 month ago

JonathanFoo0523 commented 1 month ago

When applying dredd to the following file:

#include <string>

class StringSwitch {
public:
    StringSwitch(const std::string &str);
    StringSwitch& StartsWith(const std::string &prefix, int value);
    StringSwitch& Default(int value);

    operator int() const;
};

int main() {
    std::string Name = "foo";

    int result = StringSwitch(Name)
        .StartsWith("eg1", 1)
        .StartsWith("eg2", 2)
        .StartsWith("eg3", 3)
        .StartsWith("eg4", 4)
        .StartsWith("eg5", 5)
        .StartsWith("eg6", 6)
        .StartsWith("eg7", 7)
        .StartsWith("eg8", 8)
        .StartsWith("eg9", 9)
        .StartsWith("eg10", 10)
        .StartsWith("eg11", 11)
        .StartsWith("eg12", 12)
        .StartsWith("eg13", 13)
        .StartsWith("eg14", 14)
        .StartsWith("eg15", 15)
        .StartsWith("eg16", 16)
        .StartsWith("eg17", 17)
        .StartsWith("eg18", 18)
        .StartsWith("eg19", 19)
        .StartsWith("eg20", 20)
        .StartsWith("eg21", 21)
        .StartsWith("eg22", 22)
        .StartsWith("eg23", 23)
        .StartsWith("eg24", 24)
        .StartsWith("eg25", 25)
        .StartsWith("eg26", 26)
        .StartsWith("eg27", 27)
        .StartsWith("eg28", 28)
        .StartsWith("eg29", 29)
        .StartsWith("eg30", 30)
        .StartsWith("eg31", 31)
        .StartsWith("eg32", 32)
        .StartsWith("eg33", 33)
        .StartsWith("eg34", 34)
        .StartsWith("eg35", 35)
        .StartsWith("eg36", 36)
        .StartsWith("eg37", 37)
        .StartsWith("eg38", 38)
        .StartsWith("eg39", 39)
        .StartsWith("eg40", 40)
        .StartsWith("eg41", 41)
        .StartsWith("eg42", 42)
        .StartsWith("eg43", 43)
        .StartsWith("eg44", 44)
        .StartsWith("eg45", 45)
        .StartsWith("eg46", 46)
        .StartsWith("eg47", 47)
        .StartsWith("eg48", 48)
        .StartsWith("eg49", 49)
        .StartsWith("eg50", 50)
        .StartsWith("eg51", 51)
        .StartsWith("eg52", 52)
        .StartsWith("eg53", 53)
        .StartsWith("eg54", 54)
        .StartsWith("eg55", 55)
        .StartsWith("eg56", 56)
        .StartsWith("eg57", 57)
        .Default(0);

    return 0;
}

dredd fails with the following error:

Error writing JSON data to mutation_info.json"

Upon inspecting the dredd source code and making slight modifications to capture error messages from google::protobuf::util::MessageToJsonString, the root cause was identified as:

INVALID_ARGUMENT:Message too deep. Max recursion depth reached for type 'dredd.protobufs.SourceLocation', field 'start'

I suggest implementing fixes that not only resolve the recursion depth problem but also enhance logging to provide more detailed error information when failures occur during JSON data writing.

afd commented 1 month ago

Duplicate of #192 - @JamesLee-Jones also ran into this problem (but on a different codebase).

We should indeed look into how to fix it or work around it.

JonathanFoo0523 commented 1 month ago

I will look into the thread. Will close this issue due to duplicate.