volk icon indicating copy to clipboard operation
volk copied to clipboard

Undefined Behaviour in volk_8u_x4_conv_k7_r2_8u

Open argilo opened this issue 8 months ago • 2 comments

UBSAN reports undefined behaviour in this code:

https://github.com/gnuradio/volk/blob/42f57cd67506e7fb6a7795af3948b803de0085f4/kernels/volk/volk_8u_x4_conv_k7_r2_8u.h#L112-L113

Here w is an unsigned int[2], and the s * (sizeof(decision_t) / sizeof(unsigned int)) calculation intentionally reaches outside the bounds of the array to access the sth element of the outer decision_t array d.

It looks like this hack became necessary because sizeof(decision_t) is 8, and yet it is marked as being 16-byte aligned; because of this, accessing d[1] (or any other odd offset) fails due to misalignment. I suspect that the 16-byte alignment of decision_t is incorrect or unnecessary.

argilo avatar Oct 22 '23 19:10 argilo