Skip to content

Commit

Permalink
FreeRTOS_ND_utest: Fix test failures due to missing initialization
Browse files Browse the repository at this point in the history
test_SendPingRequestIPv6_SendToIP_Pass():
This test segfaulted without AddressSanitizer:

    'build/normal/bin/tests/FreeRTOS…' terminated by signal SIGSEGV

test_SendPingRequestIPv6_Assert():

    ==7143==AddressSanitizer CHECK failed: ../../../../src/libsanitizer/asan/asan_descriptions.cpp:80 "((0 && "Address is not in memory and not in shadow?")) != (0)" (0x0, 0x0)
    #0 0x7ff6c812f9a8 in AsanCheckFailed ../../../../src/libsanitizer/asan/asan_rtl.cpp:74
    FreeRTOS#1 0x7ff6c815032e in __sanitizer::CheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) ../../../../src/libsanitizer/sanitizer_common/sanitizer_termination.cpp:78
    FreeRTOS#2 0x7ff6c809fa77 in GetShadowKind ../../../../src/libsanitizer/asan/asan_descriptions.cpp:80
    FreeRTOS#3 0x7ff6c809fa77 in __asan::GetShadowAddressInformation(unsigned long, __asan::ShadowAddressDescription*) ../../../../src/libsanitizer/asan/asan_descriptions.cpp:96
    FreeRTOS#4 0x7ff6c809fa77 in __asan::GetShadowAddressInformation(unsigned long, __asan::ShadowAddressDescription*) ../../../../src/libsanitizer/asan/asan_descriptions.cpp:93
    FreeRTOS#5 0x7ff6c80a1296 in __asan::AddressDescription::AddressDescription(unsigned long, unsigned long, bool) ../../../../src/libsanitizer/asan/asan_descriptions.cpp:441
    FreeRTOS#6 0x7ff6c80a3a84 in __asan::ErrorGeneric::ErrorGeneric(unsigned int, unsigned long, unsigned long, unsigned long, unsigned long, bool, unsigned long) ../../../../src/libsanitizer/asan/asan_errors.cpp:389
    FreeRTOS#7 0x7ff6c812efc5 in __asan::ReportGenericError(unsigned long, unsigned long, unsigned long, unsigned long, bool, unsigned long, unsigned int, bool) ../../../../src/libsanitizer/asan/asan_report.cpp:476
    FreeRTOS#8 0x7ff6c80abc44 in __interceptor_memset ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:799
    FreeRTOS#9 0x55f2e38a3620 in FreeRTOS_SendPingRequestIPv6 build/u22/Annexed_TCP_Sources/FreeRTOS_ND.c:768
    FreeRTOS#10 0x55f2e3893053 in test_SendPingRequestIPv6_Assert test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c:1065
    FreeRTOS#11 0x55f2e389c5dd in run_test build/u22/FreeRTOS_ND_utest_runner.c:201
    FreeRTOS#12 0x55f2e389ca84 in main build/u22/FreeRTOS_ND_utest_runner.c:252
    FreeRTOS#13 0x7ff6c6bcbd8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)
    FreeRTOS#14 0x7ff6c6bcbe3f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e3f)
    FreeRTOS#15 0x55f2e38873d4 in _start (build/u22/bin/tests/FreeRTOS_ND_utest+0x233d4

test_prvProcessICMPMessage_IPv6_NeighborSolicitationNullEP()
behaved different with and without ASan on Gcc 11.
Without AddressSanitizer on Gcc 11:

    FreeRTOS_ND_utest.c:1427:test_prvProcessICMPMessage_IPv6_NeighborSolicitationNullEP:
    FAIL:Function usGenerateProtocolChecksum.  Called more times than expected.
  • Loading branch information
