SQLite.swift icon indicating copy to clipboard operation
SQLite.swift copied to clipboard

Crash when accessing in multi-threaded environment

Open sree127 opened this issue 6 years ago • 12 comments

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

screen shot 2018-06-04 at 18 32 32

sree127 avatar Jun 04 '18 16:06 sree127

In my app also same issue occur. any fix on it?

deepti82 avatar Jun 13 '18 12:06 deepti82

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))
    }
}

pigmasha avatar Jun 19 '18 12:06 pigmasha

This does not happen on Xcode9.2. I checked it by switching Xcode. But I'm not sure.

wasitu avatar Jul 12 '18 06:07 wasitu

I got the same problem as "sree127". However, it was fixed with xcode9.2. Please note.

lpioneer avatar Jul 19 '18 17:07 lpioneer

XCode 10, iOS 9.3, Simulator, still crash in sqlite3_prepare_v2.

wukongzhikong avatar Oct 19 '18 11:10 wukongzhikong

It's ok on iOS 10.3.1 simulator.

wukongzhikong avatar Oct 19 '18 11:10 wukongzhikong

I had the same problem on iOS9 simulator, multi-thread use one Connection call sqlite3_prepare_v2.

YanPengImp avatar Dec 19 '18 03:12 YanPengImp

Connection.txt This patch helps me

makleso6 avatar Sep 06 '19 14:09 makleso6

Where did you apply the patch? I have the same problem and I can't solve it

lorenzomalferrari avatar May 18 '20 10:05 lorenzomalferrari

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

khsalman avatar Feb 04 '21 11:02 khsalman

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.

bridger avatar Apr 01 '21 12:04 bridger

#259 perhaps related

jberkel avatar Aug 25 '21 07:08 jberkel