From jose.calhariz at tecnico.ulisboa.pt Tue Jan 10 11:35:47 2017 From: jose.calhariz at tecnico.ulisboa.pt (Jose M Calhariz) Date: Tue, 10 Jan 2017 19:35:47 +0000 Subject: [Xorp-users] A possible fix for g++ 6 Message-ID: <20170110193547.GA16880@calhariz.com> Hi, A user of xorp in Debian have found that in some situations xorp fails during initialization with a NULL pointer possibly because of new optimizations in g++ 6. Is possible to review the patch that he sent me? The patch is in attach. Kind regards Jose M Calhariz -- -- Os jogadores de videogame s?o pessoas normais, que tomam sorvete pela testa como todo mundo! -------------- next part -------------- Description: Add some null pointer checks to avoid segfaults. When compiled using gcc 6, the initialization process generates segfaults at some null pointer dereferences. This problem was probably exposed by the behaviour of -fdelete-null-pointer-checks in gcc 6. Author: Dhionel D?az Last-Update: 2017-01-04 --- --- a/libxorp/trie.hh +++ b/libxorp/trie.hh @@ -623,7 +623,7 @@ * */ iterator lookup_node(const Key & k) const { - Node *n = _root->find(k); + Node *n = (_root) ? _root->find(k) : NULL; return (n && n->k() == k) ? iterator(n) : end(); } @@ -632,7 +632,7 @@ * the key passed as parameter. */ iterator search_subtree(const Key &key) const { - return iterator(_root->find_subtree(key), key); + return (_root) ? iterator(_root->find_subtree(key), key) : end(); } /** @@ -648,7 +648,7 @@ Key x(key.masked_addr(), key.prefix_len() - 1); - return iterator(_root->find(x)); + return (_root) ? iterator(_root->find(x)) : end(); } /** -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 819 bytes Desc: Digital signature Url : http://mailman.ICSI.Berkeley.EDU/pipermail/xorp-users/attachments/20170110/ef2d116b/attachment.bin From greearb at candelatech.com Tue Jan 10 11:40:47 2017 From: greearb at candelatech.com (Ben Greear) Date: Tue, 10 Jan 2017 11:40:47 -0800 Subject: [Xorp-users] A possible fix for g++ 6 In-Reply-To: <20170110193547.GA16880@calhariz.com> References: <20170110193547.GA16880@calhariz.com> Message-ID: <1edbe413-809f-8349-e0f6-a64ac616214f@candelatech.com> I would be interested in seeing a backtrace if the user has it so I could better understand the problem. Maybe the code should never actually be trying to call these methods if _root is NULL? Thanks, Ben On 01/10/2017 11:35 AM, Jose M Calhariz wrote: > > Hi, > > A user of xorp in Debian have found that in some situations xorp fails > during initialization with a NULL pointer possibly because of new > optimizations in g++ 6. > > Is possible to review the patch that he sent me? The patch is in > attach. > > Kind regards > Jose M Calhariz > > > > _______________________________________________ > Xorp-users mailing list > Xorp-users at xorp.org > http://mailman.ICSI.Berkeley.EDU/mailman/listinfo/xorp-users > -- Ben Greear Candela Technologies Inc http://www.candelatech.com