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

UCS/GTEST: fixed uninitialized value access #9917

Merged

Conversation

iyastreb
Copy link
Contributor

What

This is fix for RM#3919044
There are multiple test failures reported as:

==54391== Conditional jump or move depends on uninitialised value(s)
==54391==    at 0x50AE1A2: ucs_rcache_check_overlap (rcache.c:860)
==54391==    by 0x50AE1A2: ucs_rcache_create_region (rcache.c:952)
==54391==    by 0x50AE9AB: ucs_rcache_get (rcache.c:1108)
==54391==    by 0xBE26F4: test_rcache::get(void*, unsigned long, int, unsigned long) (test_rcache.cc:109)
==54391==    by 0xBD33E1: test_rcache_basic_Test::test_body() (test_rcache.cc:276)
==54391==    by 0x637499: ucs::test_base::thread_func(void*) (test.cc:397)
==54391==    by 0x995ADD4: start_thread (in /usr/lib64/libpthread-2.17.so)
==54391==  Uninitialised value was created by a stack allocation

Why ?

Function ucs_rcache_check_overlap was modified in #9441, with additional check whether found region is the only element in the list. The issue reported by ASAN and valgrind happens when returned region list is empty. In this case we access some uninitialized data on the stack:

    ucs_list_link_t region_list;
    ucs_list_head_init(&region_list);
    ucs_rcache_find_regions(rcache, *start, *end - 1, &region_list); << returns empty list

    region = ucs_list_next(&region_list, ucs_rcache_region_t, tmp_list); << access non-existing region by offset on the stack

How ?

Added check that returned list is not empty

src/ucs/memory/rcache.c Outdated Show resolved Hide resolved
@yosefe
Copy link
Contributor

yosefe commented Jun 2, 2024

@iyastreb pls squash

@iyastreb iyastreb force-pushed the ucs/gtest/uninitialized-value-access branch from 3e7094e to 5eb2e1f Compare June 2, 2024 10:12
@yosefe yosefe merged commit 20c5ec9 into openucx:master Jun 3, 2024
146 checks passed
@iyastreb iyastreb deleted the ucs/gtest/uninitialized-value-access branch June 3, 2024 08:25
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 this pull request may close these issues.

5 participants