Skip to content

cryptic segfault? #1361

@UltraBlackLinux

Description

@UltraBlackLinux

Hey there,
I have a very weird issue, that I've been unable to debug for several hours now. Take a look at this example

void LogicTest2::Base::eval(YAML::Node nodes) {
    for (YAML::const_iterator it = nodes.begin(); it != nodes.end(); ++it) {
        std::string tag = it->first.as<std::string>();
        for (std::vector<ConditionalAction*> condActs : conditions_) {
            for (ConditionalAction* act : *condActs) {
                 bool exists = nodes[act->key] && true;
  • Commenting out tag moves the sigsegv to the act for-loop.
  • Commenting out exists makes the crash vanish
    But
  • act and its variables are all non-nullptr
  • it->first is non-nullptr

At this point I've frankly run out of ideas on how to debug this. I've tried to create a MVP for the crash but I haven't been able to. What you see here is pretty much the most I could condense it down, as every part seems to play a role in this in some way...
I'm frankly unsure if this library is even at fault here, but I've at this point checked everything I could.
Any ideas?
Thanks!

Edit: Stacktrace with the line it segfaulted on:

Image

Edit 2: After some fiddling around it turns out that storing all key/value pairs into a map and then iterating over the map also prevents the crash from happening:

    std::map<std::string, YAML::Node> nodeslist = {};
    for (YAML::const_iterator it = nodes.begin(); it != nodes.end(); ++it) {
        nodeslist.insert({it->first.as<std::string>(), it->second});
    }
    for (auto node : nodeslist) {
        std::string tag = node.first;

Edit 3: The entire source code is now here: https://chonkyrabbit.eu/git/ricecooker.git/tree/src/app/yaml/fluent-yaml.cpp#n85

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions