Wireshark-dev: Re: [Wireshark-dev] ThreadSanitizer issue in RecentFileStatus()

From: Gerald Combs <gerald@xxxxxxxxxxxxx>
Date: Fri, 2 Feb 2018 10:33:31 -0800
That's correct -- the main and RecentFileStatus threads could operate on the filename at the same time. I think the data race is harmless in this case, but it's easy enough to create a local copy of the filename. Fix inbound at https://code.wireshark.org/review/#/c/25572.

On 2/2/18 8:08 AM, Jaap Keuter wrote:
> Hi,
> 
> Good question.
> Just spitballing here, in what thread are the constructors running?
> RecentFileStatus::filename_ is being set during construction, but is run() already called from the other thread?
> 
> Jaap
> 
> 
>> On 2 Feb 2018, at 15:04, Stig Bjørlykke <stig@xxxxxxxxxxxxx> wrote:
>>
>> When running with ThreadSanitizer I constantly get this race condition
>> report from a QString in RecentFileStatus.  Anyone else seen this?  I
>> can't figure out the issue...
>>
>> ==================
>> WARNING: ThreadSanitizer: data race (pid=41949)
>>  Read of size 8 at 0x7b0c000c0dd0 by thread T18:
>>  * #0 QString::QString(QString const&) qstring.h:906
>> (Wireshark:x86_64+0x100039756)
>>    #1 QString::QString(QString const&) qstring.h:907
>> (Wireshark:x86_64+0x100038998)
>>    #2 RecentFileStatus::run() recent_file_status.cpp:33
>> (Wireshark:x86_64+0x1004ffbec)
>>    #3 non-virtual thunk to RecentFileStatus::run()
>> recent_file_status.cpp (Wireshark:x86_64+0x1004ffd2c)
>>    #4 <null> <null>:8575680 (QtCore:x86_64+0x27b6d)
>>
>>  Previous write of size 8 at 0x7b0c000c0dd0 by main thread:
>>  * #0 QString::QString(QString const&) qstring.h:906
>> (Wireshark:x86_64+0x10003976d)
>>    #1 QString::QString(QString const&) qstring.h:907
>> (Wireshark:x86_64+0x100038998)
>>    #2 RecentFileStatus::RecentFileStatus(QString, QObject*)
>> recent_file_status.cpp:13 (Wireshark:x86_64+0x1004ff8b3)
>>    #3 RecentFileStatus::RecentFileStatus(QString, QObject*)
>> recent_file_status.cpp:14 (Wireshark:x86_64+0x1004ffac0)
>>    #4 WiresharkApplication::refreshRecentCaptures()
>> wireshark_application.cpp:256 (Wireshark:x86_64+0x10079a3b6)
>>    #5 WiresharkApplication::qt_static_metacall(QObject*,
>> QMetaObject::Call, int, void**)
>> moc_wireshark_application_Debug.cpp:234 (Wireshark:x86_64+0x1000bbceb)
>>    #6 QMetaObject::activate(QObject*, int, int, void**)
>> <null>:8575680 (QtCore:x86_64+0x2194ba)
>>    #7 main wireshark-qt.cpp:852 (Wireshark:x86_64+0x100037b0c)
>>
>>  Issue is caused by frames marked with "*".
>>
>>  Location is heap block of size 48 at 0x7b0c000c0db0 allocated by main thread:
>>    #0 operator new(unsigned long) <null>:8575712
>> (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x6ba8e)
>>    #1 WiresharkApplication::refreshRecentCaptures()
>> wireshark_application.cpp:256 (Wireshark:x86_64+0x10079a36a)
>>    #2 WiresharkApplication::qt_static_metacall(QObject*,
>> QMetaObject::Call, int, void**)
>> moc_wireshark_application_Debug.cpp:234 (Wireshark:x86_64+0x1000bbceb)
>>    #3 QMetaObject::activate(QObject*, int, int, void**)
>> <null>:8575712 (QtCore:x86_64+0x2194ba)
>>    #4 main wireshark-qt.cpp:852 (Wireshark:x86_64+0x100037b0c)
>>
>>  Thread T18 (tid=17501933, running) created by main thread at:
>>    #0 pthread_create <null>:8575760
>> (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x2a34d)
>>    #1 QThread::start(QThread::Priority) <null>:8575760 (QtCore:x86_64+0x2b5cb)
>>    #2 main wireshark-qt.cpp:667 (Wireshark:x86_64+0x100036bcd)
>>
>> SUMMARY: ThreadSanitizer: data race qstring.h:906 in
>> QString::QString(QString const&)
>> ==================
>>
>>
>> -- 
>> Stig Bjørlykke
> 
> ___________________________________________________________________________
> Sent via:    Wireshark-dev mailing list <wireshark-dev@xxxxxxxxxxxxx>
> Archives:    https://www.wireshark.org/lists/wireshark-dev
> Unsubscribe: https://www.wireshark.org/mailman/options/wireshark-dev
>              mailto:wireshark-dev-request@xxxxxxxxxxxxx?subject=unsubscribe
>