sqlite_orm
sqlite_orm copied to clipboard
Crash when using a lot of tables
I have a project with many tables, but every time I try to add the complete list of tables to my storage the app crashes. I created a python script that generates a complete test project with structs
, sql
and the make_table
storage initialization (See Crash.zip).
You can easily change the amount of generated tables in line 74 and 77. It always happens at about 40 (plus minus 10, I did not count) make_table
.
If you like you can use the python script for future testing and test data generation.
Is there a way to work around this issue?
what kind of crash you get? compiler crash or runtime crash?
@fnc12 this is a runtime crash. Tested with MSVC 2022 17.3.4. It persistently happens when using make_storage
with a lot of tables. See my test project https://github.com/fnc12/sqlite_orm/files/9583738/Crash.zip
what is error text?
@fnc12
It is a stack overflow, :) Is there any way to make make_storage
allocate on the heap?
you can try to allocate your storage on heap using new
operator but it will not work cause stack is used for function call recursion in your case. All I can advice you is
- try the latest
dev
branch if you use any release instead - try to split storage up to several storages. You can keep two or more storages with the same filename and they will work fine
@kelteseth It would be interesting whether you see an improvement with sqlite_orm v1.8.1.
@kelteseth BTW thank you for providing the test case and the python script. It works for me - both at compile-time and run-time - using Visual C++ 17.5.3. This is expected because sqlite_orm is now using fold expressions for tuple iteration (i.e. loop unrolling) instead of recursive iteration.
@trueqbit thank you🎉! I didn't have the time yet to test it, will report back soon hopefully 😊
Can confirm it does work now in my project at work. Thanks, hopefully we will find the time to switch our db implementation and become a customer :3