Open jeremyfa opened 2 years ago
I created a stress-test app that specifically tests this in order to reproduce the issue (performing many read and writes to/from an sqlite database from 2 different thread : the main thread + a background thread).
What I discovered is that the app runs fine if we don't do anything specific. There doesn't seem to be any issue with concurrent reads/writes. Mutexes are working as expected etc...
I did however reproduce the crash above from time to time by simply closing the app (tested with a mac build). It seems to happen when the background thread is doing some work and at the same time the app is closed, and, maybe, some hxcpp stuff is getting cleaned-up?
I didn't check in details what happens exactly when the app gets closed, but I guess I should find a way to ensure that when the app is about to close, background thread work should be stopped as well, before HXCPP runtime is shut down. Not sure how to achieve that though.
It would be helpful to see the stack traces of all the threads in the case of a crash - especially if there is just 1 other thread. However, it looks like it it crashing the c++ code, which generally means a memory overwrite somewhere. One way to better stress test is to add explicit gc_collect calls in different places - for example randomly in the sql results construction. This can help uncover issues.
The crash is not systematic. Could even say pretty rare, but it gets reported from time to time.
I have an app that reads from and writes to a sqlite db. It uses
sys.db.Sqlite
for that. Most of the time, it works, but it can happen that the app crashes when querying the database. Following is an example of crash log I have. It crashes when trying to write to the database from a background thread.Some info:
sys.thread.Tls<Connection>
)SQLITE_THREADSAFE
is1
and opened connections are expected to be thread safe.mutex.release()
calls in exception catch clauses, but the crashes I'm having don't seem to be related to that anyway).The crash log on the related (background) thread:
I'm trying to find out why this happens, but running out of ideas.
Are there things I should check in the project, the code that could make the app crash at this place? The crash being rare, I did not manage to reproduce it locally unfortunately.
Got these crashes on iOS, but it is not specific to any iOS version or device, and can't say for sure if it's specific to iOS or if this could happen on Android as well.
The project was built with HXCPP_CAPTURE_SETJMP, using HXCPP 4.2.1.
Any pointer to try to investigate this would be welcome !