Uploaded image for project: 'Swift Driver'
  1. Swift Driver
  2. SWIFT-396

strange segfault when comparing `intValue` in command monitoring tests

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor - P4
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      Swift 5.0, OSX 10.14.4, Single server topology

      Description

      With the following patch applied:

      diff --git a/Tests/MongoSwiftTests/CommandMonitoringTests.swift b/Tests/MongoSwiftTests/CommandMonitoringTests.swift
      index 660e5ad..4c08a29 100644
      --- a/Tests/MongoSwiftTests/CommandMonitoringTests.swift
      +++ b/Tests/MongoSwiftTests/CommandMonitoringTests.swift
      @@ -411,7 +411,7 @@ private func normalizeExpectedReply(_ input: Document) -> Document {
                   continue
               // The server sends back doubles, but the JSON test files
               // contain integer statuses (see SPEC-1050.)
      -        } else if k == "ok", let dV = (v as? BSONNumber)?.doubleValue {
      +        } else if k == "ok", let dV = (v as? BSONNumber)?.intValue {
                   output[k] = dV
               // just copy the value over as is
               } else {
      

      Running the test suite results in the following segfault:

      Process 83389 stopped
      * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x90)
          frame #0: 0x00007fff68beb1a0 libswiftCore.dylib`swift_beginAccess + 96
      libswiftCore.dylib`swift_beginAccess:
      ->  0x7fff68beb1a0 <+96>:  movq   0x10(%rdx), %rsi
          0x7fff68beb1a4 <+100>: cmpq   %rbx, (%rdx)
          0x7fff68beb1a7 <+103>: jne    0x7fff68beb1bc            ; <+124>
          0x7fff68beb1a9 <+105>: testq  %r12, %r12
      Target 0: (xctest) stopped.
      (lldb) bt
      * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x90)
        * frame #0: 0x00007fff68beb1a0 libswiftCore.dylib`swift_beginAccess + 96
          frame #1: 0x00000001072abbab MongoSwiftPackageTests`DocumentIterator.init(doc=<unavailable>, self=<unavailable>) at DocumentIterator.swift:23:19
          frame #2: 0x00000001072abadf MongoSwiftPackageTests`DocumentIterator.__allocating_init(forDocument:) at DocumentIterator.swift:0
          frame #3: 0x00000001072a5487 MongoSwiftPackageTests`Document.getValue(key="_id", self=<unavailable>) at Document.swift:194:26
          frame #4: 0x0000000107247b50 MongoSwiftPackageTests`_BSONKeyedDecodingContainer.getValue(key=0x0000000107241e00 MongoSwiftPackageTests`MongoSwift._BSONDecoder.(in _61BF67FBF611D4A455451D2941CE4163).init(referencing: MongoSwift.BSONValue, at: Swift.Array<Swift.CodingKey>, options: MongoSwift.BSONDecoder._Options) -> MongoSwift._BSONDecoder + 160 at BSONDecoder.swift:248:22, self=<unavailable>) at BSONDecoder.swift:507:46
          frame #5: 0x0000000107248131 MongoSwiftPackageTests`_BSONKeyedDecodingContainer.decodeBSONType<A>(type=String, key=0x0000000107241e00 MongoSwiftPackageTests`MongoSwift._BSONDecoder.(in _61BF67FBF611D4A455451D2941CE4163).init(referencing: MongoSwift.BSONValue, at: Swift.Array<Swift.CodingKey>, options: MongoSwift.BSONDecoder._Options) -> MongoSwift._BSONDecoder + 160 at BSONDecoder.swift:248:22, self=<unavailable>) at BSONDecoder.swift:518:25
          frame #6: 0x000000010724a877 MongoSwiftPackageTests`_BSONKeyedDecodingContainer.decode(type=String, key=0x0000000107241e00 MongoSwiftPackageTests`MongoSwift._BSONDecoder.(in _61BF67FBF611D4A455451D2941CE4163).init(referencing: MongoSwift.BSONValue, at: Swift.Array<Swift.CodingKey>, options: MongoSwift.BSONDecoder._Options) -> MongoSwift._BSONDecoder + 160 at BSONDecoder.swift:248:22, self=<unavailable>) at BSONDecoder.swift:574:92
          frame #7: 0x000000010724c57d MongoSwiftPackageTests`protocol witness for KeyedDecodingContainerProtocol.decode(_:forKey:) in conformance _BSONKeyedDecodingContainer<A> at <compiler-generated>:0
          frame #8: 0x00007fff6896167e libswiftCore.dylib`Swift._KeyedDecodingContainerBox.decode(_: Swift.String.Type, forKey: A.Key) throws -> Swift.String + 110
          frame #9: 0x00007fff6895a1a9 libswiftCore.dylib`Swift.KeyedDecodingContainer.decode(_: Swift.String.Type, forKey: A) throws -> Swift.String + 57
          frame #10: 0x0000000107472410 MongoSwiftPackageTests`MongoClientTests.Wrapper.init(decoder=Decoder @ 0x00007ffeefbf9b78) at <compiler-generated>:0
          frame #11: 0x00000001074732d6 MongoSwiftPackageTests`protocol witness for Decodable.init(from:) in conformance MongoClientTests.Wrapper at <compiler-generated>:0
          frame #12: 0x00007fff68bb63a7 libswiftCore.dylib`dispatch thunk of Swift.Decodable.init(from: Swift.Decoder) throws -> A + 7
          frame #13: 0x000000010723fd07 MongoSwiftPackageTests`BSONDecoder.decode<A>(type=0x00000001075df818, document=<unavailable>, self=<unavailable>) at BSONDecoder.swift:146:25
          frame #14: 0x000000010731a8c1 MongoSwiftPackageTests`MongoCursor.next(self=<unavailable>) at MongoCursor.swift:130:43
          frame #15: 0x0000000107318c52 MongoSwiftPackageTests`MongoCursor.nextOrError(self=<unavailable>) at MongoCursor.swift:66:28
          frame #16: 0x000000010747b165 MongoSwiftPackageTests`implicit closure #5 in MongoClientTests.testCodingStrategies() at <compiler-generated>:0
          frame #17: 0x000000010747b29f MongoSwiftPackageTests`partial apply for implicit closure #5 in MongoClientTests.testCodingStrategies() at <compiler-generated>:0
          frame #18: 0x00000001075261fd MongoSwiftPackageTests`closure #1 in memoizedClosure<A>(withoutCaching=false, cache=nil, closure=0x000000010747b280 MongoSwiftPackageTests`partial apply forwarder for implicit closure #5 () throws -> Swift.Optional<MongoSwiftTests.MongoClientTests.Wrapper> in MongoSwiftTests.MongoClientTests.testCodingStrategies() throws -> () at <compiler-generated>) at Expression.swift:9:25
          frame #19: 0x0000000107526521 MongoSwiftPackageTests`partial apply for closure #1 in memoizedClosure<A>(_:) at <compiler-generated>:0
          frame #20: 0x0000000107526d39 MongoSwiftPackageTests`Expression.evaluate(self=<unavailable>) at Expression.swift:90:25
          frame #21: 0x0000000107552054 MongoSwiftPackageTests`closure #1 in equal<A>(actualExpression=<unavailable>, msg=<unavailable>, expectedValue=nil) at Equal.swift:9:48
          frame #22: 0x00000001075525f6 MongoSwiftPackageTests`partial apply for closure #1 in equal<A>(_:) at <compiler-generated>:0
          frame #23: 0x000000010755e260 MongoSwiftPackageTests`closure #1 in static Predicate.define(actual=<unavailable>, matcher=0x00000001075525d0 MongoSwiftPackageTests`partial apply forwarder for closure #1 (Nimble.Expression<A>, Nimble.ExpectationMessage) throws -> Nimble.PredicateResult in Nimble.equal<A where A: Swift.Equatable>(Swift.Optional<A>) -> Nimble.Predicate<A> at <compiler-generated>, msg="equal <Wrapper(_id: \"baseline\", date: 1970-01-01 00:01:40 +0000, uuid: 7EF68C71-B355-48F5-B600-82350843207B, data: 51 bytes)>") at Predicate.swift:50:24
          frame #24: 0x00000001075601bc MongoSwiftPackageTests`partial apply for closure #1 in static Predicate.define(_:matcher:) at <compiler-generated>:0
          frame #25: 0x000000010755dd21 MongoSwiftPackageTests`Predicate.satisfies(expression=<unavailable>, self=<unavailable>) at Predicate.swift:33:20
          frame #26: 0x000000010755fc67 MongoSwiftPackageTests`closure #1 in Predicate.after(actual=<unavailable>, self=<unavailable>, f=0x0000000107560100 MongoSwiftPackageTests`partial apply forwarder for closure #1 (Nimble.Expression<A>, Nimble.PredicateResult) throws -> Nimble.PredicateResult in Nimble.Predicate.requireNonNil.getter : Nimble.Predicate<A> at <compiler-generated>) at Predicate.swift:223:35
          frame #27: 0x00000001075605ec MongoSwiftPackageTests`partial apply for closure #1 in Predicate.after(f:) at <compiler-generated>:0
          frame #28: 0x000000010755dd21 MongoSwiftPackageTests`Predicate.satisfies(expression=<unavailable>, self=<unavailable>) at Predicate.swift:33:20
          frame #29: 0x000000010751d410 MongoSwiftPackageTests`run #1 <A>(description=nil, to="to", predicate=<unavailable>, expression=<unavailable>, style=<unavailable>) in execute<A>(_:_:_:to:description:captureExceptions:) at Expectation.swift:27:40
          frame #30: 0x000000010751de54 MongoSwiftPackageTests`closure #2 in execute<A>(result=(_value = 0), description=nil, to="to", predicate=<unavailable>, expression=<unavailable>, style=<unavailable>) at Expectation.swift:47:22
          frame #31: 0x000000010751e013 MongoSwiftPackageTests`partial apply for closure #2 in execute<A>(_:_:_:to:description:captureExceptions:) at <compiler-generated>:0
          frame #32: 0x000000010751885f MongoSwiftPackageTests`ExceptionCapture.tryBlock(unsafeBlock=0x000000010751dfc0 MongoSwiftPackageTests`partial apply forwarder for closure #2 () -> () in Nimble.execute<A>(_: Nimble.Expression<A>, _: Nimble.ExpectationStyle, _: Nimble.Predicate<A>, to: Swift.String, description: Swift.Optional<Swift.String>, captureExceptions: Swift.Bool) -> (Swift.Bool, Nimble.FailureMessage) at <compiler-generated>, self=<unavailable>) at ExceptionCapture.swift:24:9
          frame #33: 0x000000010751d066 MongoSwiftPackageTests`execute<A>(expression=<unavailable>, style=<unavailable>, predicate=<unavailable>, to="to", description=nil, captureExceptions=true) at Expectation.swift:46:17
          frame #34: 0x000000010751ea91 MongoSwiftPackageTests`Expectation.to(predicate=<unavailable>, description=nil, self=<unavailable>) at Expectation.swift:105:27
          frame #35: 0x0000000107474beb MongoSwiftPackageTests`MongoClientTests.testCodingStrategies(self=<unavailable>) at MongoClientTests.swift:130:72
          frame #36: 0x000000010747db15 MongoSwiftPackageTests`@objc MongoClientTests.testCodingStrategies() at <compiler-generated>:0
          frame #37: 0x00007fff3cd6502c CoreFoundation`__invoking___ + 140
          frame #38: 0x00007fff3cd64eff CoreFoundation`-[NSInvocation invoke] + 311
          frame #39: 0x00000001001821fc XCTest`__24-[XCTestCase invokeTest]_block_invoke_2.197 + 65
          frame #40: 0x0000000100206d27 XCTest`-[XCTMemoryChecker _assertInvalidObjectsDeallocatedAfterScope:] + 51
          frame #41: 0x000000010018b010 XCTest`-[XCTestCase assertInvalidObjectsDeallocatedAfterScope:] + 116
          frame #42: 0x000000010018218c XCTest`__24-[XCTestCase invokeTest]_block_invoke.191 + 207
          frame #43: 0x00000001001f4793 XCTest`-[XCTestCase(Failures) performFailableBlock:testCaseRun:shouldInterruptTest:] + 57
          frame #44: 0x00000001001f46b0 XCTest`-[XCTestCase(Failures) _performTurningExceptionsIntoFailuresInterruptAfterHandling:block:] + 96
          frame #45: 0x0000000100181da5 XCTest`__24-[XCTestCase invokeTest]_block_invoke + 856
          frame #46: 0x00000001001fab06 XCTest`-[XCUITestContext performInScope:] + 128
          frame #47: 0x0000000100181994 XCTest`-[XCTestCase testContextPerformInScope:] + 104
          frame #48: 0x0000000100181a40 XCTest`-[XCTestCase invokeTest] + 137
          frame #49: 0x00000001001835b2 XCTest`__26-[XCTestCase performTest:]_block_invoke_2 + 43
          frame #50: 0x00000001001f4793 XCTest`-[XCTestCase(Failures) performFailableBlock:testCaseRun:shouldInterruptTest:] + 57
          frame #51: 0x00000001001f46b0 XCTest`-[XCTestCase(Failures) _performTurningExceptionsIntoFailuresInterruptAfterHandling:block:] + 96
          frame #52: 0x00000001001834c9 XCTest`__26-[XCTestCase performTest:]_block_invoke.321 + 88
          frame #53: 0x0000000100202fa2 XCTest`+[XCTContext runInContextForTestCase:block:] + 225
          frame #54: 0x0000000100182c3b XCTest`-[XCTestCase performTest:] + 676
          frame #55: 0x00000001001d426f XCTest`-[XCTest runTest] + 57
          frame #56: 0x000000010017d73e XCTest`__27-[XCTestSuite performTest:]_block_invoke + 365
          frame #57: 0x000000010017cf1a XCTest`-[XCTestSuite _performProtectedSectionForTest:testSection:] + 54
          frame #58: 0x000000010017d1d6 XCTest`-[XCTestSuite performTest:] + 290
          frame #59: 0x00000001001d426f XCTest`-[XCTest runTest] + 57
          frame #60: 0x000000010017d73e XCTest`__27-[XCTestSuite performTest:]_block_invoke + 365
          frame #61: 0x000000010017cf1a XCTest`-[XCTestSuite _performProtectedSectionForTest:testSection:] + 54
          frame #62: 0x000000010017d1d6 XCTest`-[XCTestSuite performTest:] + 290
          frame #63: 0x00000001001d426f XCTest`-[XCTest runTest] + 57
          frame #64: 0x000000010017d73e XCTest`__27-[XCTestSuite performTest:]_block_invoke + 365
          frame #65: 0x000000010017cf1a XCTest`-[XCTestSuite _performProtectedSectionForTest:testSection:] + 54
          frame #66: 0x000000010017d1d6 XCTest`-[XCTestSuite performTest:] + 290
          frame #67: 0x00000001001d426f XCTest`-[XCTest runTest] + 57
          frame #68: 0x0000000100217781 XCTest`__44-[XCTTestRunSession runTestsAndReturnError:]_block_invoke + 171
          frame #69: 0x000000010021784b XCTest`__44-[XCTTestRunSession runTestsAndReturnError:]_block_invoke.80 + 68
          frame #70: 0x00000001001a199c XCTest`-[XCTestObservationCenter _observeTestExecutionForBlock:] + 594
          frame #71: 0x0000000100217537 XCTest`-[XCTTestRunSession runTestsAndReturnError:] + 623
          frame #72: 0x0000000100160f46 XCTest`-[XCTestDriver runTestsAndReturnError:] + 460
          frame #73: 0x00000001001ff240 XCTest`_XCTestMain + 2326
          frame #74: 0x0000000100002104 xctest`main + 245
          frame #75: 0x00007fff691cd3d5 libdyld.dylib`start + 1
          frame #76: 0x00007fff691cd3d5 libdyld.dylib`start + 1
      

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            matt.broadstone Matt Broadstone
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: