SQlite issue because of entitlements?

Hello,

I am having some trouble with an application accessing and running SQlite database queries.

The error I am getting is (5642) SQLITE_IOERR_SEEK when trying to sqlite_step_stement in the database. See https://www.sqlite.org/rescode.html#ioerr_seek

A bit of background, it is an application in Unreal Engine, and everything was working fine in Unreal Engine 4. The application uses a SQlite database on disk to store and fetch data. This database is saved to the documents folder. (I also tried other folders to see if that would make a difference)

But since switching to a new version of the engine, Unreal Engine 5, in a build I am getting errors when trying to read/write to the database. This only happens in a build .app file.

The only big difference I can find is that in the new engine when making a build the codesigning is already done in the engine. I don't see why those settings would break anything though. It also has an entitlements file, but I also edited it and made sure it has the same entitlements settings as my own scripts that are run afterwards.

I am overwriting the codesigning with our own CI/CD scripts afterwards. The .app file is codesigned, notarized and stapled by that script. Also I use an entitlements file to set certain values.

It doesn't seem to be a code related issue, as everything is working fine when running the application "in editor". But only when creating a final .app build. It doesn't matter if this build is in Debug or Shipping.

My first thought was to try more entitlements settings. But I tried the following and I am still getting the same errors:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>com.apple.security.cs.debugger</key>
	<true/>
	<key>com.apple.security.cs.disable-executable-page-protection</key>
	<true/>
	<key>com.apple.security.cs.disable-library-validation</key>
	<true/>
	<key>com.apple.security.automation.apple-events</key>
	<true/>
	<key>com.apple.security.app-sandbox</key>
	<false/>
	<key>com.apple.security.cs.allow-dyld-environment-variables</key>
	<true/>
	<key>com.apple.security.cs.allow-jit</key>
	<true/>
	<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
	<true/>
	<key>com.apple.security.files.downloads.read-write</key>
	<true/>
	<key>com.apple.security.network.client</key>
	<true/>
	<key>com.apple.security.network.server</key>
	<true/>
</dict>
</plist>

I also am thinking that it might be a different issue as the application is able to create a database file in the documents folder, just not able to do the read write inside the database.

These values are just set to try if any of these settings "fix" the issue, but thus far no luck.

As there is nothing I can find in Unreal Engine related forums, and I also do not have a lot of experience with all the options when making Mac builds. I was hoping someone on this forum could think of a reason why a .app file would have problems with reading and writing to a SQlite database.

Answered by SoulRyder in 785373022

Thanks for the reply! Good to know that I should not add the sandbox property if I don't want to use it!

It turned out to be a different issue though. In Unreal Engine 4 I was using sqlite3.h that I imported myself into the project. In Unreal Engine 5 I wanted to make use of SQLiteCore (a plugin inside the engine) that has it's own sqlite3.h file. With the intention of later moving some of the code to use SQliteCore instead of my own implementation, I pointed my code to that sqlite3.h file of SQliteCore. This file seemed to be the same and because everything was working on other platforms without any issues, I didn't immediately think that this had anything to do with the issue.

Turns out though that SQLiteCore seems to be bugged on MacOS and some other platforms... And reverting some code to point back to our own sqlite3.h file fixes the issue... So nothing to do with entitlements or codesigning.

This topic can be closed.

Small correction, it looks like reading from the database works, it's just writing to, using INSERT or REPLACE INTO it that gives me this SEEK error.

OK, so we’re on the Mac here, right?

If so, please fix this:

<key>com.apple.security.app-sandbox</key>
<false/>

If you want your app to be sandboxed — typically because you intend to ship on the Mac App Store — then this should be true. If you don’t want your app to be sandboxed, remove the entire com.apple.security.app-sandbox property. Un-sandboxed is the default on macOS, and try to set it to false just causes problems.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Accepted Answer

Thanks for the reply! Good to know that I should not add the sandbox property if I don't want to use it!

It turned out to be a different issue though. In Unreal Engine 4 I was using sqlite3.h that I imported myself into the project. In Unreal Engine 5 I wanted to make use of SQLiteCore (a plugin inside the engine) that has it's own sqlite3.h file. With the intention of later moving some of the code to use SQliteCore instead of my own implementation, I pointed my code to that sqlite3.h file of SQliteCore. This file seemed to be the same and because everything was working on other platforms without any issues, I didn't immediately think that this had anything to do with the issue.

Turns out though that SQLiteCore seems to be bugged on MacOS and some other platforms... And reverting some code to point back to our own sqlite3.h file fixes the issue... So nothing to do with entitlements or codesigning.

This topic can be closed.

SQlite issue because of entitlements?
 
 
Q