Cmocka conflicts with __attribute__((malloc)) when building the tests with OpenSSL 3.1.0
When building the tests with OpenSSL 3.1.0, there are build errors like this:
CC hmac_test-hmac_test.o
In file included from include/openssl/bio.h:30,
from include/openssl/evp.h:30,
from ../../lib/isc/hmac.c:14,
from hmac_test.c:33:
include/openssl/crypto.h:344:1: error: ‘test_malloc’ attribute directive ignored [-Werror=attributes]
344 | OSSL_CRYPTO_ALLOC void *CRYPTO_malloc(size_t num, const char *file, int line);
| ^~~~~~~~~~~~~~~~~
For GCC, OSSL_CRYPTO_ALLOC
is defined like this in include/openssl/macros.h
:
# define OSSL_CRYPTO_ALLOC __attribute__((malloc))
The compiler error above means that the malloc
attribute has been interpreted as test_malloc
.
Since neither BIND 9 nor OpenSSL 3.1.0 has test_malloc
defined anywhere, next thing to check is cmocka.h
, and there it is:
$ grep 'define malloc' /usr/include/cmocka.h
/usr/include/cmocka.h: * #define malloc(size) _test_malloc(size, __FILE__, __LINE__)
/usr/include/cmocka.h:#define malloc test_malloc