OpenCombine
OpenCombine copied to clipboard
EXC_BAD_ACCESS when repeatedly using Future
Hello folks. I am investigating an issue where I can trigger iOS to crash with an EXC_BAD_ACCESS when repeatedly using Future
s.
From OpenCombineTests.swift in my sample project repo:
import XCTest
import OpenCombine
private class Item {}
final class OpenCombineTests: XCTestCase {
func testBadAccessSimplified() async {
let item = await Future<Item, Never> { promise in
DispatchQueue.global().async {
promise(.success(Item()))
}
}
.value
}
}
If I run this test case repeatedly until failure with enough iterations (10000+), an EXC_BAD_ACCESS will (most likely) occur. See screenshot:
For context, this behavior also occurs when running with Apple's Combine. I haven't had much luck finding anyone who can help me understand what's going on here, so I am creating an issue here as I figure you folks might be able to help. 🙏
Notes:
- I have also been able to reproduce this issue a normal application lifecycle context
- As far as I can tell, the issue seems limited to Combine or OpenCombine usage. I have not been able to reproduce similar behavior with any other async library/solution.
Related links:
I think the issue might be caused by accessing the Future's result
from the Conduit
from outside of the Future's lock
here. Strangely neither the Address nor Thread sanitizers are able to catch this.
I think the issue might be caused by accessing the Future's
result
from theConduit
from outside of the Future'slock
here. Strangely neither the Address nor Thread sanitizers are able to catch this.
Hi @tarbaiev-smg. To clarify, are you thinking this issue is a bug with OpenCombine, or with my usage of Future? If it's the latter, can you please help me understand exactly what I'm doing wrong? Thank you!
Definitely the implementation, both Combine and OpenCombine. I spent a weekend investigating this exact issue.