Uploaded image for project: 'Swift'
  1. Swift
  2. SR-5292

Another Data slice-related crash

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Medium
    • Resolution: Done
    • Component/s: Foundation
    • Labels:
      None
    • Environment:

      Xcode 9 beta 2; build 9M137d

      Description

      If you attempt to append a Data object to another Data object, and that Data object is a slice of a larger Data object that is at least 101,582 bytes large, your app will non-reproducibly crash (although if you put it in a loop, it will happen quickly enough). The code below will demonstrate:

      import Foundation
      
      for i in 0..<Int.max {
      	print("attempt number \(i)")
      	
      	var data1 = Data()
      	let data2 = Data(count: 101582)
      
      	data1.append(data2.suffix(8))
      }
      

      If the slice is wrapped in a Data, as in "data1.append(Data(data2.suffix(8)))", the crash does not occur.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              CharlesJS Charles Srstka
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: