[PATCH v2] testsuite,clang: fix malloc04 and malloctest for on clang
Sebastian Huber
sebastian.huber at embedded-brains.de
Fri Oct 5 11:07:47 UTC 2018
On 05/10/2018 09:57, Daniel Hellstrom wrote:
> malloc04 and malloctest tests from the rtems test-suite fails
> when checking the return value of malloc(). The check is
> optimized away and always fails.
> ---
> testsuites/libtests/malloc04/init.c | 6 ++++++
> testsuites/libtests/malloctest/init.c | 1 +
> 2 files changed, 7 insertions(+)
>
> diff --git a/testsuites/libtests/malloc04/init.c b/testsuites/libtests/malloc04/init.c
> index 632ea28..e3fb3b8 100644
> --- a/testsuites/libtests/malloc04/init.c
> +++ b/testsuites/libtests/malloc04/init.c
> @@ -99,6 +99,7 @@ rtems_task Init(
>
> errno = 0;
> p = malloc( 256 );
> + RTEMS_OBFUSCATE_VARIABLE( p );
> rtems_test_assert( p == NULL );
> rtems_test_assert( errno == ENOMEM );
> rtems_test_assert( sbrk_count == 0 );
> @@ -118,6 +119,7 @@ rtems_task Init(
> rtems_test_assert( sbrk_count == 0 );
>
> p = malloc(257);
> + RTEMS_OBFUSCATE_VARIABLE( p );
> rtems_test_assert( p != NULL );
> rtems_test_assert( sbrk_count == 1 );
>
> @@ -131,6 +133,7 @@ rtems_task Init(
>
> errno = 0;
> p = malloc( sizeof( Malloc_Heap ) );
> + RTEMS_OBFUSCATE_VARIABLE( p );
> rtems_test_assert( p == NULL );
> rtems_test_assert( errno == ENOMEM );
> rtems_test_assert( sbrk_count == 1 );
> @@ -144,10 +147,12 @@ rtems_task Init(
> RTEMS_Malloc_Initialize( &area, 1, NULL );
>
> p = malloc( 128 );
> + RTEMS_OBFUSCATE_VARIABLE( p );
> rtems_test_assert( p != NULL );
> rtems_test_assert( sbrk_count == 0 );
>
> p = malloc( 128 );
> + RTEMS_OBFUSCATE_VARIABLE( p );
> rtems_test_assert( p != NULL );
> rtems_test_assert( sbrk_count == 1 );
>
> @@ -161,6 +166,7 @@ rtems_task Init(
>
> errno = 0;
> p = malloc( 256 );
> + RTEMS_OBFUSCATE_VARIABLE( p );
> rtems_test_assert( p == NULL );
> rtems_test_assert( errno == ENOMEM );
> rtems_test_assert( sbrk_count == 2 );
> diff --git a/testsuites/libtests/malloctest/init.c b/testsuites/libtests/malloctest/init.c
> index 577f557..89b56f8 100644
> --- a/testsuites/libtests/malloctest/init.c
> +++ b/testsuites/libtests/malloctest/init.c
> @@ -1400,6 +1400,7 @@ static void test_early_malloc( void )
> rtems_test_assert( r == q );
>
> s = malloc( 1 );
> + RTEMS_OBFUSCATE_VARIABLE( s );
> rtems_test_assert( s != NULL );
>
> free( s );
This the use of RTEMS_OBFUSCATE_VARIABLE() necessary in all those cases?
It is not clear to me why clang decides to optimize something here.
Which assert statement fails? We should try to better understand what
clang does here.
--
Sebastian Huber, embedded brains GmbH
Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail : sebastian.huber at embedded-brains.de
PGP : Public key available on request.
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
More information about the devel
mailing list