[genode] bug report on nic_bridge

jaeyong yoo y.jaeyong at ...9...
Tue Jan 22 01:22:50 CET 2013


Hello Genode,

I think I found a bug on nic_bridge. Just briefly, nic_bridge uses memcmp
to maintain avl_tree for clients, but genode memcmp impl. is not fully
c-standard compatible.

nic_brdige uses address node which is a avl_tree node that uses
Genode::memcmp to determine which node is higher:
os/src/server/nic_bridge/address_node.h:

                        bool higher(Address_node *c)
                        {
                                using namespace Genode;

                                return (memcmp(&c->_addr.addr, &_addr.addr,
                                               sizeof(_addr.addr)) > 0);
                        }

Genode memcmp is not fully c-standard compatible: it only returns 0 or 1.
base/include/util/string.h:

        /**
         * Compare memory blocks
         *
         * \retval 0  memory blocks are equal
         * \retval 1  memory blocks differ
         *
         * NOTE: This function is not fully compatible to the C standard.
         */
        inline int memcmp(const void *p0, const void *p1, size_t size)
        {
                char *c0 = (char *)p0;
                char *c1 = (char *)p1;

                size_t i;
                for (i = 0; i < size; i++)
                        if (c0[i] != c1[i]) return 1;

                return 0;
        }

which makes Address_node avl_tree only grows in one direction (1 side).
Once the avl_tree is rebalanced, we never reach to the other side (0 side).

best regards,
Jaeyong
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.genode.org/pipermail/users/attachments/20130122/55714b2d/attachment.html>


More information about the users mailing list