Skip to content

Commit

Permalink
http: fix data-race
Browse files Browse the repository at this point in the history
Fix the following tsan report:

~/work/git/vlc/build-tsan/modules $ ./h2conn_test
==================
WARNING: ThreadSanitizer: data race (pid=20689)
  Write of size 1 at 0x7b20000000a5 by thread T4:
    #0 vlc_h2_stream_reset ../../modules/access/http/h2conn.c:206 (h2conn_test+0x8a6a)
    #1 vlc_h2_recv_thread ../../modules/access/http/h2conn.c:676 (h2conn_test+0x9029)
    #2 <null> <null> (libtsan.so.0+0x29b4d)

  Previous read of size 1 at 0x7b20000000a5 by main thread (mutexes: write M12):
    #0 vlc_h2_stream_wait ../../modules/access/http/h2conn.c:246 (h2conn_test+0x917d)
    #1 vlc_http_stream_read_headers ../../modules/access/http/message.h:360 (h2conn_test+0x40ff)
    #2 main ../../modules/access/http/h2conn_test.c:283 (h2conn_test+0x40ff)

  Location is heap block of size 128 at 0x7b2000000080 allocated by main thread:
    #0 malloc <null> (libtsan.so.0+0x2b1b3)
    #1 vlc_h2_stream_open ../../modules/access/http/h2conn.c:404 (h2conn_test+0x9afc)
    #2 vlc_http_stream_open ../../modules/access/http/conn.h:49 (h2conn_test+0x3be8)
    #3 stream_open ../../modules/access/http/h2conn_test.c:124 (h2conn_test+0x3be8)
    #4 main ../../modules/access/http/h2conn_test.c:280 (h2conn_test+0x40c3)

  Mutex M12 (0x7b1800000030) created at:
    #0 pthread_mutex_init <null> (libtsan.so.0+0x2c5bd)
    #1 vlc_mutex_init ../../src/posix/thread.c:116 (libvlccore.so.9+0xeadba)
    #2 vlc_h2_conn_create ../../modules/access/http/h2conn.c:736 (h2conn_test+0xa10e)
    #3 conn_create ../../modules/access/http/h2conn_test.c:100 (h2conn_test+0x393c)
    #4 main ../../modules/access/http/h2conn_test.c:165 (h2conn_test+0x3cd1)

  Thread T4 (tid=20707, running) created by main thread at:
    #0 pthread_create <null> (libtsan.so.0+0x2be2b)
    #1 vlc_clone_attr ../../src/posix/thread.c:431 (libvlccore.so.9+0xeabcf)
    #2 vlc_clone ../../src/posix/thread.c:443 (libvlccore.so.9+0xeb11b)
    #3 vlc_h2_conn_create ../../modules/access/http/h2conn.c:739 (h2conn_test+0xa13a)
    #4 conn_create ../../modules/access/http/h2conn_test.c:100 (h2conn_test+0x393c)
    #5 main ../../modules/access/http/h2conn_test.c:165 (h2conn_test+0x3cd1)

The good news is that there is only 4 remaining tests to fix with tsan.
  • Loading branch information
tguillem committed Oct 18, 2018
1 parent 1b4cf92 commit 4a230d7
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions modules/access/http/h2conn.c
Expand Up @@ -672,8 +672,10 @@ static void *vlc_h2_recv_thread(void *data)
vlc_h2_parse_destroy(parser);
fail:
/* Terminate any remaining stream */
vlc_mutex_lock(&conn->lock);
for (struct vlc_h2_stream *s = conn->streams; s != NULL; s = s->older)
vlc_h2_stream_reset(s, VLC_H2_CANCEL);
vlc_mutex_unlock(&conn->lock);
return NULL;
}

Expand Down

0 comments on commit 4a230d7

Please sign in to comment.