[swift-users] Swift 4.0 bug in concurrent array access

‫Fadi Botros‬ ‫ botros_fadi at yahoo.com
Mon Jan 8 06:24:41 CST 2018


I'm on macOS Sierra 10.12.6, and using Swift 4.0Tried to access the array concurrently to see whether is it synchronized or no
import Foundation let global = DispatchQueue.global() var array: [Int] = [ - Pastebin.com

  
|  
|   
|   
|   |    |

   |

  |
|  
|   |  
import Foundation let global = DispatchQueue.global() var array: [Int...
   |   |

  |

  |

 
When tried to run it using the terminalThis crash happened
swift(69836,0x700002dc2000) malloc: *** error for object 0x7ffe4be237e0: pointer - Pastebin.com
  
|  
|   
|   
|   |    |

   |

  |
|  
|   |  
swift(69836,0x700002dc2000) malloc: *** error for object 0x7ffe4be237e0: po...
   |   |

  |

  |

 
Avoided this crash using Serial Dispatch Queue
let otherDispatch = DispatchQueue(label: "another.dispatch.com",
                                  qos: .default)
func appending(_ i: Int) {
  otherDispatch.sync { array.append(i) }
}



Also tried to file this issue on bugs.swift.org, and it appears your site is down (under maintainence)
Sorry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20180108/72d846e6/attachment.html>


More information about the swift-users mailing list