<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 8, 2018, at 2:59 PM, Greg Parker via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Jan 8, 2018, at 12:51 PM, Jordan Rose via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Jan 8, 2018, at 11:47, ⁨‫Fadi Botros‬ ‫⁩ &lt;⁨<a href="mailto:botros_fadi@yahoo.com" class="">botros_fadi@yahoo.com</a>⁩&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class=""><div style="background-color: rgb(255, 255, 255); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Lucida Grande&quot;, sans-serif; font-size: 13px;" class=""><div class="">1st: How to invoke the thread sanitizer?</div></div></div></div></blockquote><div class=""><br class=""></div><div class="">Check out this article on <a href="http://developer.apple.com/" class="">developer.apple.com</a>:&nbsp;<a href="https://developer.apple.com/documentation/code_diagnostics/thread_sanitizer/enabling_the_thread_sanitizer" class="">https://developer.apple.com/documentation/code_diagnostics/thread_sanitizer/enabling_the_thread_sanitizer</a></div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><div style="background-color: rgb(255, 255, 255); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Lucida Grande&quot;, sans-serif; font-size: 13px;" class=""><div dir="ltr" id="yui_3_16_0_ym19_1_1515440347138_7774" class="">2nd: I think making something like ConcurrentModificationException of Java should be a little better experience (if it will not make, or make a small performance penalty, also if it makes performance penalty, it would be activated only when you make a debug version or non-optimized version)<br class=""></div></div></div></div></blockquote><div class=""><br class=""></div><div class="">I don't exactly disagree, but my understanding is that the work to do such a thing is nearly equivalent to having thread sanitizer on all the time. But maybe there's a simpler model that we could still turn on in debug builds. Can you file a bug report requesting this now that <a href="http://bugs.swift.org/" class="">bugs.swift.org</a> is back up?</div></div></div></div></blockquote><br class=""></div><div class="">Something like ConcurrentModificationException ought to be cheaper than the thread sanitizer. The thread sanitizer works hard to detect every concurrency error. ConcurrentModificationException typically does something simple and cheap that catches errors sometimes but makes no attempt to be exhaustive.</div><div class=""><br class=""></div><div class="">Objective-C's fast enumeration protocol includes a mechanism like this. The collection can have a simple mutation counter, and the enumerator captures the counter's value at the start and checks that the value is unchanged as the enumeration proceeds.</div></div></div></blockquote><br class=""></div><div>Does ObjC synchronize the mutation counter? &nbsp;My understanding is that that counter was used to detect mutation while iteration on a single thread, not across threads.</div><div><br class=""></div><div>-Chris</div><div><br class=""></div><br class=""></body></html>