-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SharkORM fetch crashing on background fetch #136
Comments
Hi @MeteC, that is a spicy one. Thank you for the time you've taken to try and track this down. We also see that with one of our major projects. We had it cornered at one point where we felt it was to do with background encryption, but we were unable to work anything out beyond that. At one point we felt it could be a free'd SQlite3 pointer, but lots of the preceding calls check validity of the main handle and stmt structs. As it crashes deeply within SQLite and not at the surface, I wonder if it's SharkORM doing something flaky and actually that might have been fixed by SQLite in the last 2 years since it was upgraded. We could try updating to a later maintenance release of SQLite and see if that solves the issue as a very quick attempt at a fix. Casually looking at where is went wrong however, deep in the WAL, makes me feel like it's iOS locking that file for some reason and it having a valid handle to the log, but being unable to read from it. |
To test my last theory, you could set the log mode to none (or equivalent), and see if that stops the issue. |
Ah right! Well thanks Adrian, it's nice to know I'm not alone at least. 😆 Spicy indeed. Ok will try the log mode change - to be specific do you mean I might change (As seen in the line |
So, i'd go for DELETE.
As SQLite will open the file each time, so won't get unpicked by something holding onto the file. |
Thought that might be the way to go, thanks! So after a cursory test with DELETE mode I'm not seeing any crashes - I'll install on all previously offending devices and monitor Crashlytics over the course of the week to see results. I'll report back! |
FYI No further issues all week, it's looking good for DELETE mode! |
Yes it is, however. I was thinking of adding in a suspend call. Which could change the mode to delete and roll the log into the sqlite3 file. Then on app resume, it could switch back to WAL for performance. That way you gain stability and file security and keep performance as well. |
Hi Adrian et al.,
I've been trying for a long time to track down a crash I've only been seeing sporadically via Crashlytics, but I've managed to start replicating it myself, and I wonder if you've any knowledge on the matter.
Specifically, I'm seeing
EXC_BAD_ACCESS
during a call tosqlite3_step
in the stack after calling SharkORM fetches during an iOS background fetch (myUIApplicationDelegate::performFetchWithCompletionHandler
calls a SharkORM fetch to see what's in the DB). I'll paste in the thread stack below.I couldn't replicate this without waiting some minutes - that is, running my app and then using Xcode's "Simulate Background Fetch" caused no problems at all the first few times I did it. Then 5-10 mins later I tried again (without having touched the phone at all meanwhile) and I could replicate the crash. So it seems the app and phone needs to be quite deeply backgrounded - I've never known sqlite to fail like this before..
Any help or clues would be much appreciated! It's a nasty bug because it can take so much time to replicate each time...
Stack trace:
(note line numbers for SharkORM.m will be a bit higher than they would be in the official version, as I hacked some extra calls into
openDatabaseNamed
for debugging.)The text was updated successfully, but these errors were encountered: