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

Memory leak after VACUUM #10

Closed
synopse opened this issue Jun 8, 2020 · 5 comments
Closed

Memory leak after VACUUM #10

synopse opened this issue Jun 8, 2020 · 5 comments

Comments

@synopse
Copy link

synopse commented Jun 8, 2020

From my preliminary tests, performing a VACUUM makes a memory leak of the codec instance (65xxx bytes). With no VACUUM (i.e. regular INSERT/UPDATE/SELECT), no memory leak.
I guess there is a missing sqlite3mcCodecFree() call somewhere...
Perhaps the ATTACH statement executed during VACCUM doesn't work as expected.

@utelle
Copy link
Owner

utelle commented Jun 8, 2020

Thanks for reporting the issue. I will look into it.

VACUUM creates a temporary new database file. If the main database is encrypted, a copy of the main codec will be made. Maybe this copy is not freed as it should. I will have to check what's going on.

@synopse
Copy link
Author

synopse commented Jun 8, 2020

If I comment the last sqlite3mcCodeAttach() in sqlite3mcHandleAttachKey (case SQLITE_NULL - which is the case for the ATTACH temp db made during VACUUM), I don't have any leak, and the file is still encrypted after the vacuum... weird...

@utelle
Copy link
Owner

utelle commented Jun 9, 2020

The VACUUM command attaches a temporary database without using a file name. As a consequence there is no SQLite file handle to which the codec could be attached.

The current implementation does not detect this situation correctly: a codec is allocated and initialized, but not freed.

Commenting the call to sqlite3mcCodeAttach as you did solves the problem only for this special case, but not for the general case.

I will provide a fix within the next few days.

utelle added a commit that referenced this issue Jun 9, 2020
The VACUUM command attaches a temporary database without using a file name. As a consequence there is no SQLite file handle to which the codec of an encrypted main database file could be attached. This was not properly detected leading to a memory leak.
@utelle
Copy link
Owner

utelle commented Jun 9, 2020

Commit 2794168 should fix the issue.

If no SQLite file handle can be found in function sqlite3mcSetCodec the codec is freed.

@utelle
Copy link
Owner

utelle commented Jun 10, 2020

Closing... reopen if necessary.

@utelle utelle closed this as completed Jun 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants