raft icon indicating copy to clipboard operation
raft copied to clipboard

null pointer dereference on raft_periodic

Open skorokhod opened this issue 8 years ago • 2 comments

call of raft_periodic with the only non-self node added causes the library to crash there:

    if (1 == raft_get_num_voting_nodes(me_) &&
        raft_node_is_voting(raft_get_my_node((void*)me)) &&
        !raft_is_leader(me_))
        raft_become_leader(me_);

because raft_get_my_node return null. null pointer check should be added.

skorokhod avatar Jun 28 '17 21:06 skorokhod

and the same kind of issue is in raft_periodic there:

        if (1 < raft_get_num_voting_nodes(me_) && raft_node_is_voting(raft_get_my_node(me_)))
            raft_election_start(me_);

but I'm not sure whether we need to start election there or not in this case

skorokhod avatar Jun 28 '17 21:06 skorokhod

Sorry for not getting back to this for a long time.

When this happens it indicates that you didn't do raft_add_node with is_self = 1 for the self node. I am considering adding an if statement check that will return -1 in this situation.

willemt avatar Jan 09 '18 23:01 willemt