Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-8593] Runtime: Unable to Demangle Type of Field #51109

Closed
swift-ci opened this issue Aug 21, 2018 · 6 comments
Closed

[SR-8593] Runtime: Unable to Demangle Type of Field #51109

swift-ci opened this issue Aug 21, 2018 · 6 comments

Comments

@swift-ci
Copy link
Collaborator

@swift-ci swift-ci commented Aug 21, 2018

Previous ID SR-8593
Radar None
Original Reporter dennisvennink (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate
Environment

2,4 GHz Intel Core i7 MacBook Pro (17-inch, Late 2011) running macOS High Sierra 10.13.5 (17F77), Xcode 10.0 beta 6 (10L232m) and Swift 4.2 (swiftlang-1000.0.36 clang-1000.0.4).

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, RunTimeCrash, Runtime
Assignee None
Priority Medium

md5: f33dbaa9a29e2a2fca8d3bcf511b9b56

duplicates:

  • SR-8354 Runtime warning on failure to demangle type

Issue Description:

Given the following code:

@inlinable public func zipLongest <Collection1, Collection2> (_ collection1: Collection1, _ collection2: Collection2) -> ZipLongest2Collection<Collection1, Collection2> {
  return ZipLongest2Collection(_collection1: collection1, _collection2: collection2)
}

public struct ZipLongest2Collection <Collection1: Collection, Collection2: Collection> {
  @usableFromInline internal var _collection1: Collection1
  @usableFromInline internal var _collection2: Collection2

  @inlinable public init (_collection1 collection1: Collection1, _collection2 collection2: Collection2) {
    (_collection1, _collection2) = (collection1, collection2)
  }
}

extension ZipLongest2Collection: Collection {
  public typealias Element = (Collection1.Element?, Collection2.Element?)

  public enum Index: Comparable, CustomStringConvertible {
    case index (Collection1.Index, Collection2.Index)
    case endIndex

    @inlinable public static func < (lhs: Index, rhs: Index) -> Bool {
      switch (lhs, rhs) {
        case (.endIndex, _):
          return false

        case (_, .endIndex):
          return true

        case let (.index(lhsIndex1, lhsIndex2), .index(rhsIndex1, rhsIndex2)):
          return lhsIndex1 < rhsIndex1 && lhsIndex2 < rhsIndex2
      }
    }

    @inlinable public var description: String {
      switch (self) {
        case .endIndex:
          return "endIndex"

        case let .index(index1, index2):
          return "(\(index1), \(index2))"
      }
    }
  }

  @inlinable public var startIndex: Index {
    let index1 = _collection1.startIndex
    let index2 = _collection2.startIndex

    return index1 == _collection1.endIndex && index2 == _collection2.endIndex ?
      .endIndex :
      .index(index1, index2)
  }

  @inlinable public var endIndex: Index {
    return .endIndex
  }

  @inlinable public subscript (position: Index) -> Element {
    switch position {
      case .endIndex:
        preconditionFailure("position must be a valid index of the collection")

      case let .index(index1, index2):
        precondition(
          index1 <= _collection1.endIndex && index2 <= _collection2.endIndex,
          "both indices must be lesser than or equal to their end indices"
        )

        return (
          index1 == _collection1.endIndex ? .none : .some(_collection1[index1]),
          index2 == _collection2.endIndex ? .none : .some(_collection2[index2])
        )
    }
  }

  @inlinable public func index (after index: Index) -> Index {
    switch index {
      case .endIndex:
        preconditionFailure("can't advance beyond endIndex")

      case let .index(index1, index2):
        let indexAfterIndex1 = index1 == _collection1.endIndex ?
          _collection1.endIndex :
          _collection1.index(after: index1)
        let indexAfterIndex2 = index2 == _collection2.endIndex ?
          _collection2.endIndex :
          _collection2.index(after: index2)

        if indexAfterIndex1 == _collection1.endIndex &&
           indexAfterIndex2 == _collection2.endIndex {
          return .endIndex
        }

        return .index(indexAfterIndex1, indexAfterIndex2)
    }
  }
}

This:

print(zipLongest([0, 1, 2], [0]).indices)

Will print a runtime bug (the code still exits with 0):

DefaultIndices<ZipLongest2Collection<Array<Int>, Array<Int>>>(_elements: Benchmark.ZipLongest2Collection<Swift.Array<Swift.Int>, Swift.Array<Swift.Int>>(_collection1: [0, 1, 2], _collection2: [0])SWIFT RUNTIME BUG: unable to demangle type of field '_startIndex'. mangled type name is '5IndexSlQz'
2018-08-21 23:24:31.087946+0200 xctest[74142:19397894] SWIFT RUNTIME BUG: unable to demangle type of field '_startIndex'. mangled type name is '5IndexSlQz'
, _startIndex: ()SWIFT RUNTIME BUG: unable to demangle type of field '_endIndex'. mangled type name is '5IndexSlQz'
2018-08-21 23:24:31.088083+0200 xctest[74142:19397894] SWIFT RUNTIME BUG: unable to demangle type of field '_endIndex'. mangled type name is '5IndexSlQz'
, _endIndex: ())
@belkadan
Copy link
Contributor

@belkadan belkadan commented Aug 21, 2018

@mikeash
Copy link
Contributor

@mikeash mikeash commented Aug 22, 2018

Likely the same as SR-8354 which is supposedly fixed on recent master. I tried the example here with a recent build and did not see the error.

@swift-ci
Copy link
Collaborator Author

@swift-ci swift-ci commented Nov 4, 2018

Comment by Rob Bishop (JIRA)

I'm getting almost the same error message. I've stripped my code down to a bare minimum: create a command-line project in XCode, remove absolutely everything from main.swift, and replace it with print(Slice<Array<Int>>()). Really, just that.

XCode Version 10.1 (10B61), Mojave on MacBook Pro (Retina, 15-inch, Mid 2015)

I get the following message.

Slice<Array<Int>>(warning: the Swift runtime was unable to demangle the type of field '_startIndex'. the mangled type name is '5IndexSlQz'. this field will show up as an empty tuple in Mirrors
2018-11-04 01:01:19.482830-0700 Sequence[76030:9123388] warning: the Swift runtime was unable to demangle the type of field '_startIndex'. the mangled type name is '5IndexSlQz'. this field will show up as an empty tuple in Mirrors
_startIndex: ()warning: the Swift runtime was unable to demangle the type of field '_endIndex'. the mangled type name is '5IndexSlQz'. this field will show up as an empty tuple in Mirrors
2018-11-04 01:01:19.483220-0700 Sequence[76030:9123388] warning: the Swift runtime was unable to demangle the type of field '_endIndex'. the mangled type name is '5IndexSlQz'. this field will show up as an empty tuple in Mirrors
, _endIndex: (), _base: [])

@belkadan
Copy link
Contributor

@belkadan belkadan commented Nov 5, 2018

The fix didn't make it into Xcode 10.1, sorry.

@swift-ci
Copy link
Collaborator Author

@swift-ci swift-ci commented Feb 6, 2019

Comment by Jeff Holliday (JIRA)

@belkadan did it make it into Xcode 10.2?

@belkadan
Copy link
Contributor

@belkadan belkadan commented Feb 6, 2019

It should have, yes. If you're still seeing this, please file a new bug with your test case!

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants