[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#906917: sem_timedwait could always block and returns ETIMEOUT but decrements the value on i686 architecture



On your side, have you been able to reproduce the problem *without*
ASAN, even on a bigger codebase? I wonder if it is actually a side
effect of ASAN.

All sem_timedwait calls do not work in the codebase of our project without ASAN. So we cannot use i386 hardware in our embedded systems. Codebase is about 1000 source files. But the minimal test passes without ASAN so I cannot determine what affects sem_timedwait in our project. Any thoughts?

вс, 30 дек. 2018 г. в 22:31, Aurelien Jarno <aurelien@aurel32.net>:
Hi,

On 2018-08-22 13:02, Андрей Доценко wrote:
> Package: libc6
> Version: 2.24-11+deb9-u3
>
> Using sem_timedwait on i686 gives random results. In out proprietary
> software semaphore used by two processes and located in shared memory
> mapped with mmap. All works under amd64 architecture and under another some
> distibutions. But under Debian Stretch amd64 sem_timedwait always blocks
> for timeout and returns ETIMEOUT error. Meanwhile it acquires the lock
> decreasing semaphore value.
>
> I've tried to make test for this bug. Test reproduces bug only with ASAN
> enabled. Without ASAN enabled it always passes. I've attached test but
> without ASAN support to show that I don't miss anything. I can modify test
> to enable ASAN support but if somebody ask.

Thanks, I have been able to reproduce the problem here, even with glibc
2.29. I have attached a version which doesn't need cmake nor check.

On your side, have you been able to reproduce the problem *without*
ASAN, even on a bigger codebase? I wonder if it is actually a side
effect of ASAN.

> I've discovered that symbols used by i686 are different from those from
> amd64. On amd64 symbols are:
> ~$ nm "${PROJ_PATH}/Docker/debian/9/amd64/test-bugs/test-bugs"  | grep sem_
>                  U sem_destroy@@GLIBC_2.2.5
>                  U sem_getvalue@@GLIBC_2.2.5
>                  U sem_init@@GLIBC_2.2.5
>                  U sem_post@@GLIBC_2.2.5
>                  U sem_timedwait@@GLIBC_2.2.5
> 00000000004019b0 t test_process_sem_timedwait
> 00000000004011c0 t test_process_sem_timedwait_nolock
>
> But under i686 symbols are different:
> ~$ nm "${PROJ_PATH}/Docker/debian/9/i386/test-bugs/test-bugs"  | grep sem_
>          U sem_destroy@@GLIBC_2.1
>          U sem_getvalue@@GLIBC_2.1
>          U sem_init@@GLIBC_2.1
>          U sem_post@@GLIBC_2.1
>          U sem_timedwait@@GLIBC_2.2
> 08049f50 t test_process_sem_timedwait
> 08048ee0 t test_process_sem_timedwait_nolock
>
> As you can see symbols are different for i686. Version of sem_init,
> sem_wait, sem_post, sem_destroy and sem_getvalue is GLIBC_2.1, but version
> of sem_timedwait is GLIBC_2.2.

This is perfectly normal. glibc 2.2.5 is the first glibc version that
supported the amd64 architecture.

> Replacing sem_timedwait with sem_wait makes all work on i686 architecture.
> So sem_wait is ok, but sem_timedwait is not.

I confirm that.

Regards,
Aurelien

--
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
aurelien@aurel32.net                 http://www.aurel32.net


--
Андрей Николаевич, инженер-программист.

Reply to: