Re: [vpp-dev] vpp-2206 bug

2022-10-10 Thread Lijian Zhang
Yes, it’s undefined behavior for __builtin_clz with 0 input.

And it seems rare to initialize bihash with 0 bucket, but not sure of the input 
for other use cases with min_log2/max_log2.

Or, there could be a “ASSERT (x != 0)” in min_log2/max_log2 to alert 0 input.

[1]
https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html
Built-in Function: int __builtin_clz (unsigned int x)
Returns the number of leading 0-bits in x, starting at the most significant bit 
position. If x is 0, the result is undefined.
Thanks.
From: vpp-dev@lists.fd.io  On Behalf Of NUAA?? via 
lists.fd.io
Sent: Monday, October 10, 2022 11:11 AM
To: vpp-dev@lists.fd.io
Subject: [vpp-dev] vpp-2206 bug

Hi, vpp experts

when i use bihash_init_8_8 ( p, "test",0,0)function in arm64 machine, it will 
cause abort()
gcc version is 9.3.0

the reason is when buckets is 0, src/vppinfra/clib.h  min_log2() function will 
use count_leading_zero(0), but return value is different between x86 and 
arm64,x86 is 63 but arm64 is 64, it is a undefined behavior for compiler, so 
min_log2() need add a judgement with it


-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#21985): https://lists.fd.io/g/vpp-dev/message/21985
Mute This Topic: https://lists.fd.io/mt/94229490/21656
Group Owner: vpp-dev+ow...@lists.fd.io
Unsubscribe: https://lists.fd.io/g/vpp-dev/leave/1480452/21656/631435203/xyzzy 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[vpp-dev] vpp-2206 bug

2022-10-09 Thread NUAA无痕
Hi, vpp experts

when i use bihash_init_8_8 ( p, "test",0,0)function in arm64 machine, it
will cause abort()
gcc version is 9.3.0

the reason is when buckets is 0, src/vppinfra/clib.h  min_log2() function
will use count_leading_zero(0), but return value is different between x86
and arm64,x86 is 63 but arm64 is 64, it is a undefined behavior for
compiler, so min_log2() need add a judgement with it

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#21979): https://lists.fd.io/g/vpp-dev/message/21979
Mute This Topic: https://lists.fd.io/mt/94229490/21656
Group Owner: vpp-dev+ow...@lists.fd.io
Unsubscribe: https://lists.fd.io/g/vpp-dev/leave/1480452/21656/631435203/xyzzy 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-