Skip to content
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

Crash when using a lot of tables #1083

Closed
kelteseth opened this issue Sep 16, 2022 · 10 comments
Closed

Crash when using a lot of tables #1083

kelteseth opened this issue Sep 16, 2022 · 10 comments

Comments

@kelteseth
Copy link

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).
image

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.

Crash.zip

image

If you like you can use the python script for future testing and test data generation.

@kelteseth
Copy link
Author

Is there a way to work around this issue?

@fnc12
Copy link
Owner

fnc12 commented Nov 2, 2022

what kind of crash you get? compiler crash or runtime crash?

@kelteseth
Copy link
Author

kelteseth commented Nov 3, 2022

@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

@fnc12
Copy link
Owner

fnc12 commented Nov 3, 2022

what is error text?

@kelteseth
Copy link
Author

@fnc12

It is a stack overflow, :) Is there any way to make make_storage allocate on the heap?

image

@fnc12
Copy link
Owner

fnc12 commented Nov 4, 2022

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

  1. try the latest dev branch if you use any release instead
  2. try to split storage up to several storages. You can keep two or more storages with the same filename and they will work fine

@trueqbit
Copy link
Collaborator

@kelteseth It would be interesting whether you see an improvement with sqlite_orm v1.8.1.

@trueqbit
Copy link
Collaborator

@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.

@kelteseth
Copy link
Author

@trueqbit thank you🎉! I didn't have the time yet to test it, will report back soon hopefully 😊

@kelteseth
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants