Dear All,<br><br>It seems to me that there is a bug in lq_avl.c that causes the system to crash under some scenarios. In my application, the crash sometimes happens at the beginning when a node is joining the network, or in another scenario of 3 nodes, when one of the nodes leaves the network, one of the 2 remaining nodes crashes.
<br><br>I traced the reason for the crash and it happens through the following functions at lq_route.c and lq_avl.c: olsr_calculate _lq_routing_table() -> add_vertex() -> avl_insert() -> post_insert() -> rotate_left()
<br><br>///////////////////////////////////////////////////////////////////////////////////////////////////////////<br>static void rotate_left (struct avl_tree *tree, struct avl_node *node)<br>{<br> struct avl_node *right, *parent;
<br> <br> right = node->right;<br> parent = node->parent;<br><br> right->parent = parent;<br> node->parent = right;<br><span style="font-family: monospace;"></span>///////////////////////////////////////////////////////////////////////////////////////////////////////////////
<br><br>In some cases right is NULL, causing right->parent to cause a segmentation fault.<br><br>To fix this problem I added:<br>if (!right) return; <br>before <br>right->parent = parent;<br><br>(and a similar check to rotate_right: if (!left) return; before left->parent = parent;)
<br><br>which seems to be working fine in my small topology.<br><br>I haven't looked into the code in detail, so I would appreciate if other developers who are more involved with the code let me know if that makes sense and whether this fix is sufficient and does not have other consequuences.
<br><br>Best Regards,<br>Karim<br>