tui: update_size(): Fix race condition.

bridge.width and bridge.height reach ui.c:ui_refresh() when it iterates
through all UIs, so they do not need to be set directly by
tui.c:update_size().

Race found by helgrind:

==18532== Helgrind, a thread error detector
==18532== Copyright (C) 2007-2015, and GNU GPL'd, by OpenWorks LLP et al.
==18532== Using Valgrind-3.12.0 and LibVEX; rerun with -h for copyright info
==18532== Command: ./build/bin/nvim -u NONE --cmd set\ rtp+=~/.vim/bundle/vimfiler.vim,~/.vim/bundle/unite.vim --cmd runtime\ plugin/vimfiler.vim --cmd runtime\ plugin/unite.vim
==18532== Parent PID: 6477
==18532==
==18532== ---Thread-Announcement------------------------------------------
==18532==
==18532== Thread #2 was created
==18532==    at 0x68FA98E: clone (clone.S:73)
==18532==    by 0x5270179: create_thread (createthread.c:102)
==18532==    by 0x5271BE2: pthread_create@@GLIBC_2.2.5 (pthread_create.c:679)
==18532==    by 0x4C32B07: pthread_create_WRK (hg_intercepts.c:427)
==18532==    by 0x4E53A3F: uv_thread_create (in /usr/lib/x86_64-linux-gnu/libuv.so.1.0.0)
==18532==    by 0x6A7154: ui_bridge_attach (ui_bridge.c:89)
==18532==    by 0x6A164C: tui_start (tui.c:116)
==18532==    by 0x6A4CFC: ui_builtin_start (ui.c:89)
==18532==    by 0x55A825: main (main.c:433)
==18532==
==18532== ---Thread-Announcement------------------------------------------
==18532==
==18532== Thread #1 is the program's root thread
==18532==
==18532== ----------------------------------------------------------------
==18532==
==18532== Possible data race during write of size 4 at 0x770E7B4 by thread #2
==18532== Locks held: none
==18532==    at 0x6A3071: update_size (tui.c:759)
==18532==    by 0x6A30DB: sigwinch_cb (tui.c:269)
==18532==    by 0x4D0A54: signal_event (signal.c:44)
==18532==    by 0x4CDDB6: multiqueue_process_events (multiqueue.c:146)
==18532==    by 0x4CD135: loop_poll_events (loop.c:56)
==18532==    by 0x6A2451: tui_main (tui.c:239)
==18532==    by 0x6A857A: ui_thread_run (ui_bridge.c:112)
==18532==    by 0x4E539F6: ??? (in /usr/lib/x86_64-linux-gnu/libuv.so.1.0.0)
==18532==    by 0x4C32D06: mythread_wrapper (hg_intercepts.c:389)
==18532==    by 0x5271423: start_thread (pthread_create.c:333)
==18532==    by 0x68FA9BE: clone (clone.S:105)
==18532==
==18532== This conflicts with a previous read of size 4 by thread #1
==18532== Locks held: none
==18532==    at 0x6A542A: ui_refresh (ui.c:169)
==18532==    by 0x6A5870: ui_refresh_event (ui.c:181)
==18532==    by 0x4CDDB6: multiqueue_process_events (multiqueue.c:146)
==18532==    by 0x4CD135: loop_poll_events (loop.c:56)
==18532==    by 0x5DEDB4: os_breakcheck (input.c:150)
==18532==    by 0x59263D: line_breakcheck (misc1.c:2667)
==18532==    by 0x621AE5: nfa_regmatch (regexp_nfa.c:6171)
==18532==    by 0x61DCF7: nfa_regtry (regexp_nfa.c:6240)
==18532==  Address 0x770e7b4 is 4 bytes inside a block of size 352 alloc'd
==18532==    at 0x4C2EFE5: calloc (vg_replace_malloc.c:711)
==18532==    by 0x57C962: xcalloc (memory.c:119)
==18532==    by 0x6A6E29: ui_bridge_attach (ui_bridge.c:53)
==18532==    by 0x6A164C: tui_start (tui.c:116)
==18532==    by 0x6A4CFC: ui_builtin_start (ui.c:89)
==18532==    by 0x55A825: main (main.c:433)
==18532==  Block was alloc'd by thread #1
==18532==
==18532== ----------------------------------------------------------------
==18532==
==18532== Possible data race during write of size 4 at 0x770E7B8 by thread #2
==18532== Locks held: none
==18532==    at 0x6A3085: update_size (tui.c:760)
==18532==    by 0x6A30DB: sigwinch_cb (tui.c:269)
==18532==    by 0x4D0A54: signal_event (signal.c:44)
==18532==    by 0x4CDDB6: multiqueue_process_events (multiqueue.c:146)
==18532==    by 0x4CD135: loop_poll_events (loop.c:56)
==18532==    by 0x6A2451: tui_main (tui.c:239)
==18532==    by 0x6A857A: ui_thread_run (ui_bridge.c:112)
==18532==    by 0x4E539F6: ??? (in /usr/lib/x86_64-linux-gnu/libuv.so.1.0.0)
==18532==    by 0x4C32D06: mythread_wrapper (hg_intercepts.c:389)
==18532==    by 0x5271423: start_thread (pthread_create.c:333)
==18532==    by 0x68FA9BE: clone (clone.S:105)
==18532==
==18532== This conflicts with a previous read of size 4 by thread #1
==18532== Locks held: none
==18532==    at 0x6A5455: ui_refresh (ui.c:170)
==18532==    by 0x6A5870: ui_refresh_event (ui.c:181)
==18532==    by 0x4CDDB6: multiqueue_process_events (multiqueue.c:146)
==18532==    by 0x4CD135: loop_poll_events (loop.c:56)
==18532==    by 0x5DEDB4: os_breakcheck (input.c:150)
==18532==    by 0x59263D: line_breakcheck (misc1.c:2667)
==18532==    by 0x621AE5: nfa_regmatch (regexp_nfa.c:6171)
==18532==    by 0x61DCF7: nfa_regtry (regexp_nfa.c:6240)
==18532==  Address 0x770e7b8 is 8 bytes inside a block of size 352 alloc'd
==18532==    at 0x4C2EFE5: calloc (vg_replace_malloc.c:711)
==18532==    by 0x57C962: xcalloc (memory.c:119)
==18532==    by 0x6A6E29: ui_bridge_attach (ui_bridge.c:53)
==18532==    by 0x6A164C: tui_start (tui.c:116)
==18532==    by 0x6A4CFC: ui_builtin_start (ui.c:89)
==18532==    by 0x55A825: main (main.c:433)
==18532==  Block was alloc'd by thread #1
This commit is contained in:
Justin M. Keyes 2017-02-03 14:04:38 +01:00
parent 8b804948df
commit 0e75438a38

View File

@ -763,8 +763,8 @@ end:
height = DFLT_ROWS;
}
data->bridge->bridge.width = ui->width = width;
data->bridge->bridge.height = ui->height = height;
data->bridge->bridge.width = width;
data->bridge->bridge.height = height;
}
static void unibi_goto(UI *ui, int row, int col)