Skip to content
This repository has been archived by the owner on Mar 9, 2019. It is now read-only.

prevent segfault after mmap failure #707

Closed
wants to merge 3 commits into from

Conversation

lukechampine
Copy link
Contributor

@lukechampine lukechampine commented Jul 18, 2017

Fixes #706.

This PR causes the db to revert to mmap(db, db.datasz) if the call to mmap(db, minsz) fails. The original error is still returned, so callers will see "mmap failure" returned from db.Update. I also wrapped this error in a new type, so that callers can check for it explicitly. This is good to have, since I imagine applications will want to panic instead of continuing to attempt more db.Update calls. Another option would be to add a PanicOnFailedMmap flag so that bolt will automatically panic under these conditions.

I'm not 100% sure that this code is safe, but I've confirmed that it resolves the segfault bug, and it appears that calls to db.View will succeed even after mmap failure.

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

Successfully merging this pull request may close these issues.

Segfault on Windows when out of disk space
2 participants