Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

address sanitizer option detect segv in es_UT.c #2553

Closed
avan989 opened this issue Apr 24, 2024 · 0 comments · Fixed by #2554
Closed

address sanitizer option detect segv in es_UT.c #2553

avan989 opened this issue Apr 24, 2024 · 0 comments · Fixed by #2554

Comments

@avan989
Copy link
Contributor

avan989 commented Apr 24, 2024

Describe the bug
When run with address sanitizer option the following error occurs:

AddressSanitizer:DEADLYSIGNAL
=================================================================
==9380==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7f63fa6e4926 bp 0x7ffe746f7540 sp 0x7ffe746f6c88 T0)
==9380==The signal is caused by a READ memory access.
==9380==Hint: address points to the zero page.
    #0 0x7f63fa6e4926 in __sanitizer::internal_strlen(char const*) ../../../../src/libsanitizer/sanitizer_common/sanitizer_libc.cpp:167
    #1 0x7f63fa677f27 in printf_common ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors_format.inc:490
    #2 0x7f63fa679f75 in __interceptor_vsnprintf ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:1664
    #3 0x5631161e6d00 in CFE_ES_SysLog_vsnprintf /home/vboxuser/Desktop/cFS/cfe/modules/es/fsw/src/cfe_es_syslog.c:390
    #4 0x5631161963d8 in ES_UT_SysLog_snprintf /home/vboxuser/Desktop/cFS/cfe/modules/es/ut-coverage/es_UT.c:226
    #5 0x5631161b8431 in TestAPI /home/vboxuser/Desktop/cFS/cfe/modules/es/ut-coverage/es_UT.c:4559
    #6 0x56311620df71 in UtTest_Run /home/vboxuser/Desktop/cFS/osal/ut_assert/src/uttest.c:172
    #7 0x56311620e9be in OS_Application_Run /home/vboxuser/Desktop/cFS/osal/ut_assert/src/utbsp.c:230
    #8 0x563116228d05 in main /home/vboxuser/Desktop/cFS/osal/src/bsp/generic-linux/src/bsp_start.c:244
    #9 0x7f63fa41b082 in __libc_start_main ../csu/libc-start.c:308
    #10 0x563116195b3d in _start (/home/vboxuser/Desktop/cFS/build/exe/cpu1/coverage-es-ALL-testrunner+0x41b3d)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV ../../../../src/libsanitizer/sanitizer_common/sanitizer_libc.cpp:167 in __sanitizer::internal_strlen(char const*)
==9380==ABORTING

The cause seems to be that one of the coverage tests is trying to pass a null to an snprintf:

UtAssert_VOIDCALL(ES_UT_SysLog_snprintf(SysLogBuf, sizeof(SysLogBuf), NULL));

To Reproduce
Steps to reproduce the behavior:

  1. Add in the following compiler options:
    add_compile_options(-fsanitize=address -g)
    add_link_options(-fsanitize=address)

  2. Do make install ENABLE_UNIT_TESTS=true

  3. Run test

Expected behavior
Error out.

Code snips
If applicable, add references to the software.

System observed on:

  • Hardware
  • OS: [e.g. Linux 4.4]
  • Versions [e.g. cFE 6.6, OSAL 4.2, PSP 1.3 for mcp750, any related apps]

Additional context
Add any other context about the problem here.

Reporter Info
Full name and company/organization if applicable
Anh Van. GSFC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant