[asterisk-bugs] [JIRA] (ASTERISK-25773) ast flags macros broke atomic thread safe
Badalian Vyacheslav (JIRA)
noreply at issues.asterisk.org
Thu Feb 11 22:14:33 CST 2016
Badalian Vyacheslav created ASTERISK-25773:
----------------------------------------------
Summary: ast flags macros broke atomic thread safe
Key: ASTERISK-25773
URL: https://issues.asterisk.org/jira/browse/ASTERISK-25773
Project: Asterisk
Issue Type: Bug
Security Level: None
Reporter: Badalian Vyacheslav
defines like this broke atomic thread safe
{code}
#define ast_set_flag(p,flag) do { \
typeof ((p)->flags) __p = (p)->flags; \
typeof (__unsigned_int_flags_dummy) __x = 0; \
(void) (&__p == &__x); \
((p)->flags |= (flag)); \
} while(0)
{code}
for add, xor, sub and other you must do for old gcc:
https://gcc.gnu.org/onlinedocs/gcc/_005f_005fsync-Builtins.html
or for new gcc:
https://gcc.gnu.org/onlinedocs/gcc-4.4.5/gcc/Atomic-Builtins.html
or you get data race
{code}
==================
WARNING: ThreadSanitizer: data race (pid=24710)
Write of size 4 at 0x7f5ec5941810 by main thread:
#0 asterisk_daemon /root/asterisk/main/asterisk.c:4691 (asterisk+0x0000002d6ffe)
#1 main /root/asterisk/main/asterisk.c:4230 (asterisk+0x0000002d5cfd)
Previous read of size 4 at 0x7f5ec5941810 by thread T1:
#0 queued_set_size /root/asterisk/main/threadpool.c:825 (asterisk+0x000000694b51)
#1 ast_taskprocessor_execute /root/asterisk/main/taskprocessor.c:850 (asterisk+0x00000067f1bb)
#2 default_tps_processing_function /root/asterisk/main/taskprocessor.c:183 (asterisk+0x00000067b1c4)
#3 dummy_start /root/asterisk/main/utils.c:1232 (asterisk+0x0000006b6674)
#4 <null> <null> (libtsan.so.0+0x000000023659)
Location is global 'ast_options' of size 4 at 0x7f5ec5941810 (asterisk+0x000000a07810)
Thread T1 (tid=25192, running) created by main thread at:
#0 pthread_create <null> (libtsan.so.0+0x000000027b07)
#1 ast_pthread_create_stack /root/asterisk/main/utils.c:1285 (asterisk+0x0000006b6abd)
#2 default_listener_start /root/asterisk/main/taskprocessor.c:200 (asterisk+0x00000067b33a)
#3 __allocate_taskprocessor /root/asterisk/main/taskprocessor.c:682 (asterisk+0x00000067e298)
#4 ast_taskprocessor_get /root/asterisk/main/taskprocessor.c:728 (asterisk+0x00000067e4c1)
#5 threadpool_alloc /root/asterisk/main/threadpool.c:402 (asterisk+0x00000069266e)
#6 ast_threadpool_create /root/asterisk/main/threadpool.c:894 (asterisk+0x000000695202)
#7 ast_sorcery_init /root/asterisk/main/sorcery.c:504 (asterisk+0x00000061d926)
#8 asterisk_daemon /root/asterisk/main/asterisk.c:4383 (asterisk+0x0000002d64cb)
#9 main /root/asterisk/main/asterisk.c:4230 (asterisk+0x0000002d5cfd)
SUMMARY: ThreadSanitizer: data race /root/asterisk/main/asterisk.c:4691 asterisk_daemon
{code}
--
This message was sent by Atlassian JIRA
(v6.2#6252)
More information about the asterisk-bugs
mailing list