Skip to content

Make sure munlock is called for ctx->buffer - #410

Merged
sjlombardo merged 1 commit into
sqlcipher:masterfrom
indutny-signal:fix/munlock-ctx-buffer
Nov 12, 2021
Merged

sjlombardo merged 1 commit into
sqlcipher:masterfrom
indutny-signal:fix/munlock-ctx-buffer

Conversation

@indutny-signal

Copy link
Copy Markdown
Contributor

ctx->buffer is allocated with sqlcipher_malloc which calls mlock() on the whole page, but when sqlcipher_free is called with length 0 for the ctx->buffer - munlock() doesn't get called anymore (because of the check in sqlcipher_munlock).

@indutny-signal

Copy link
Copy Markdown
Contributor Author

FWIW, this might seem like a minor fix for general users, but when ran under Electron - malloc/free gets substituted by Chromium's implementation that crashes when freeing the mlocked chunk of memory!

@sjlombardo

Copy link
Copy Markdown
Member

Hi @indutny-signal - thanks for reporting this issue. I definitely agree this should be fixed up. May I ask when did you start seeing this crashing issue? I was just looking at the history and it looks like this behavior has been there for some time.

@indutny-signal

indutny-signal commented Nov 8, 2021 •

Copy link
Copy Markdown
Contributor Author

@sjlombardo we started to see the issue after upgrade to electron@15.3.0 and after we started testing our app under playwright. I don't think playwright has any relevance here after debugging it, but electron update might be significant here.

Thank you!

@sjlombardo

Copy link
Copy Markdown
Member

Hi @indutny-signal - we're planning to merge this in. Just to confirm have you already tested that this code change fixes the issue you were seeing following the electron upgrade?

@indutny-signal

Copy link
Copy Markdown
Contributor Author

Thanks so much. Yes, we patched it internally and tested heavily. No crashes due to mlock are happening anymore.

@sjlombardo
sjlombardo merged commit 4d60901 into sqlcipher:master Nov 12, 2021
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

Successfully merging this pull request may close these issues.

2 participants