[SSSD] [PATCH] sss_client: Fix race condition in memory cache

Michal Židek mzidek at redhat.com
Mon Nov 24 15:05:48 UTC 2014


On 11/24/2014 09:43 AM, Lukas Slebodnik wrote:
> ehlo,
>
> The commit message is quite self explanatory.
>
> The attached file "test.c" is a simple reproducer for crash.
> It shoudl be executed as user from sssd becuasde it call getuid() or
> getgid(). In infinite loop, the program calls getpwuid_r() or getgrgid_r()
> in threads (count of threads is specified from command line).
>
> While test program is running you can call sss_cache -E (-U -G) to invalidate
> cache ( or better "while true; do sss_cache -G; usleep 100; done")
>
> There should not be crash with attached patch, but it isn't 100% reproducer
> because it's difficult to reproduce race condition. I was able to find problem
> in my code even thout the program didn't crashed for 5 minutes.
>
> You can also test that memory cahce is used after reinitialisation.
>      strace -p `pgrep test_prog` -f -e trace=sendto
>
> LS
>
> BTW: unit test from mail [1] will pass with small change.
>
> diff --git a/src/tests/cmocka/test_mc_client.c b/src/tests/cmocka/test_mc_client.c
> index 4347cce..99d922a 100644
> --- a/src/tests/cmocka/test_mc_client.c
> +++ b/src/tests/cmocka/test_mc_client.c
> @@ -262,7 +262,7 @@ static void test_client_reinit_race_condition(void **state)
>
>       will_return(__wrap_sss_nss_check_header, CALL_THREAD1);
>       will_return(__wrap_sss_nss_check_header, CALL_THREAD2);
> -    sss_will_return_always(__wrap_sss_nss_check_header, 3);
> +    /* sss_will_return_always(__wrap_sss_nss_check_header, 3); */
>
>       ret = pthread_barrier_init(&barr, NULL, THREADS_COUNT);
>       assert_int_equal(ret, 0);
>
> [1] https://lists.fedorahosted.org/pipermail/sssd-devel/2014-November/022436.html
>

Patch 1:
Ack.

Patch 2:
Ack.

Thank you for the test.c program.

Michal



More information about the sssd-devel mailing list