Closed Bug 1171145 Opened 9 years ago Closed 9 years ago

fatal error: can not increment endIndex in UITests.BookmarkingTests

Categories

(Firefox for iOS :: Build & Test, defect)

All
iOS 8
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: rnewman, Assigned: rnewman)

Details

Attachments

(1 file)

47 bytes, text/x-github-pull-request
bnicholson
: review+
Details | Review
2015-06-03 12:04:38.201 [Debug] [BrowserViewController.swift:1413] readerMode(_:didChangeReaderModeState:forBrowser:): New readerModeState: Unavailable
2015-06-03 12:04:38.389 [Debug] [SQLiteBookmarks.swift:217] insertBookmark: Inserting bookmark with specified icon -1.
[DEBUG] Did disconnect
[DEBUG] Did end background task
2015-06-03 12:04:40.354 [Debug] [Profile.swift:170] onLocationChange: Ignoring navigation for nil.
fatal error: can not increment endIndex


Thread 1Queue : com.apple.main-thread (serial)
#0	0x010d3164 in function signature specialization <Arg[0] = Exploded, Arg[1] = Exploded, Arg[2] = Dead, Arg[3] = Dead> of Swift._fatalErrorMessage (Swift.StaticString, Swift.StaticString, Swift.StaticString, Swift.UInt) -> () ()
#1	0x010fa86c in generic specialization <Swift.String.Index with Swift.String.Index : Swift._ForwardIndexType in Swift, Swift.Int with Swift.Int : Swift._SignedIntegerType in Swift, Swift.Int with Swift.Int : Swift._BuiltinIntegerLiteralConvertible in Swift, Swift._DisabledRangeIndex_> of Swift._advanceForward <A : Swift._ForwardIndexType>(A, A.Distance) -> A ()
#2	0x010b71dc in protocol witness for static Swift.ForwardIndexType.~> infix <A : Swift.ForwardIndexType>(Swift.ForwardIndexType.Self.Type)(Swift.ForwardIndexType.Self, (Swift._Advance, Swift.ForwardIndexType.Self.Distance)) -> Swift.ForwardIndexType.Self in conformance Swift.String.Index : Swift.ForwardIndexType in Swift ()
#3	0x0108049c in Swift.advance <A : Swift.ForwardIndexType>(A, A.Distance) -> A ()
#4	0x000acce0 in Client.AutocompleteTextField.(removeCompletion in _6358D4D91A1BCF759402EA10EC5306B2) (Client.AutocompleteTextField)() -> () at /Users/rnewman/moz/git/firefox-ios/Client/Frontend/Widgets/AutocompleteTextField.swift:58
#5	0x000aed0c in Client.AutocompleteTextField.insertText (Client.AutocompleteTextField)(Swift.String) -> () at /Users/rnewman/moz/git/firefox-ios/Client/Frontend/Widgets/AutocompleteTextField.swift:111
#6	0x0016f2e0 in @objc Client.AutocompleteTextField.insertText (Client.AutocompleteTextField)(Swift.String) -> () ()
#7	0x280a1c0a in -[UIKeyboardImpl insertText:] ()
#8	0x22fb7ff0 in -[UIKeyboardImplAccessibility insertText:] ()
#9	0x282491c6 in -[UIKeyboardImpl performKeyboardOutput:] ()
#10	0x28248f30 in __55-[UIKeyboardImpl handleKeyboardInput:executionContext:]_block_invoke_2 ()
#11	0x27f1b07c in -[UIKeyboardTaskQueue continueExecutionOnMainThread] ()
#12	0x255f939e in __NSThreadPerformPerform ()
#13	0x2488122e in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ ()
#14	0x24880642 in __CFRunLoopDoSources0 ()
#15	0x2487ecc0 in __CFRunLoopRun ()
#16	0x247ca9a0 in CFRunLoopRunSpecific ()
#17	0x247ca7b2 in CFRunLoopRunInMode ()
#18	0x014c70d2 in +[KIFTypist enterCharacter:] at /Users/rnewman/moz/git/firefox-ios/Carthage/Checkouts/KIF/Classes/KIFTypist.m:92
#19	0x014d1b50 in -[KIFUITestActor enterTextIntoCurrentFirstResponder:fallbackView:] at /Users/rnewman/moz/git/firefox-ios/Carthage/Checkouts/KIF/Classes/KIFUITestActor.m:334
#20	0x014d20a8 in -[KIFUITestActor enterText:intoViewWithAccessibilityLabel:traits:expectedResult:] at /Users/rnewman/moz/git/firefox-ios/Carthage/Checkouts/KIF/Classes/KIFUITestActor.m:367
#21	0x014d1f44 in -[KIFUITestActor enterText:intoViewWithAccessibilityLabel:] at /Users/rnewman/moz/git/firefox-ios/Carthage/Checkouts/KIF/Classes/KIFUITestActor.m:356
#22	0x014d2cc0 in -[KIFUITestActor clearTextFromAndThenEnterText:intoViewWithAccessibilityLabel:] at /Users/rnewman/moz/git/firefox-ios/Carthage/Checkouts/KIF/Classes/KIFUITestActor.m:443
#23	0x014921d0 in UITests.BookmarkingTests.testBookmarkingUI (UITests.BookmarkingTests)() -> () at /Users/rnewman/moz/git/firefox-ios/UITests/BookmarkingTests.swift:36
#24	0x01493720 in @objc UITests.BookmarkingTests.testBookmarkingUI (UITests.BookmarkingTests)() -> () ()
#25	0x248bf854 in __invoking___ ()
#26	0x247e9fec in -[NSInvocation invoke] ()
#27	0x0157fa4c in -[XCTestCase invokeTest] ()
#28	0x0157fd30 in -[XCTestCase performTest:] ()
#29	0x01588f0a in -[XCTest run] ()
#30	0x0157e848 in -[XCTestSuite performTest:] ()
#31	0x01588f0a in -[XCTest run] ()
#32	0x0157e848 in -[XCTestSuite performTest:] ()
#33	0x01588f0a in -[XCTest run] ()
#34	0x0157e848 in -[XCTestSuite performTest:] ()
#35	0x01588f0a in -[XCTest run] ()
#36	0x0157ba94 in __25-[XCTestDriver _runSuite]_block_invoke ()
#37	0x0158655e in -[XCTestObservationCenter _observeTestExecutionForBlock:] ()
#38	0x0157b99e in -[XCTestDriver _runSuite] ()
#39	0x0157c402 in -[XCTestDriver _checkForTestManager] ()
#40	0x0158bbaa in +[XCTestProbe runTests:] ()
#41	0x255ee124 in __NSFireDelayedPerform ()
#42	0x2488115e in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ ()
#43	0x24880ce0 in __CFRunLoopDoTimer ()
#44	0x2487ef4a in __CFRunLoopRun ()
#45	0x247ca9a0 in CFRunLoopRunSpecific ()
#46	0x247ca7b2 in CFRunLoopRunInMode ()
#47	0x2bf7a1a8 in GSEventRunModal ()
#48	0x27f55694 in UIApplicationMain ()
#49	0x000866f0 in main at /Users/rnewman/moz/git/firefox-ios/Client/Application/main.swift:18

The app crashed after typing 

"http://localhost:59599/ "

The caret is after a space. There's a single match shown.
Failing code is the last line:

    private func removeCompletion() {
        if completionActive {
            let enteredText = text.substringToIndex(advance(text.startIndex, enteredTextLength))
We're calling

advance({index position: 0}, 24)

The current string is "http://localhost:59599/", which has 24 characters.

24 is out of range. 23 works. 
 
endIndex is 23.

I guess this is a failure to remove a completion when the entire completion has been typed.

The docs:

    /// The position of the first `Character` if the `String` is
    /// non-empty; identical to `endIndex` otherwise.
    var startIndex: String.Index { get }
Attached file Pull req.
Attachment #8614834 - Flags: review?(sarentz)
Comment on attachment 8614834 [details] [review]
Pull req.

Changing this over to bnicholson because he wrote most of this code.
Attachment #8614834 - Flags: review?(sarentz) → review?(bnicholson)
Assignee: nobody → rnewman
Status: NEW → ASSIGNED
Comment on attachment 8614834 [details] [review]
Pull req.

I'm a little confused about what's causing this. insertText() doesn't update enteredTextLength until *after* it calls removeCompletion(), so I would have expected enteredTextLength to be 23 in your case. I can't reproduce, so it's hard to investigate. Either way, this looks like a good safety argument to have.
Attachment #8614834 - Flags: review?(bnicholson) → review+
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: