The unpac monorepo manager self-hosting as a monorepo using unpac
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #13987 from OlivierNicole/fix-tsan-false-alarm

Fix #13427

authored by

Gabriel Scherer and committed by
GitHub
e0154dc2 f252da53

+18 -13
+4
Changes
··· 26 26 does with an unrecognised file. 27 27 (David Allsopp, review by Antonin Décimo and Sébastien Hinderer) 28 28 29 + - #13987: Remove a spurious TSan report in case of benign data race between 30 + major GC read and write from the mutator (fixes #13427) 31 + (Olivier Nicole, report by Thomas Leonard, review by Gabriel Scherer) 32 + 29 33 - #13966: Enable "generalized polymorphic #install_printer" 30 34 in the debugger 31 35 (Pierre Boutillier and Gabriel Scherer, review by Florian Angeletti)
+14 -13
runtime/major_gc.c
··· 1120 1120 mark_stack_prune(stk); 1121 1121 } 1122 1122 1123 + /* This function is used for reads that may race with a concurrent `caml_modify` 1124 + from the mutator. Without this, TSan would flag it as a race (see section 1125 + 3.2 of comment in tsan.c); however, we have decided that these races are 1126 + benign. We therefore use this function instead, ensuring that the read is 1127 + not seen by TSan. */ 1128 + static CAMLno_tsan 1129 + #if defined(WITH_THREAD_SANITIZER) 1130 + Caml_noinline 1131 + #endif 1132 + value volatile_load_uninstrumented(volatile value* p) { 1133 + return *p; 1134 + } 1135 + 1123 1136 Caml_inline void mark_stack_push_range(struct mark_stack* stk, 1124 1137 value_ptr start, value_ptr end) 1125 1138 { ··· 1160 1173 end = (block_wsz < 8 ? block_wsz : 8); 1161 1174 1162 1175 for (i = offset; i < end; i++) { 1163 - value v = Field(block, i); 1176 + value v = volatile_load_uninstrumented(&Field(block, i)); 1164 1177 1165 1178 if (Is_markable(v)) 1166 1179 break; ··· 1252 1265 } 1253 1266 } 1254 1267 1255 - static CAMLno_tsan 1256 - #if defined(WITH_THREAD_SANITIZER) 1257 - Caml_noinline 1258 - #endif 1259 - value volatile_load_uninstrumented(volatile value* p) { 1260 - return *p; 1261 - } 1262 - 1263 1268 Caml_noinline static intnat do_some_marking(struct mark_stack* stk, 1264 1269 intnat budget) { 1265 1270 prefetch_buffer_t pb = { .enqueued = 0, .dequeued = 0, ··· 1358 1363 for (; me.start < scan_end; me.start++) { 1359 1364 CAMLassert(budget >= 0); 1360 1365 1361 - /* This load may race with a concurrent caml_modify. It does not 1362 - constitute a data race as this is a volatile load. However, TSan will 1363 - wrongly see a race here (see section 3.2 of comment in tsan.c). We 1364 - therefore make sure it is never TSan-instrumented. */ 1365 1366 value child = volatile_load_uninstrumented(me.start); 1366 1367 1367 1368 budget--;