route(8) core dump, possible gcc(1) related

Alexander Kabaev kabaev at gmail.com
Sun Dec 16 11:35:02 PST 2007


On Sun, 16 Dec 2007 21:27:17 +0300 (MSK)
Maxim Konovalov <maxim at macomnet.ru> wrote:

> Hello,
> 
> gcc w/ default flags:
> 
> # route add 172.19.16.0.0/16 10.10.10.2
> zsh: segmentation fault (core dumped)
> 
> gcc -O0:
> 
> # route add 172.19.16.0.0/16 10.10.10.2
> route: bad address: 172.19.16.0.0/16
> 
> I failed to find any bugs in this code snippet where route(8)
> dumps a core (line 1041):
> 
>  1033           q = strchr(s,'/');
>  1034           if (q && which == RTA_DST) {
>  1035                   *q = '\0';
>  1036                   if ((val = inet_network(s)) != INADDR_NONE) {
>  1037                           inet_makenetandmask(
>  1038                                   val, &su->sin, strtoul(q+1,
> 0, 0)); 1039                           return (0);
>  1040                   }
>  1041                   *q = '/';
>  1042           }
> 
> Any comments?
> 
Preliminary results show that inet_network from libc is somehow
thrashing $ebx even if it is not supposed to. -O0 disables value
caching in register and always allocates stack slot for the 'q'
pointer, so the problem is not visible.

Thanks for the test case, I'll look some more. 

-- 
Alexander Kabaev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-current/attachments/20071216/9bfcb9ef/signature.pgp


More information about the freebsd-current mailing list