title: Filling an array concurrently
body: <p>I am stumbling upon an issue with concurrency and arrays in Swift 5. To reproduce the issue I have simplified my code to the following fragment:</p>
  
  <pre><code>import Dispatch
  
  let group = DispatchGroup()
  let queue = DispatchQueue(
    label: "Concurrent threads",
    qos: .userInitiated,
    attributes: .concurrent
  )
  
  let threadCount = 4
  let size = 1_000
  var pixels = [SIMD3&lt;Float&gt;](
    repeating: .init(repeating: 0),
    count: threadCount*size
  )
  
  for thread in 0..&lt;threadCount {
    queue.async(group: group) {
      for number in thread*size ..&lt; (thread+1)*size {
        let floating = Float(number)
        pixels[number] = SIMD3&lt;Float&gt;(floating, floating, floating)
      }
    }
  }
  
  print("waiting")
  group.wait()
  print("Finished")
  </code></pre>
  
  <p>When I execute this in debug mode using Xcode Version 10.2 beta 4 (10P107d) it always crashes with an error like:</p>
  
  <pre><code>Multithread(15095,0x700008d63000) malloc: *** error for object 0x104812200: pointer being freed was not allocated
  Multithread(15095,0x700008d63000) malloc: *** set a breakpoint in malloc_error_break to debug
  </code></pre>
  
  <p>I have the feeling that this is some bug in the compiler because when I run the code in release mode it runs just fine. Or am I doing something wrong here?</p>