SQLite.swift
SQLite.swift copied to clipboard
Crash when accessing in multi-threaded environment
Build Information
Application is written in Swift 4 Using SQLite.swift 0.11.4 via CocoaPods Xcode 9.3.1
Crash Information
I'm experiencing a crash in sqlite3_prepare_v2
which gets called from Connection.prepare
or Connection.pluck
on devices running iOS 9
& iOS 10
. The connections are accessed in a multi-threaded environment and works fine on iOS 11 and above.
Below is a screenshot of the exact place where the crash happens:
What might be the possible reason for this. TIA
In my app also same issue occur. any fix on it?
ios9: the following code crashes in connection.scalar
method with
Thread 7: EXC_BREAKPOINT (code=EXC_ARM_BREAKPOINT, subcode=0xdefe)
let connection = try! Connection(fullPath)
try! connection.run("CREATE TABLE Records (id INTEGER, name TEXT NOT NULL)")
for _ in 0 ..< 100 {
DispatchQueue.global().async {
_ = try? connection.scalar("SELECT COUNT(*) FROM Records")
}
}
DispatchQueue.global().async {
try! connection.transaction(.exclusive) {
try connection.run(Table("Records").drop(ifExists: true))
}
}
This does not happen on Xcode9.2. I checked it by switching Xcode. But I'm not sure.
I got the same problem as "sree127". However, it was fixed with xcode9.2. Please note.
XCode 10, iOS 9.3, Simulator, still crash in sqlite3_prepare_v2.
It's ok on iOS 10.3.1 simulator.
I had the same problem on iOS9 simulator, multi-thread use one Connection call sqlite3_prepare_v2.
Connection.txt This patch helps me
Where did you apply the patch? I have the same problem and I can't solve it
Still having the crash in XCode 12.4. I was using multiple thread. On single thread it works fine but crash on using multiple threads
I'm also seeing this issue with Xcode 12 and multiple threads. I'm not sure if this is due to an Xcode change or a SQLite.swift change.
#259 perhaps related