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

Line 301 of UIView_KIFAdditions causes a bad access error. #1108

Closed
azav opened this issue May 11, 2019 · 5 comments
Closed

Line 301 of UIView_KIFAdditions causes a bad access error. #1108

azav opened this issue May 11, 2019 · 5 comments

Comments

@azav
Copy link

azav commented May 11, 2019

When running our tests from Xcode with command U,

calling return [self _predicateSearchWithRequiresMatch:YES mustBeTappable:NO].view;

ends up creating a bad access error on line 301 of UIView-KIFAdditions.

CFRunLoopRunInMode(UIApplicationCurrentRunMode, delay, false);

Lots of cases under Xcode 10.2.1 are reporting EXC_BAD_ACCESS at calls to CFRunLoopRunInMode within UIView-KIFAdditions.

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x10)
    frame #0: 0x0000000118832f2c UIKitCore`__56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 439
    frame #1: 0x0000000118f20cc9 UIKitCore`_runAfterCACommitDeferredBlocks + 318
    frame #2: 0x0000000118f10199 UIKitCore`_cleanUpAfterCAFlushAndRunDeferredBlocks + 358
    frame #3: 0x0000000118f3d32b UIKitCore`_afterCACommitHandler + 124
    frame #4: 0x000000010f03e0f7 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
    frame #5: 0x000000010f0385be CoreFoundation`__CFRunLoopDoObservers + 430
    frame #6: 0x000000010f038c31 CoreFoundation`__CFRunLoopRun + 1505
    frame #7: 0x000000010f038302 CoreFoundation`CFRunLoopRunSpecific + 626
  * frame #8: 0x000000013155ef4c KIF`-[UIView(self=0x00007ffa01bb3400, _cmd=<unavailable>, matchBlock=<unavailable>, notHidden=<unavailable>) accessibilityElementMatchingBlock:notHidden:] at UIView-KIFAdditions.m:301:13 [opt]
    frame #9: 0x000000013155dd53 KIF`-[UIView(self=0x00007ffa08164fa0, _cmd=<unavailable>, matchBlock=<unavailable>, notHidden=<unavailable>) accessibilityElementMatchingBlock:notHidden:] at UIView-KIFAdditions.m:165:43 [opt]
    frame #10: 0x000000013155dd53 KIF`-[UIView(self=0x00007ffa06539fa0, _cmd=<unavailable>, matchBlock=<unavailable>, notHidden=<unavailable>) accessibilityElementMatchingBlock:notHidden:] at UIView-KIFAdditions.m:165:43 [opt]
    frame #11: 0x000000013155dd53 KIF`-[UIView(self=0x00007ffa01ad5000, _cmd=<unavailable>, matchBlock=<unavailable>, notHidden=<unavailable>) accessibilityElementMatchingBlock:notHidden:] at UIView-KIFAdditions.m:165:43 [opt]
    frame #12: 0x000000013155dd53 KIF`-[UIView(self=0x00007ffa00d9a400, _cmd=<unavailable>, matchBlock=<unavailable>, notHidden=<unavailable>) accessibilityElementMatchingBlock:notHidden:] at UIView-KIFAdditions.m:165:43 [opt]
    frame #13: 0x000000013155dd53 KIF`-[UIView(self=0x00007ffa0851a740, _cmd=<unavailable>, matchBlock=<unavailable>, notHidden=<unavailable>) accessibilityElementMatchingBlock:notHidden:] at UIView-KIFAdditions.m:165:43 [opt]
    frame #14: 0x000000013155dd53 KIF`-[UIView(self=0x00007ffa08514870, _cmd=<unavailable>, matchBlock=<unavailable>, notHidden=<unavailable>) accessibilityElementMatchingBlock:notHidden:] at UIView-KIFAdditions.m:165:43 [opt]
    frame #15: 0x000000013155dd53 KIF`-[UIView(self=0x00007ffa08514260, _cmd=<unavailable>, matchBlock=<unavailable>, notHidden=<unavailable>) accessibilityElementMatchingBlock:notHidden:] at UIView-KIFAdditions.m:165:43 [opt]
    frame #16: 0x000000013155dd53 KIF`-[UIView(self=0x00007ffa00d5f3f0, _cmd=<unavailable>, matchBlock=<unavailable>, notHidden=<unavailable>) accessibilityElementMatchingBlock:notHidden:] at UIView-KIFAdditions.m:165:43 [opt]
    frame #17: 0x000000013155dd53 KIF`-[UIView(self=0x00007ffa082238d0, _cmd=<unavailable>, matchBlock=<unavailable>, notHidden=<unavailable>) accessibilityElementMatchingBlock:notHidden:] at UIView-KIFAdditions.m:165:43 [opt]
    frame #18: 0x000000013155dd53 KIF`-[UIView(self=0x00007ffa082236d0, _cmd=<unavailable>, matchBlock=<unavailable>, notHidden=<unavailable>) accessibilityElementMatchingBlock:notHidden:] at UIView-KIFAdditions.m:165:43 [opt]
    frame #19: 0x000000013155dd53 KIF`-[UIView(self=0x00007ffa00fe6b40, _cmd=<unavailable>, matchBlock=<unavailable>, notHidden=<unavailable>) accessibilityElementMatchingBlock:notHidden:] at UIView-KIFAdditions.m:165:43 [opt]
    frame #20: 0x000000013155dd53 KIF`-[UIView(self=0x00007ffa00f15d20, _cmd=<unavailable>, matchBlock=<unavailable>, notHidden=<unavailable>) accessibilityElementMatchingBlock:notHidden:] at UIView-KIFAdditions.m:165:43 [opt]
    frame #21: 0x000000013155895f KIF`-[UIApplication(self=<unavailable>, _cmd=<unavailable>, matchBlock=<unavailable>) accessibilityElementMatchingBlock:] at UIApplication-KIFAdditions.m:65:43 [opt]
    frame #22: 0x000000013155693a KIF`+[UIAccessibilityElement(self=UIAccessibilityElement, _cmd=<unavailable>, foundElement=0x00007ffee76c95f8, foundView=0x00007ffee76c9600, predicate=<unavailable>, mustBeTappable=NO, error=domain: @"KIFTest" - code: 0) accessibilityElement:view:withElementMatchingPredicate:tappable:error:] at UIAccessibilityElement-KIFAdditions.m:80:39 [opt]
    frame #23: 0x0000000131548df0 KIF`__89-[KIFUITestActor waitForAccessibilityElement:view:withElementMatchingPredicate:tappable:]_block_invoke(.block_descriptor=<unavailable>, error=<unavailable>) at KIFUITestActor.m:143:16 [opt]
    frame #24: 0x0000000131545d0f KIF`-[KIFTestActor tryRunningBlock:complete:timeout:error:](self=<unavailable>, _cmd=<unavailable>, executionBlock=<unavailable>, completionBlock=<unavailable>, timeout=10, error=0x00007ffee76c9458) at KIFTestActor.m:88:22 [opt]
    frame #25: 0x0000000131545e95 KIF`-[KIFTestActor runBlock:complete:timeout:](self=0x0000600003b203c0, _cmd=<unavailable>, executionBlock=<unavailable>, completionBlock=<unavailable>, timeout=<unavailable>) at KIFTestActor.m:111:10 [opt]
    frame #26: 0x0000000131545f1f KIF`-[KIFTestActor runBlock:complete:](self=0x0000600003b203c0, _cmd=<unavailable>, executionBlock=<unavailable>, completionBlock=<unavailable>) at KIFTestActor.m:118:5 [opt]
    frame #27: 0x0000000131548d98 KIF`-[KIFUITestActor waitForAccessibilityElement:view:withElementMatchingPredicate:tappable:](self=<unavailable>, _cmd=<unavailable>, element=0x00007ffee76c95f8, view=<unavailable>, predicate=<unavailable>, mustBeTappable=<unavailable>) at KIFUITestActor.m:142:5 [opt]
    frame #28: 0x00000001315552ba KIF`-[KIFUIViewTestActor _predicateSearchWithRequiresMatch:mustBeTappable:](self=<unavailable>, _cmd=<unavailable>, requiresMatch=<unavailable>, tappable=NO) at KIFUIViewTestActor.m:571:9 [opt]
    frame #29: 0x0000000131552a53 KIF`-[KIFUIViewTestActor waitForView](self=<unavailable>, _cmd=<unavailable>) at KIFUIViewTestActor.m:175:12 [opt]
    frame #30: 0x00000001314370b3 HIFeatureTests`BaseKIFTestCase.signOut(self=0x0000600001389e90) at BaseKIFTestCase.swift:62:64 [opt]
    frame #31: 0x000000013143968c HIFeatureTests`specialized BaseKIFTestCase.moveToMakePaymentScreen(self=0x0000600001389e90) at BaseKIFTestCase.swift:99:14 [opt]
    frame #32: 0x0000000131445b5b HIFeatureTests`ShowErrorMessageOnLPEandFees.testPaymentRoutingNumberError() [inlined] HIFeatureTests.BaseKIFTestCase.moveToMakePaymentScreen(username: Swift.String) -> () at <compiler-generated>:0 [opt]
    frame #33: 0x0000000131445b42 HIFeatureTests`ShowErrorMessageOnLPEandFees.testPaymentRoutingNumberError(self=0x0000600001389e90) at UserMakesAPayment.swift:244 [opt]
    frame #34: 0x000000013144061b HIFeatureTests`merged @objc HIFeatureTests.UserMakesAPayment.testMakePaymentWithDefaultOptions() -> () + 27
    frame #35: 0x000000010f0de4cc CoreFoundation`__invoking___ + 140
    frame #36: 0x000000010f0dba45 CoreFoundation`-[NSInvocation invoke] + 325
    frame #37: 0x000000013016cb74 XCTest`__24-[XCTestCase invokeTest]_block_invoke.194 + 78
    frame #38: 0x00000001301c48a4 XCTest`-[XCTestCase(Failures) performFailableBlock:testCaseRun:shouldInterruptTest:] + 57
    frame #39: 0x00000001301c47c2 XCTest`-[XCTestCase(Failures) _performTurningExceptionsIntoFailuresInterruptAfterHandling:block:] + 96
    frame #40: 0x000000013016c804 XCTest`__24-[XCTestCase invokeTest]_block_invoke + 848
    frame #41: 0x00000001301cad01 XCTest`-[XCUITestContext performInScope:] + 128
    frame #42: 0x000000013016c3f1 XCTest`-[XCTestCase testContextPerformInScope:] + 116
    frame #43: 0x000000013016c4a7 XCTest`-[XCTestCase invokeTest] + 137
    frame #44: 0x000000013016df73 XCTest`__26-[XCTestCase performTest:]_block_invoke_2 + 43
    frame #45: 0x00000001301c48a4 XCTest`-[XCTestCase(Failures) performFailableBlock:testCaseRun:shouldInterruptTest:] + 57
    frame #46: 0x00000001301c47c2 XCTest`-[XCTestCase(Failures) _performTurningExceptionsIntoFailuresInterruptAfterHandling:block:] + 96
    frame #47: 0x000000013016de8a XCTest`__26-[XCTestCase performTest:]_block_invoke.316 + 88
    frame #48: 0x00000001301d53b7 XCTest`+[XCTContext runInContextForTestCase:block:] + 225
    frame #49: 0x000000013016d5f8 XCTest`-[XCTestCase performTest:] + 676
    frame #50: 0x00000001301b0d6c XCTest`-[XCTest runTest] + 57
    frame #51: 0x00000001301680d7 XCTest`__27-[XCTestSuite performTest:]_block_invoke + 365
    frame #52: 0x00000001301678b3 XCTest`-[XCTestSuite _performProtectedSectionForTest:testSection:] + 54
    frame #53: 0x0000000130167b6f XCTest`-[XCTestSuite performTest:] + 290
    frame #54: 0x00000001301b0d6c XCTest`-[XCTest runTest] + 57
    frame #55: 0x00000001301680d7 XCTest`__27-[XCTestSuite performTest:]_block_invoke + 365
    frame #56: 0x00000001301678b3 XCTest`-[XCTestSuite _performProtectedSectionForTest:testSection:] + 54
    frame #57: 0x0000000130167b6f XCTest`-[XCTestSuite performTest:] + 290
    frame #58: 0x00000001301b0d6c XCTest`-[XCTest runTest] + 57
    frame #59: 0x00000001301680d7 XCTest`__27-[XCTestSuite performTest:]_block_invoke + 365
    frame #60: 0x00000001301678b3 XCTest`-[XCTestSuite _performProtectedSectionForTest:testSection:] + 54
    frame #61: 0x0000000130167b6f XCTest`-[XCTestSuite performTest:] + 290
    frame #62: 0x00000001301b0d6c XCTest`-[XCTest runTest] + 57
    frame #63: 0x00000001301df986 XCTest`__44-[XCTTestRunSession runTestsAndReturnError:]_block_invoke + 171
    frame #64: 0x00000001301dfa57 XCTest`__44-[XCTTestRunSession runTestsAndReturnError:]_block_invoke.80 + 68
    frame #65: 0x000000013017f474 XCTest`-[XCTestObservationCenter _observeTestExecutionForBlock:] + 588
    frame #66: 0x00000001301df73d XCTest`-[XCTTestRunSession runTestsAndReturnError:] + 623
    frame #67: 0x000000013014c41c XCTest`-[XCTestDriver runTestsAndReturnError:] + 446
    frame #68: 0x00000001301d156f XCTest`_XCTestMain + 2333
    frame #69: 0x000000010a118bf1 libXCTestBundleInject.dylib`__RunTests_block_invoke_2 + 13
    frame #70: 0x000000010f03eaec CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
    frame #71: 0x000000010f03e2b0 CoreFoundation`__CFRunLoopDoBlocks + 336
    frame #72: 0x000000010f038b34 CoreFoundation`__CFRunLoopRun + 1252
    frame #73: 0x000000010f038302 CoreFoundation`CFRunLoopRunSpecific + 626
    frame #74: 0x0000000111e1c2fe GraphicsServices`GSEventRunModal + 65
    frame #75: 0x0000000118f15ba2 UIKitCore`UIApplicationMain + 140
    frame #76: 0x00000001086c5849 MrCooper`main(argc=5, argv=0x00007ffee76cbe28) at main.m:30:16
    frame #77: 0x00000001115f7541 libdyld.dylib`start + 1
    frame #78: 0x00000001115f7541 libdyld.dylib`start + 1
