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

Data.insert(:at:) fails at runtime on sliced Data

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Medium
    • Resolution: Invalid
    • Component/s: Foundation
    • Labels:
      None
    • Environment:

      Apple Swift version 4.0 (swiftlang-900.0.65 clang-900.0.37)
      Target: x86_64-apple-macosx10.9

      Description

      var data = Data(bytes: [0, 128])
      data.removeFirst(1)
      data.insert(1, at: 0)

      Expected: data == Data(bytes: [1,128])

      Actual:

      data: Data =Process 76646 stopped
      * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
          frame #0: 0x000000010290ef4c libswiftFoundation.dylib`function signature specialization <Arg[0] = Owned To Guaranteed, Arg[1] = Exploded> of Foundation.Data._validateRange<A where A: Swift.RangeExpression, A.Bound == Swift.Int>(A) -> () + 268
      libswiftFoundation.dylib`function signature specialization <Arg[0] = Owned To Guaranteed, Arg[1] = Exploded> of Foundation.Data._validateRange<A where A: Swift.RangeExpression, A.Bound == Swift.Int>(A) -> ():
      ->  0x10290ef4c <+268>: ud2    
          0x10290ef4e <+270>: nop    
      
      libswiftFoundation.dylib`___lldb_unnamed_symbol4$$libswiftFoundation.dylib:
          0x10290ef50 <+0>:   pushq  %rbp
          0x10290ef51 <+1>:   movq   %rsp, %rbp
      Target 0: (repl_swift) stopped.
       {
        _backing = <extracting data from value failed>
      
        _sliceRange = {
          lowerBound = <extracting data from value failed>
      
          upperBound = <extracting data from value failed>
      
        }
      }

      This seems to  be a regression from 3.1 –> 4.0

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            Reitzig Raphael
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: