EXC_BAD_ACCESS after Xcode 15 upgrade

After our upgrade to Xcode 15.3, our app compiles and builds, but when we run it on an iPhone it crashes with EXC_BAD_ACCESS (code=1, address=0x15b) upon starting.

We're using Qt and the crash occurs when we try to access our app's sqlite file with QSqlQuery::exec(). The EXC_BAD_ACCESS occurs when trying to run a SELECT or PRAGMA statement to read from the sqlite. Running an INSERT or DELETE with the exec() method does not result in an exception; we just get an error saying that the table in the command does not exist.

exec() crashes when it gets to sqlite3VdbeMemGrow in the sqlite3VdbeMemStringify call.

We're using a "solid" QSqlQuery object variable in our code, not a pointer to a QSqlQuery object, so it's not like our code is using an uninitialized pointer.

We tried the suggestion in this post that references this project's bug tracker and changed our iOS Minimum Deployment setting in Xcode from 11.0 to 13.0, but this didn't resolve the issue.

I hypothesized that perhaps the Xcode update prohibits the main thread from doing file access, but after preventing our main thread from doing any accessing of the sqlite file, we still get EXC_BAD_ACCESS (code=1, address=0x15b) from a separate thread that tries to access the sqlite file.

I hypothesized that perhaps it was a file access permission issue when I saw the app trying to use the sqlite file out of the "Documents" folder /var/mobile/Containers/Data/Application/AAC50B3C-4DCF-4122-B88A-FC631E6BB9A0/Documents. I changed the app to use a different container sub folder but that gave different errors:

QIODevice::write (QFile, "/var/mobile/Containers/Data/Application/E64A08B4-5F59-433E-9111-D503F190383F/Library/Application Support/ELD/log.txt"): device not open

which would be our app's log file. The sqlite commands all give database not open responses.

Another thread suggested downgrading Xcode, but we also got the EXC_BAD_ACCESS with Xcode 15.0.1.

Thanks for your time!

Answered by criegel in 787275022

It seems all is well after adding

QTPLUGIN += qsqlite

to the ios section of my Qt project file.

I think it would be better to post your app's crash report, though you included most of its information in your post already.

Running an INSERT or DELETE with the exec() method does not result in an exception; we just get an error saying that the table in the command does not exist.

This makes me think there's an error accessing the database file, though I am not sure.

exec() crashes when it gets to sqlite3VdbeMemGrow in the sqlite3VdbeMemStringify call.

It seems like a memory allocation-related segfault bug in SQLite (somewhere here, to be precise: https://github.com/sqlite/sqlite/blob/master/src/vdbemem.c#L242), so I'm not sure what Xcode changes could determine this.

I've attached the app's crash report:

Accepted Answer

It seems all is well after adding

QTPLUGIN += qsqlite

to the ios section of my Qt project file.

EXC_BAD_ACCESS after Xcode 15 upgrade
 
 
Q