[cfarm-users] GCC 8.2 UBsan and runtime error: signed integer overflow

Jeffrey Walton noloader at gmail.com
Wed Nov 28 00:06:01 CET 2018


On Tue, Nov 27, 2018 at 3:51 PM Jeffrey Walton <noloader at gmail.com> wrote:
>
> I've got some self tests failing on PowerPC with GCC 8.2. The program
> was compiled with -O1 and -fsanitize=undefined. The program uses
> Altivec. A sample finding is shown below.
>
> ppc_simd.h:965 is a vec_add, and it happens on a unsigned int vector.
> We don't use signed vector types. I don't believe overflow can happen
> and the algorithm depends on unsigned wrap.

This is kind of weird. The template function below is the one
generating the findings. I added two overloads to capture the signed
int vectors. My hope was to brick the program and look at the stack.

The overloads are never used.

I guess this leaves the question, where are the signed types coming
from since they are not from our program.

template <class T1, class T2>
inline T1 VecAdd(const T1 vec1, const T2 vec2)
{
    // ppc_simd.h : 965
    return (T1)vec_add(vec1, (T1)vec2);
}

typedef __vector signed int int32x4_p;
inline int32x4_p VecAdd(const int32x4_p vec1, const int32x4_p vec2)
{
    volatile int* p = NULLPTR;
    *p = 0;
    return vec_add(vec1, vec2);
}

#if defined(_ARCH_PWR8)
typedef __vector signed long long int64x2_p;
inline int64x2_p VecAdd(const int64x2_p vec1, const int64x2_p vec2)
{
    volatile int* p = NULLPTR;
    *p = 0;
    return vec_add(vec1, vec2);
}
#endif


More information about the cfarm-users mailing list