[openssl-dev] [openssl.org #3714] OpenSSL 1.0.2 "make test" bus error in evp_test (Solaris 10 Sparc, sun4u)

Andy Polyakov appro at openssl.org
Tue Feb 24 22:27:50 UTC 2015


> Adding volatile first results in new compiler warnings:

The purpose of exercise was not to find a solution, but to simply see
how compiler reacts at volatile. Thanks for taking time.

> ccm128.c: In function 'CRYPTO_ccm128_decrypt':
> ccm128.c:300:9: warning: passing argument 1 of 'memcpy' discards
> 'volatile' qualifier from pointer target type
>          memcpy(temp.c, inp, 16);
>          ^
> 
> And then it also changes the resulting code:
> 
> -       ldd     [%i4], %i2
> +       call    memcpy, 0
> ^^^ that's probably the memcpy() that was optimized away before

Yes, obviously volatile prevented compiler from optimizing memcpy
altogether. Which kind of contradicts the warning. I mean doesn't
warning say "I'm going to go ahead and ignore qualifier", but it didn't.
Anyway, the hope was that compiler would still inline memcpy, but would
be forced to actually write value to temp, that would have to be
aligned. Once again, it was really just a wonder...

> And yes, with volatile the test no longer crashes even when compiled
> with the broken gcc 4.9.1 and -O3.

Naturally, because real memcpy is perfectly capable of handling
misaligned data in any combination. Thanks again.



More information about the openssl-dev mailing list