我尝试了here
给出的程序small_race.c
$ clang -fsanitize=thread -g -pthread -O1 small_race.c
$./a.out ==> No error it's passing successfully
汇编
ref.child('contabilidad').once('value', function(snapshot) {
var updates = {};
snapshot.forEach(function(child) {
updates[child.key()+'/pago'] = 0;
});
ref.child('contabilidad').update(updates);
});
我试图创建另外两个线程,并尝试在其中一个线程中睡觉,然后它也正在传递。我正在使用Debian OS
答案 0 :(得分:0)
您的平台或安装有问题。根据您的确切代码,我得到:
==================
WARNING: ThreadSanitizer: data race (pid=20087)
Write of size 4 at 0x000000601080 by thread T1:
#0 Thread1(void*) /tmp/a.cpp:4 (a2+0x000000400a7f)
#1 <null> <null> (libtsan.so.0+0x0000000235b9)
Previous write of size 4 at 0x000000601080 by main thread:
#0 main /tmp/a.cpp:10 (a2+0x000000400ac5)
Location is global '<null>' of size 0 at 0x000000000000 (a2+0x000000601080)
Thread T1 (tid=20089, running) created by main thread at:
#0 pthread_create <null> (libtsan.so.0+0x000000027a67)
#1 main /tmp/a.cpp:9 (a2+0x000000400abb)
SUMMARY: ThreadSanitizer: data race /tmp/a.cpp:4 Thread1(void*)
==================