[asterisk-bugs] [JIRA] (ASTERISK-25777) data race in threadpool

Corey Farrell (JIRA) noreply at issues.asterisk.org
Fri Feb 12 10:06:32 CST 2016


     [ https://issues.asterisk.org/jira/browse/ASTERISK-25777?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Corey Farrell updated ASTERISK-25777:
-------------------------------------

    Attachment: ASTERISK-25777.patch

It looks like the problem is that {{worker_start}} checks {{worker->status == ZOMBIE}} after releasing {{worker->lock}}.  The unlock needs to be done after checking status.  This change will require testing so I will post to gerrit once I (or someone else) has had the chance to try the patch.

> data race in threadpool
> -----------------------
>
>                 Key: ASTERISK-25777
>                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-25777
>             Project: Asterisk
>          Issue Type: Bug
>      Security Level: None
>    Affects Versions: 13.7.2
>            Reporter: Badalian Vyacheslav
>         Attachments: ASTERISK-25777.patch
>
>
> {code}
> Asterisk Ready.
> ==================
> WARNING: ThreadSanitizer: data race (pid=6553)
>   Write of size 4 at 0x7d440001dd20 by thread T2 (mutexes: write M969):
>     #0 worker_set_state /root/asterisk/main/threadpool.c:1173 (asterisk+0x00000069680d)
>     #1 worker_shutdown /root/asterisk/main/threadpool.c:979 (asterisk+0x000000695976)
>     #2 worker_thread_destroy /root/asterisk/main/threadpool.c:997 (asterisk+0x000000695b69)
>     #3 __ao2_ref /root/asterisk/main/astobj2.c:528 (asterisk+0x0000002d87e0)
>     #4 thread_worker_pair_destructor /root/asterisk/main/threadpool.c:206 (asterisk+0x00000069170b)
>     #5 __ao2_ref /root/asterisk/main/astobj2.c:528 (asterisk+0x0000002d87e0)
>     #6 queued_idle_thread_dead /root/asterisk/main/threadpool.c:317 (asterisk+0x00000069211b)
>     #7 ast_taskprocessor_execute /root/asterisk/main/taskprocessor.c:850 (asterisk+0x00000067f1bb)
>     #8 default_tps_processing_function /root/asterisk/main/taskprocessor.c:183 (asterisk+0x00000067b1c4)
>     #9 dummy_start /root/asterisk/main/utils.c:1232 (asterisk+0x0000006b6674)
>     #10 <null> <null> (libtsan.so.0+0x000000023659)
>   Previous read of size 4 at 0x7d440001dd20 by thread T7:
>     #0 worker_start /root/asterisk/main/threadpool.c:1040 (asterisk+0x000000695e0a)
>     #1 dummy_start /root/asterisk/main/utils.c:1232 (asterisk+0x0000006b6674)
>     #2 <null> <null> (libtsan.so.0+0x000000023659)
>   Location is heap block of size 272 at 0x7d440001dc40 allocated by thread T2:
>     #0 calloc <null> (libtsan.so.0+0x000000025bed)
>     #1 _ast_calloc /root/asterisk/include/asterisk/utils.h:573 (asterisk+0x0000002d752c)
>     #2 __ao2_alloc /root/asterisk/main/astobj2.c:597 (asterisk+0x0000002d8af6)
>     #3 worker_thread_alloc /root/asterisk/main/threadpool.c:1061 (asterisk+0x000000695f53)
>     #4 grow /root/asterisk/main/threadpool.c:520 (asterisk+0x000000693150)
>     #5 queued_set_size /root/asterisk/main/threadpool.c:837 (asterisk+0x000000694d3b)
>     #6 ast_taskprocessor_execute /root/asterisk/main/taskprocessor.c:850 (asterisk+0x00000067f1bb)
>     #7 default_tps_processing_function /root/asterisk/main/taskprocessor.c:183 (asterisk+0x00000067b1c4)
>     #8 dummy_start /root/asterisk/main/utils.c:1232 (asterisk+0x0000006b6674)
>     #9 <null> <null> (libtsan.so.0+0x000000023659)
>   Mutex M969 (0x7d440001dcd8) created at:
>     #0 pthread_mutex_init <null> (libtsan.so.0+0x000000028645)
>     #1 __ast_pthread_mutex_init /root/asterisk/main/lock.c:149 (asterisk+0x000000503c43)
>     #2 worker_thread_alloc /root/asterisk/main/threadpool.c:1066 (asterisk+0x000000695fe5)
>     #3 grow /root/asterisk/main/threadpool.c:520 (asterisk+0x000000693150)
>     #4 queued_set_size /root/asterisk/main/threadpool.c:837 (asterisk+0x000000694d3b)
>     #5 ast_taskprocessor_execute /root/asterisk/main/taskprocessor.c:850 (asterisk+0x00000067f1bb)
>     #6 default_tps_processing_function /root/asterisk/main/taskprocessor.c:183 (asterisk+0x00000067b1c4)
>     #7 dummy_start /root/asterisk/main/utils.c:1232 (asterisk+0x0000006b6674)
>     #8 <null> <null> (libtsan.so.0+0x000000023659)
>   Thread T2 (tid=7036, 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 stasis_init /root/asterisk/main/stasis.c:1620 (asterisk+0x00000063db9c)
>     #8 asterisk_daemon /root/asterisk/main/asterisk.c:4420 (asterisk+0x0000002d65dd)
>     #9 main /root/asterisk/main/asterisk.c:4230 (asterisk+0x0000002d5cfd)
>   Thread T7 (tid=7041, finished) created by thread T2 at:
>     #0 pthread_create <null> (libtsan.so.0+0x000000027b07)
>     #1 ast_pthread_create_stack /root/asterisk/main/utils.c:1285 (asterisk+0x0000006b6abd)
>     #2 worker_thread_start /root/asterisk/main/threadpool.c:1077 (asterisk+0x000000696200)
>     #3 grow /root/asterisk/main/threadpool.c:525 (asterisk+0x0000006931eb)
>     #4 queued_set_size /root/asterisk/main/threadpool.c:837 (asterisk+0x000000694d3b)
>     #5 ast_taskprocessor_execute /root/asterisk/main/taskprocessor.c:850 (asterisk+0x00000067f1bb)
>     #6 default_tps_processing_function /root/asterisk/main/taskprocessor.c:183 (asterisk+0x00000067b1c4)
>     #7 dummy_start /root/asterisk/main/utils.c:1232 (asterisk+0x0000006b6674)
>     #8 <null> <null> (libtsan.so.0+0x000000023659)
> SUMMARY: ThreadSanitizer: data race /root/asterisk/main/threadpool.c:1173 worker_set_state
> {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)



More information about the asterisk-bugs mailing list