title: Swift Crash: Array._allocateBufferUninitialized
body: <p>I have a crash report from an app that has integrated our Swift SDK. I was able to symbolicate it but when I look at the last line of code in the stack trace that is supposed to belong to our SDK, I do not recognize it.</p>
  
  <p>(rest of stack is in Swift Core. Obfuscated names)</p>
  
  <pre><code>Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
  Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000a00000008
  ....
  7   libswiftCore.dylib      0x00000001007d337c 0x1005ec000 + 1995644
  8   libswiftCore.dylib      0x00000001007d33d4 0x1005ec000 + 1995732
  9   OurLib                  0x00000001003e1ed0 specialized specialized static Array._allocateBufferUninitialized&lt;A&gt;(Int) -&gt; _ArrayBuffer&lt;A&gt; (TheCrashingClass.swift:0)
  10  OurLib                  0x0000000100420200 specialized static OurLibClass.(startInternal in _9A5ED0808944BC6425F8A2C348E9DA3A)(delegate : NotificationDelegate?, send : Bool) -&gt; () (OurLibClass.swift:0)
  11  OurLib                  0x0000000100420a70 specialized static OurLibClass.start(NotificationDelegate?, send : Bool) -&gt; () (OurLibClass.swift:47)
  12  OurLib                  0x000000010041f5b0 @objc static OurLibClass.start(NotificationDelegate?, send : Bool) -&gt; () (OurLibClass.swift:0)
  13  TheApp                  0x00000001000f8f3c -[AppDelegate application:didFinishLaunchingWithOptions:] (AppDelegate.m:48)
  </code></pre>
  
  <p>The line in question is this line:</p>
  
  <pre><code>specialized specialized static Array._allocateBufferUninitialized&lt;A&gt;(Int) -&gt; _ArrayBuffer&lt;A&gt; (TheCrashingClass.swift:0)
  </code></pre>
  
  <p>The stack trace is confusing since OurLibClass doesn't call TheCrashingClass. The client confirmed that a print statement we have enabled at the beginning of the start() call is not being printed. This makes me think that a static property/block is being called on CrashingClass when it is loaded. Here is a stripped down version of the class and attributes.</p>
  
  <pre><code>public class CrashingClass : IProtocolThree, CustomStringConvertible {
  
      public let description = "ADescription"
      private let class1: IProtocolOne
      private var class2: IProtocolTwo?
      private let defaults: NSUserDefaults
      private let key: String
      private let class4: IProtocolOne
      private let callback: () -&gt; ()
      private let class3 = Class3()
  
      public private(set) var interval: NSTimeInterval
  
      public var date2: NSDate? { get { } }
  
      public var date1: NSDate? { get { } }
  
      init(class1: IProtocolOne, defaults: NSUserDefaults, key: String, interval: NSTimeInterval, class4: IProtocolFour, callback: () -&gt; ()) {
      }
  }
  </code></pre>
  
  <p>It doesn't have any arrays and the only property I could think of that would be getting initialized as an array is the String.</p>
  
  <p>Some other things to note:
  - I am unable to reproduce this issue on any device (real or simulator)
  - the crash only happens on certain devices, but when it happens on a device it happens consistently. But, different devices of the same type exhibit different behaviour. For example, one iPad4 (ios 8.0) always crashes while another iPad4 (ios 8.1) doesn't.
  - App is objc while framework is Swift</p>
  
  <p>My questions are:</p>
  
  <p>specialized specialized static Array._allocateBufferUninitialized(Int) -> _ArrayBuffer (TheCrashingClass.swift:0)</p>
  
  <ul>
  <li>Can I set a symbolic break point at allocateBufferUninitialized, so I could see where it is being called from?</li>
  <li>What does "specialized specialized" mean?</li>
  <li>Any other insights would be greatly appreciated.</li>
  </ul>