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

Environment.deinit can crash when closing the environment handle. #22

Closed
kennycarruthers opened this issue May 31, 2021 · 1 comment
Closed

Comments

@kennycarruthers
Copy link

Environment.deinit always calls mdb_env_close(handle). However, if mdb_env_open fails on line 82, then the guard condition is entered and the handle is closed then an exception is thrown.

That exception might be caught higher up in such a way that the Environment is released and deinit is called, causing the handle to get released a second time and crashing.

In my case, the database failed to open because it did not have sufficient permissions for the target directory. The exception was caught and an error might be presented to the user, but since the Environment is released the application crashes.

Looks like it might be "safe" to just omit releasing the handle in the guard and instead relying on deinit as that seems to be the case for all other exceptions thrown in the initializer.

@agisboye
Copy link
Owner

agisboye commented Jun 3, 2021

Good catch! I just encountered this issue myself for the first time.
Fixed in 2.1.2.

@agisboye agisboye closed this as completed Jun 3, 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

No branches or pull requests

2 participants