Summary: | ASTERISK-25783: data race in ast_begin_shutdown | ||
Reporter: | Badalian Vyacheslav (slavon) | Labels: | |
Date Opened: | 2016-02-11 23:31:47.000-0600 | Date Closed: | 2016-02-12 14:47:40.000-0600 |
Priority: | Minor | Regression? | |
Status: | Closed/Complete | Components: | |
Versions: | 13.7.2 | Frequency of Occurrence | |
Related Issues: | |||
Environment: | [root@vm-asterisk04t asterisk]# git branch -v * master a394865 Merge "Resources/res_phoneprov: fix memory leak and heap-use-after-free" | Attachments: | ( 0) ASTERISK-25783.patch |
Description: | {code}
================== WARNING: ThreadSanitizer: data race (pid=16961) Write of size 4 at 0x7fb30a8dd064 by main thread (mutexes: write M344395): #0 ast_begin_shutdown /root/asterisk/main/asterisk.c:1819 (asterisk+0x0000002c7343) #1 can_safely_quit /root/asterisk/main/asterisk.c:1909 (asterisk+0x0000002c75ec) #2 quit_handler /root/asterisk/main/asterisk.c:1829 (asterisk+0x0000002c73a7) #3 handle_stop_now /root/asterisk/main/asterisk.c:2353 (asterisk+0x0000002c96b4) #4 ast_cli_command_full /root/asterisk/main/cli.c:2717 (asterisk+0x0000004058fa) #5 consolehandler /root/asterisk/main/asterisk.c:2230 (asterisk+0x0000002c8cca) #6 asterisk_daemon /root/asterisk/main/asterisk.c:4743 (asterisk+0x0000002d7411) #7 main /root/asterisk/main/asterisk.c:4230 (asterisk+0x0000002d5cfd) Previous read of size 4 at 0x7fb30a8dd064 by thread T64 (mutexes: write M44123, write M45314756831139840): #0 ast_shutting_down /root/asterisk/main/asterisk.c:1794 (asterisk+0x0000002c7214) #1 <null> <null> (chan_sip.so+0x0000001ccc19) #2 <null> <null> (chan_sip.so+0x0000001ec44f) #3 <null> <null> (chan_sip.so+0x0000001edbfd) #4 <null> <null> (chan_sip.so+0x0000001ed1c2) #5 ast_io_wait /root/asterisk/main/io.c:292 (asterisk+0x0000004ece92) #6 <null> <null> (chan_sip.so+0x0000001f2283) #7 dummy_start /root/asterisk/main/utils.c:1232 (asterisk+0x0000006b6674) #8 <null> <null> (libtsan.so.0+0x000000023659) Location is global 'shutdown_pending' of size 4 at 0x7fb30a8dd064 (asterisk+0x000000cdc064) Mutex M344395 (0x7fb30a609e00) created at: #0 pthread_mutex_lock <null> (libtsan.so.0+0x000000037816) #1 __ast_pthread_mutex_lock /root/asterisk/main/lock.c:313 (asterisk+0x000000503d01) #2 can_safely_quit /root/asterisk/main/asterisk.c:1884 (asterisk+0x0000002c74f5) #3 quit_handler /root/asterisk/main/asterisk.c:1829 (asterisk+0x0000002c73a7) #4 handle_stop_now /root/asterisk/main/asterisk.c:2353 (asterisk+0x0000002c96b4) #5 ast_cli_command_full /root/asterisk/main/cli.c:2717 (asterisk+0x0000004058fa) #6 consolehandler /root/asterisk/main/asterisk.c:2230 (asterisk+0x0000002c8cca) #7 asterisk_daemon /root/asterisk/main/asterisk.c:4743 (asterisk+0x0000002d7411) #8 main /root/asterisk/main/asterisk.c:4230 (asterisk+0x0000002d5cfd) Mutex M44123 (0x7fb2f25c35a0) created at: #0 pthread_mutex_lock <null> (libtsan.so.0+0x000000037816) #1 __ast_pthread_mutex_lock /root/asterisk/main/lock.c:313 (asterisk+0x000000503d01) #2 <null> <null> (chan_sip.so+0x000000232308) #3 <null> <null> (chan_sip.so+0x00000023d1df) #4 start_resource /root/asterisk/main/loader.c:1015 (asterisk+0x0000004ff12f) #5 load_resource_list /root/asterisk/main/loader.c:1213 (asterisk+0x000000500c7c) #6 load_modules /root/asterisk/main/loader.c:1366 (asterisk+0x000000501ade) #7 asterisk_daemon /root/asterisk/main/asterisk.c:4659 (asterisk+0x0000002d6e5d) #8 main /root/asterisk/main/asterisk.c:4230 (asterisk+0x0000002d5cfd) Mutex M45314756831139840 is already destroyed. Thread T64 (tid=17506, 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 <null> <null> (chan_sip.so+0x0000001f25ec) #3 <null> <null> (chan_sip.so+0x00000023dbb7) #4 start_resource /root/asterisk/main/loader.c:1015 (asterisk+0x0000004ff12f) #5 load_resource_list /root/asterisk/main/loader.c:1213 (asterisk+0x000000500c7c) #6 load_modules /root/asterisk/main/loader.c:1366 (asterisk+0x000000501ade) #7 asterisk_daemon /root/asterisk/main/asterisk.c:4659 (asterisk+0x0000002d6e5d) #8 main /root/asterisk/main/asterisk.c:4230 (asterisk+0x0000002d5cfd) SUMMARY: ThreadSanitizer: data race /root/asterisk/main/asterisk.c:1819 ast_begin_shutdown ================== {code} | ||
Comments: | By: Asterisk Team (asteriskteam) 2016-02-11 23:31:48.790-0600 Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution. A good first step is for you to review the [Asterisk Issue Guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines] if you haven't already. The guidelines detail what is expected from an Asterisk issue report. Then, if you are submitting a patch, please review the [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process]. By: Corey Farrell (coreyfarrell) 2016-02-12 08:55:38.182-0600 [~slavon]: Would your scanner be happy if we just change the definition of {{shutdown_pending}} to be volatile? I'm not sure we really need to lock around the read of shutdown_pending, this feels like overkill for a simple boolean value. By: Badalian Vyacheslav (slavon) 2016-02-12 10:52:57.724-0600 can you give patch to test? I quickly check By: Badalian Vyacheslav (slavon) 2016-02-12 12:06:37.253-0600 volatile does not help... After patch {code} *CLI> core restart now ================== WARNING: ThreadSanitizer: data race (pid=20580) Write of size 4 at 0x7f6c55f1d064 by main thread (mutexes: write M344098): #0 ast_begin_shutdown /root/asterisk/main/asterisk.c:1819 (asterisk+0x0000002c7343) #1 can_safely_quit /root/asterisk/main/asterisk.c:1909 (asterisk+0x0000002c75ec) #2 quit_handler /root/asterisk/main/asterisk.c:1829 (asterisk+0x0000002c73a7) #3 handle_restart_now /root/asterisk/main/asterisk.c:2413 (asterisk+0x0000002c9b9f) #4 ast_cli_command_full /root/asterisk/main/cli.c:2717 (asterisk+0x0000004058fa) #5 consolehandler /root/asterisk/main/asterisk.c:2230 (asterisk+0x0000002c8cca) #6 asterisk_daemon /root/asterisk/main/asterisk.c:4743 (asterisk+0x0000002d7411) #7 main /root/asterisk/main/asterisk.c:4230 (asterisk+0x0000002d5cfd) Previous read of size 4 at 0x7f6c55f1d064 by thread T64: [failed to restore the stack] Location is global 'shutdown_pending' of size 4 at 0x7f6c55f1d064 (asterisk+0x000000cdc064) Mutex M344098 (0x7f6c55c49e00) created at: #0 pthread_mutex_lock <null> (libtsan.so.0+0x000000037816) #1 __ast_pthread_mutex_lock /root/asterisk/main/lock.c:313 (asterisk+0x000000503d01) #2 can_safely_quit /root/asterisk/main/asterisk.c:1884 (asterisk+0x0000002c74f5) #3 quit_handler /root/asterisk/main/asterisk.c:1829 (asterisk+0x0000002c73a7) #4 handle_restart_now /root/asterisk/main/asterisk.c:2413 (asterisk+0x0000002c9b9f) #5 ast_cli_command_full /root/asterisk/main/cli.c:2717 (asterisk+0x0000004058fa) #6 consolehandler /root/asterisk/main/asterisk.c:2230 (asterisk+0x0000002c8cca) #7 asterisk_daemon /root/asterisk/main/asterisk.c:4743 (asterisk+0x0000002d7411) #8 main /root/asterisk/main/asterisk.c:4230 (asterisk+0x0000002d5cfd) Thread T64 (tid=21129, 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+0x0000006b6ae9) #2 <null> <null> (chan_sip.so+0x0000001f25ec) #3 <null> <null> (chan_sip.so+0x00000023dbb7) #4 start_resource /root/asterisk/main/loader.c:1015 (asterisk+0x0000004ff12f) #5 load_resource_list /root/asterisk/main/loader.c:1213 (asterisk+0x000000500c7c) #6 load_modules /root/asterisk/main/loader.c:1366 (asterisk+0x000000501ade) #7 asterisk_daemon /root/asterisk/main/asterisk.c:4659 (asterisk+0x0000002d6e5d) #8 main /root/asterisk/main/asterisk.c:4230 (asterisk+0x0000002d5cfd) SUMMARY: ThreadSanitizer: data race /root/asterisk/main/asterisk.c:1819 ast_begin_shutdown ================== {code} By: Corey Farrell (coreyfarrell) 2016-02-12 14:47:40.432-0600 Since {{shutdown_pending}} is being used as a boolean this has no effect. Locking may quiet the sanitizer, but it would also add unneeded overhead (lock contention). |