@justinseanmartin
Copy link
Contributor

This seems like either an Apple bug in UIPresentationController or a bug in your app as to how view presentation is being done. KIF is yielding the runloop to your app to execute when it didn't find the element that you told it to wait for.

Which version of KIF are you using? Some behavior in this method was changed relatively recently:
https://github.com/kif-framework/KIF/blob/master/Additions/UIView-KIFAdditions.m#L301

You might be able to comment out that line, as I don't think spinning the runloop there should be necessary. I'd guess though that this will just push the crash to happen elsewhere, but it is worth a shot.

@justinseanmartin
Copy link
Contributor

You could also try going back to version 3.7.3 of KIF, before the major changes in how we match against table view cells. If that works, it would be very helpful to know.

@azav
Copy link
Author

azav commented Jun 19, 2019

It's an odd one because it occasionally appears and I can't get clear steps as to what happened to cause it.

@justinseanmartin
Copy link
Contributor

The crash is within UIKit code, so it isn't something that is inherently KIFs fault. It is possible that it is exacerbated by quickly scrolling to many different positions in tableviews to try and find a matching element, though not necessarily. The table view cell matching code changed as a mitigation for issue #1007, where we used to enumerate the table view cells programmatically and started throwing exceptions in iOS 11. This is why I asked about going back to version 3.7.3 or before to see if that avoids the problem.

This could SO message could also be related:
https://stackoverflow.com/questions/39530125/app-crashing-on-runtransitionforcurrentstate-but-no-clue-as-to-why

I'm going to close this issue, as there isn't anything clearly wrong with KIF. If you disagree, please feel free to reactivate.

@azav
Copy link
Author

azav commented Jun 25, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants