jflinter / Dwifft

Swift Diff

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

EXC_BAD_ACCESS in thread

guofei opened this issue · comments

Xcode Version 7.1.1 (7B1005)

My code is like this:

dispatch_async(queue) {
    let s1 = get_a_string()
    let s2 = get_another_string()

    // size of a and b is about 1000
    let a = s1!.characters.split { $0 == "\n" }.map(String.init)
    let b = s2!.characters.split { $0 == "\n" }.map(String.init)

    let diff = a.diff(b) // crash in Array::diffFromIndices
}

1

Thanks for the crash report - I'll see if I can reproduce it.


Sent from Mailbox

On Sat, Nov 21, 2015 at 11:49 PM, guofei notifications@github.com wrote:

Xcode Version 7.1.1 (7B1005)
My code is like this:

dispatch_async(queue) {
  let s1 = get_a_string()
  let s2 = get_another_string()
  // size of a and b is about 1000
  let a = s1!.characters.split { $0 == "\n" }.map(String.init)
  let b = s2!.characters.split { $0 == "\n" }.map(String.init)
  let diff = a.diff(b) // crash in Array::diffFromIndices
}

1

Reply to this email directly or view it on GitHub:
#8

I've been unable to reproduce this after a fair amount of testing. If you can write a test case in DwifftTests.swift that reliably fails and send me a PR with it, I'll be happy to take another look though.

I change recursion to for loop then everything is ok.
So I think the problem is that the recursion may be too deep.

Example if i write:

    func testInThread() {
        let qos = Int(QOS_CLASS_USER_INITIATED.rawValue)
        let queue = dispatch_get_global_queue(qos, 0)
        dispatch_async(queue) {
            let string = String(count: 50, repeatedValue: Character("0"))
            let test = TestCase(string, string, string, "abc")
            let diff = test.array1.diff(test.array2)
            let printableDiff = diff.results.map({ $0.debugDescription }).joinWithSeparator("")
            XCTAssertEqual(printableDiff, test.expectedDiff, "incorrect diff")
        }
    }

the test will be failed

but if I write

    func testInThread() {
        let qos = Int(QOS_CLASS_USER_INITIATED.rawValue)
        let queue = dispatch_get_global_queue(qos, 0)
        dispatch_async(queue) {
            let string = String(count: 5000, repeatedValue: Character("0"))
            let test = TestCase(string, string, string, "abc")
            let diff = test.array1.diff(test.array2)
            let printableDiff = diff.results.map({ $0.debugDescription }).joinWithSeparator("")
            XCTAssertEqual(printableDiff, test.expectedDiff, "incorrect diff")
        }
    }

the test will be passed.

Please, help

Same problem here. For initialRows I have an array: [Int](0..<1150) (array of Ints from 0 through 1150). Then I randomly take like half of them out (amount doesn't seem to matter here) and set that to diffCalculator.rows. Then I get the screenshot like shown above.

In the debug window (left to log window) it says 1151 at table. Is this some out of bounds thing?

I may experiment some more, but what I tried is already the most basic usage I think.

Thanks that one works :). However it takes a couple of seconds to diff 1150 values :(. I probably should just forget about row animations for now :).