<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Jan 8, 2018, at 11:47, Fadi Botros <<a href="mailto:botros_fadi@yahoo.com" class="">botros_fadi@yahoo.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class=""><div style="background-color: rgb(255, 255, 255); font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size: 13px;" class=""><div class="">1st: How to invoke the thread sanitizer?</div></div></div></div></blockquote><div><br class=""></div><div>Check out this article on <a href="http://developer.apple.com" class="">developer.apple.com</a>: <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: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", 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><br class=""></div><div>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><br class=""></div><div>Thanks!</div><div>Jordan</div><div><br class=""></div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><div style="background-color: rgb(255, 255, 255); font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size: 13px;" class=""><div id="yui_3_16_0_ym19_1_1515440347138_7665" class=""><span class=""></span></div><div class="qtdSeparateBR" id="yui_3_16_0_ym19_1_1515440347138_7644"><br class=""><br class=""></div><div class="yahoo_quoted" id="yui_3_16_0_ym19_1_1515440347138_7614" style="display: block;"> <div style="font-family: Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 13px;" id="yui_3_16_0_ym19_1_1515440347138_7613" class=""> <div style="font-family: HelveticaNeue-Light, Helvetica Neue Light, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1515440347138_7612" class=""> <div dir="rtl" id="yui_3_16_0_ym19_1_1515440347138_7611" class=""> <font id="yui_3_16_0_ym19_1_1515440347138_7643" size="2" face="Arial" class=""> <hr size="1" class=""> <b class=""><span style="font-weight:bold;" class="">من:</span></b> Jordan Rose <<a href="mailto:jordan_rose@apple.com" class="">jordan_rose@apple.com</a>><br class=""> <b class=""><span style="font-weight: bold;" class="">إلى:</span></b> Fadi Botros <<a href="mailto:botros_fadi@yahoo.com" class="">botros_fadi@yahoo.com</a>> <br class=""><b class=""><span style="font-weight: bold;" class="">نسخة كربونية:</span></b> "<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>" <<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>><br class=""> <b class=""><span style="font-weight: bold;" class="">تاريخ الإرسال:</span></b> الإثنين 8 يناير، 2018 9:14 م<br class=""> <b class=""><span style="font-weight: bold;" class="">الموضوع:</span></b> Re: [swift-users] Swift 4.0 bug in concurrent array access<br class=""> </font> </div> <div class="y_msg_container" id="yui_3_16_0_ym19_1_1515440347138_7851"><br class=""><div id="yiv0784952751" class=""><div id="yui_3_16_0_ym19_1_1515440347138_7853" class=""><div class="yiv0784952751" id="yui_3_16_0_ym19_1_1515440347138_7852">That sounds expected to me. While Array values are thread-safe, writing to the global variable 'array' from two different threads would be a race. You can see this properly diagnosed if you enable Thread Sanitizer.</div><div class="yiv0784952751" id="yui_3_16_0_ym19_1_1515440347138_7854"><br class="yiv0784952751" clear="none"></div><div class="yiv0784952751" id="yui_3_16_0_ym19_1_1515440347138_7855">Jordan</div><div class="yiv0784952751" id="yui_3_16_0_ym19_1_1515440347138_7856"><br class="yiv0784952751" clear="none"></div><div class="yiv0784952751" id="yui_3_16_0_ym19_1_1515440347138_7857">P.S. <a rel="nofollow" shape="rect" class="yiv0784952751" target="_blank" href="http://bugs.swift.org/">bugs.swift.org</a> should be back up now, if you find any other issues.</div><br class="yiv0784952751" clear="none"><div id="yui_3_16_0_ym19_1_1515440347138_7858" class=""><br class="yiv0784952751" clear="none"><blockquote class="yiv0784952751" type="cite" id="yui_3_16_0_ym19_1_1515440347138_7860"><div class="yiv0784952751yqt6545537665" id="yiv0784952751yqt16051"><div class="yiv0784952751" id="yui_3_16_0_ym19_1_1515440347138_7859">On Jan 8, 2018, at 11:02, Fadi Botros via swift-users <<a rel="nofollow" shape="rect" class="yiv0784952751" ymailto="mailto:swift-users@swift.org" target="_blank" href="mailto:swift-users@swift.org">swift-users@swift.org</a>> wrote:</div><br class="yiv0784952751Apple-interchange-newline" clear="none"><div class="yiv0784952751"><div class="yiv0784952751"><div class="yiv0784952751" style="background-color:rgb(255, 255, 255);"><div class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4159">I'm on macOS Sierra 10.12.6, and using Swift 4.0</div><div class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4299">Tried to access the array concurrently to see whether is it synchronized or no<br class="yiv0784952751" clear="none"></div><div class="yiv0784952751" dir="ltr" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4263"><a rel="nofollow" shape="rect" class="yiv0784952751enhancr2_0af812e8-9a1d-3326-9334-51751140db37" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4262" target="_blank" href="https://pastebin.com/PnvyM3Qn">import Foundation let global = DispatchQueue.global() var array: [Int] = [ - Pastebin.com</a><br class="yiv0784952751" clear="none"></div><div class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4270"><br class="yiv0784952751" clear="none"></div><div class="yiv0784952751ymail-preserve-class yiv0784952751ymail-preserve-style yiv0784952751yahoo-link-enhancr-card" dir="ltr" id="yiv0784952751enhancr2_0af812e8-9a1d-3326-9334-51751140db37" style="max-width:400px;font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;" data-url="https://pastebin.com/PnvyM3Qn" data-type="yenhancr" data-category="article" data-embed-url="" data-size="medium"> <a rel="nofollow" shape="rect" class="yiv0784952751yahoo-enhancr-cardlink" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4318" target="_blank" href="https://pastebin.com/PnvyM3Qn" style="text-decoration:none;"> <table class="yiv0784952751card-wrapper yiv0784952751yahoo-ignore-table" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4317" style="max-width:400px;" cellspacing="0" cellpadding="0" border="0"><tbody class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4316"><tr class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4315"><td colspan="1" rowspan="1" class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4314" width="400"> <table class="yiv0784952751card yiv0784952751yahoo-ignore-table" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4313" style="max-width:400px;" width="100%" cellspacing="0" cellpadding="0" border="0"><tbody class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4312"><tr class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4311"><td colspan="1" rowspan="1" class="yiv0784952751card-primary-image-cell" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4310" style="background:#000 url('https://s.yimg.com/vv//api/res/1.2/x_YOsykpk_BPKDNd006jFg--~A/YXBwaWQ9bWFpbDtmaT1maWxsO2g9MjAwO3c9NDAw/https://pastebin.com/i/facebook.png.cf.jpg') no-repeat center center;background-size:cover;min-height:200px;position:relative;" valign="top" bgcolor="#000000" background="https://s.yimg.com/vv//api/res/1.2/x_YOsykpk_BPKDNd006jFg--~A/YXBwaWQ9bWFpbDtmaT1maWxsO2g9MjAwO3c9NDAw/https://pastebin.com/i/facebook.png.cf.jpg"> <table class="yiv0784952751yahoo-ignore-table" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4309" style="width:100%;" cellspacing="0" cellpadding="0" border="0"><tbody class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4308"><tr class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4307"><td colspan="1" rowspan="1" class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4306" style="background:transparent url('https://s.yimg.com/nq/storm/assets/enhancrV2/12/overlay-tile.png') repeat left top;min-height:200px;" valign="top" bgcolor="transparent" background="https://s.yimg.com/nq/storm/assets/enhancrV2/12/overlay-tile.png"> <table class="yiv0784952751yahoo-ignore-table" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4305" style="width:100%;min-height:185px;min-height:185px;" height="185"><tbody class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4304"><tr class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4303"><td colspan="1" rowspan="1" class="yiv0784952751card-richInfo2" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4302" style="text-align:left;text-align:left;padding:15px 0 0 15px;vertical-align:top;"> </td><td colspan="1" rowspan="1" class="yiv0784952751card-actions" style="text-align:right;padding:15px 15px 0 0;vertical-align:top;"> <div class="yiv0784952751card-share-container"></div> </td></tr></tbody></table> </td></tr></tbody></table> </td></tr><tr class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4405"><td colspan="1" rowspan="1" class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4404"> <table class="yiv0784952751card-info yiv0784952751yahoo-ignore-table" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4403" style="background:#fff;position:relative;z-index:2;width:95%;max-width:380px;border:1px solid #e0e4e9;border-bottom:3px solid #000000;margin-top:-40px;margin-left:auto;margin-right:auto;" cellspacing="0" cellpadding="0" border="0" align="center"><tbody class="yiv0784952751"><tr class="yiv0784952751"><td colspan="1" rowspan="1" class="yiv0784952751" style="background-color:#ffffff;padding:16px 0 16px 12px;vertical-align:top;"> </td><td colspan="1" rowspan="1" class="yiv0784952751" style="vertical-align:middle;padding:16px 12px;width:99%;"> <h2 class="yiv0784952751card-title" style="font-size:16px;line-height:19px;margin:0 0 4px 0;font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;">import Foundation let global = DispatchQueue.global() var array: [Int...</h2> <div class="yiv0784952751card-description" style="font-size:11px;line-height:15px;color:#999;"></div> </td><td colspan="1" rowspan="1" class="yiv0784952751" style="text-align:right;padding:16px 12px 16px 0;"> </td></tr></tbody></table> </td></tr></tbody></table> </td></tr></tbody></table> </a></div><div class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4408"><br class="yiv0784952751" clear="none"></div><div class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4409">When tried to run it using the terminal</div><div class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4416">This crash happened</div><div class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4417"><br class="yiv0784952751" clear="none"></div><div class="yiv0784952751" dir="ltr" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4418"><a rel="nofollow" shape="rect" class="yiv0784952751enhancr2_5a98714b-dace-156a-89c6-8e3af06f6ea3" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4424" target="_blank" href="https://pastebin.com/vrdKTfrP">swift(69836,0x700002dc2000) malloc: *** error for object 0x7ffe4be237e0: pointer - Pastebin.com</a></div><div class="yiv0784952751"><br class="yiv0784952751" clear="none"></div><div class="yiv0784952751ymail-preserve-class yiv0784952751ymail-preserve-style yiv0784952751yahoo-link-enhancr-card" dir="ltr" id="yiv0784952751enhancr2_5a98714b-dace-156a-89c6-8e3af06f6ea3" style="max-width:400px;font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;" data-url="https://pastebin.com/vrdKTfrP" data-type="yenhancr" data-category="article" data-embed-url="" data-size="medium"> <a rel="nofollow" shape="rect" class="yiv0784952751yahoo-enhancr-cardlink" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4442" target="_blank" href="https://pastebin.com/vrdKTfrP" style="text-decoration:none;"> <table class="yiv0784952751card-wrapper yiv0784952751yahoo-ignore-table" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4441" style="max-width:400px;" cellspacing="0" cellpadding="0" border="0"><tbody class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4440"><tr class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4439"><td colspan="1" rowspan="1" class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4438" width="400"> <table class="yiv0784952751card yiv0784952751yahoo-ignore-table" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4437" style="max-width:400px;" width="100%" cellspacing="0" cellpadding="0" border="0"><tbody class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4436"><tr class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4645"><td colspan="1" rowspan="1" class="yiv0784952751card-primary-image-cell" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4644" style="background:#000 url('https://s.yimg.com/vv//api/res/1.2/x_YOsykpk_BPKDNd006jFg--~A/YXBwaWQ9bWFpbDtmaT1maWxsO2g9MjAwO3c9NDAw/https://pastebin.com/i/facebook.png.cf.jpg') no-repeat center center;background-size:cover;min-height:200px;position:relative;" valign="top" bgcolor="#000000" background="https://s.yimg.com/vv//api/res/1.2/x_YOsykpk_BPKDNd006jFg--~A/YXBwaWQ9bWFpbDtmaT1maWxsO2g9MjAwO3c9NDAw/https://pastebin.com/i/facebook.png.cf.jpg"> <table class="yiv0784952751yahoo-ignore-table" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4643" style="width:100%;" cellspacing="0" cellpadding="0" border="0"><tbody class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4642"><tr class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4641"><td colspan="1" rowspan="1" class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4640" style="background:transparent url('https://s.yimg.com/nq/storm/assets/enhancrV2/12/overlay-tile.png') repeat left top;min-height:200px;" valign="top" bgcolor="transparent" background="https://s.yimg.com/nq/storm/assets/enhancrV2/12/overlay-tile.png"> <table class="yiv0784952751yahoo-ignore-table" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4639" style="width:100%;min-height:185px;min-height:185px;" height="185"><tbody class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4638"><tr class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4637"><td colspan="1" rowspan="1" class="yiv0784952751card-richInfo2" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4636" style="text-align:left;text-align:left;padding:15px 0 0 15px;vertical-align:top;"> </td><td colspan="1" rowspan="1" class="yiv0784952751card-actions" style="text-align:right;padding:15px 15px 0 0;vertical-align:top;"> <div class="yiv0784952751card-share-container"></div> </td></tr></tbody></table> </td></tr></tbody></table> </td></tr><tr class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4435"><td colspan="1" rowspan="1" class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4434"> <table class="yiv0784952751card-info yiv0784952751yahoo-ignore-table" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4433" style="background:#fff;position:relative;z-index:2;width:95%;max-width:380px;border:1px solid #e0e4e9;border-bottom:3px solid #000000;margin-top:-40px;margin-left:auto;margin-right:auto;" cellspacing="0" cellpadding="0" border="0" align="center"><tbody class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4491"><tr class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4490"><td colspan="1" rowspan="1" class="yiv0784952751" style="background-color:#ffffff;padding:16px 0 16px 12px;vertical-align:top;"> </td><td colspan="1" rowspan="1" class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4489" style="vertical-align:middle;padding:16px 12px;width:99%;"> <h2 class="yiv0784952751card-title" style="font-size:16px;line-height:19px;margin:0 0 4px 0;font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;">swift(69836,0x700002dc2000) malloc: *** error for object 0x7ffe4be237e0: po...</h2> <div class="yiv0784952751card-description" style="font-size:11px;line-height:15px;color:#999;"></div> </td><td colspan="1" rowspan="1" class="yiv0784952751" style="text-align:right;padding:16px 12px 16px 0;"> </td></tr></tbody></table> </td></tr></tbody></table> </td></tr></tbody></table> </a></div><div class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4432"><br class="yiv0784952751" clear="none"></div><div class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4484">Avoided this crash using Serial Dispatch Queue</div><div class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4485"><br class="yiv0784952751" clear="none"></div><div class="yiv0784952751" dir="ltr" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4488">let otherDispatch = DispatchQueue(label: "<a rel="nofollow" shape="rect" class="yiv0784952751" target="_blank" href="http://another.dispatch.com/">another.dispatch.com</a>",<br class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4600" clear="none"> qos: .default)<br class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4601" clear="none">func appending(_ i: Int) {<br class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4602" clear="none"> otherDispatch.sync { array.append(i) }<br class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4603" clear="none">}<br class="yiv0784952751" clear="none"></div><div class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4523"><br class="yiv0784952751" clear="none"></div><div class="yiv0784952751" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4530"><br class="yiv0784952751" clear="none"></div><div class="yiv0784952751" dir="ltr" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4460"><br class="yiv0784952751" clear="none"></div><div class="yiv0784952751" dir="ltr" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4687">Also tried to file this issue on <a rel="nofollow" shape="rect" class="yiv0784952751" target="_blank" href="http://bugs.swift.org/">bugs.swift.org</a>, and it appears your site is down (under maintainence)</div><div class="yiv0784952751" dir="ltr" id="yiv0784952751yui_3_16_0_ym19_1_1515413693521_4691"><br class="yiv0784952751" clear="none"></div><div class="yiv0784952751" dir="ltr">Sorry<br class="yiv0784952751" clear="none"></div></div></div>_______________________________________________<br class="yiv0784952751" clear="none">swift-users mailing list<br class="yiv0784952751" clear="none"><a rel="nofollow" shape="rect" class="yiv0784952751" ymailto="mailto:swift-users@swift.org" target="_blank" href="mailto:swift-users@swift.org">swift-users@swift.org</a><br class="yiv0784952751" clear="none"><a href="https://lists.swift.org/mailman/listinfo/swift-users" class="">https://lists.swift.org/mailman/listinfo/swift-users</a><br class="yiv0784952751" clear="none"></div></div></blockquote></div><br class="yiv0784952751" clear="none"></div></div><br class=""><br class=""></div> </div> </div> </div></div></div></div></blockquote></div><br class=""></body></html>