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

Pointer double free issue with ImagePrefetcher #1109

Closed
3 tasks done
kukushi opened this issue Feb 6, 2019 · 5 comments
Closed
3 tasks done

Pointer double free issue with ImagePrefetcher #1109

kukushi opened this issue Feb 6, 2019 · 5 comments

Comments

@kukushi
Copy link
Contributor

kukushi commented Feb 6, 2019

Check List

Thanks for considering to open an issue. Before you submit your issue, please confirm these boxes are checked.

Issue Description

What

Crashed when prefetching images in a row.

Reproduce

You can test it on the latest Kingfisher codebase in ImagePrefetcherTests.swift.

func testPrefetchMultiTimes() {
        testURLs.forEach { stub($0, data: testImageData) }

        for _ in 0..<10000 {
            let prefetcher = ImagePrefetcher(resources: testURLs)
            prefetcher.start()
        }
    }

You may need to run it serveral times before the crashed happened.

Other comment

screen shot 2019-02-06 at 2 15 20 pm

@kukushi
Copy link
Contributor Author

kukushi commented Feb 6, 2019

Each prefetcher instance runs on an independent serial queue, while they are using the same image downloader. When downloading images, the downloader concurrently overwrites the same task's onTaskDone delegate's block, which cause a double free issue.

@onevcat
Copy link
Owner

onevcat commented Feb 7, 2019

Thanks for reporting this. I will check it as soon as I can.

@onevcat
Copy link
Owner

onevcat commented Feb 11, 2019

Should be fixed by making all prefetcher use the same queue.

@onevcat onevcat closed this as completed Feb 11, 2019
@kukushi
Copy link
Contributor Author

kukushi commented Feb 11, 2019

Will the new version release in coming days?

@onevcat
Copy link
Owner

onevcat commented Feb 11, 2019

5.1.1 was released.

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