anordal committed Jun 7, 2024
1 parent 1bfb0b8 commit b3a43bb
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c
Original file line number Diff line number Diff line change
Expand Up @@ -1039,15 +1039,16 @@ void test_SendPingRequestIPv6_NULL_Buffer( void )
*/
void test_SendPingRequestIPv6_Assert( void )
{
NetworkEndPoint_t xEndPoint, * pxEndPoint = &xEndPoint;
NetworkBufferDescriptor_t xNetworkBuffer, * pxNetworkBuffer = &xNetworkBuffer;
NetworkEndPoint_t xEndPoint = { 0 }, * pxEndPoint = &xEndPoint;
NetworkBufferDescriptor_t xNetworkBuffer = { 0 };
uint8_t ucEthernetBuffer[ 1500 ] = { 0 };
IPv6_Address_t xIPAddress;
IPv6_Address_t xIPAddress = { 0 };
size_t uxNumberOfBytesToSend = 100;
BaseType_t xReturn;
uint16_t usSequenceNumber = 1;

xNetworkBuffer.pucEthernetBuffer = ucEthernetBuffer;
xNetworkBuffer.xDataLength = sizeof( ucEthernetBuffer );
( void ) memcpy( xIPAddress.ucBytes, xDefaultIPAddress.ucBytes, ipSIZE_OF_IPv6_ADDRESS );

pxEndPoint->bits.bIPv6 = 1;
Expand All @@ -1059,7 +1060,7 @@ void test_SendPingRequestIPv6_Assert( void )


uxGetNumberOfFreeNetworkBuffers_ExpectAndReturn( 4U );
pxGetNetworkBufferWithDescriptor_ExpectAnyArgsAndReturn( pxNetworkBuffer );
pxGetNetworkBufferWithDescriptor_ExpectAnyArgsAndReturn( &xNetworkBuffer );
xSendEventStructToIPTask_IgnoreAndReturn( pdPASS );

xReturn = FreeRTOS_SendPingRequestIPv6( &xIPAddress, uxNumberOfBytesToSend, 0 );
Expand All @@ -1075,14 +1076,15 @@ void test_SendPingRequestIPv6_Assert( void )
void test_SendPingRequestIPv6_SendToIP_Pass( void )
{
NetworkEndPoint_t xEndPoint, * pxEndPoint = &xEndPoint;
NetworkBufferDescriptor_t xNetworkBuffer, * pxNetworkBuffer = &xNetworkBuffer;
NetworkBufferDescriptor_t xNetworkBuffer = { 0 }, * pxNetworkBuffer = &xNetworkBuffer;
uint8_t ucEthernetBuffer[ 1500 ] = { 0 };
IPv6_Address_t xIPAddress;
size_t uxNumberOfBytesToSend = 100;
BaseType_t xReturn;
uint16_t usSequenceNumber = 1;

xNetworkBuffer.pucEthernetBuffer = ucEthernetBuffer;
xNetworkBuffer.xDataLength = sizeof( ucEthernetBuffer );
( void ) memcpy( xIPAddress.ucBytes, xDefaultIPAddress.ucBytes, ipSIZE_OF_IPv6_ADDRESS );

pxEndPoint->bits.bIPv6 = 1;
Expand Down Expand Up @@ -1460,15 +1462,17 @@ void test_prvProcessICMPMessage_IPv6_ipICMP_PING_REPLY_IPv6_eSuccess( void )
*/
void test_prvProcessICMPMessage_IPv6_NeighborSolicitationNullEP( void )
{
NetworkBufferDescriptor_t xNetworkBuffer, * pxNetworkBuffer = &xNetworkBuffer;
ICMPPacket_IPv6_t xICMPPacket;
NetworkEndPoint_t xEndPoint;
NetworkBufferDescriptor_t xNetworkBuffer = { 0 }, * pxNetworkBuffer = &xNetworkBuffer;
ICMPPacket_IPv6_t xICMPPacket = { 0 };
NetworkEndPoint_t xEndPoint = { 0 };
eFrameProcessingResult_t eReturn;

xEndPoint.bits.bIPv6 = pdTRUE_UNSIGNED;
( void ) memcpy( xEndPoint.ipv6_settings.xIPAddress.ucBytes, xDefaultIPAddress.ucBytes, ipSIZE_OF_IPv6_ADDRESS );
xICMPPacket.xICMPHeaderIPv6.ucTypeOfMessage = ipICMP_NEIGHBOR_SOLICITATION_IPv6;
pxNetworkBuffer->pxEndPoint = &xEndPoint;
pxNetworkBuffer->pucEthernetBuffer = ( uint8_t * ) &xICMPPacket;
pxNetworkBuffer->xDataLength = sizeof( xICMPPacket );

FreeRTOS_InterfaceEPInSameSubnet_IPv6_ExpectAnyArgsAndReturn( NULL );

Expand Down

0 comments on commit b3a43bb

Please sign in to comment.