Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh-185 Add protection for closed env#186

Closed
at055612 wants to merge 4 commits into
lmdbjava:masterlmdbjava/lmdbjava:masterfrom
at055612:gh-185-env-closed-crashat055612/lmdbjava:gh-185-env-closed-crashCopy head branch name to clipboard
Closed

gh-185 Add protection for closed env#186
at055612 wants to merge 4 commits into
lmdbjava:masterlmdbjava/lmdbjava:masterfrom
at055612:gh-185-env-closed-crashat055612/lmdbjava:gh-185-env-closed-crashCopy head branch name to clipboard

Conversation

@at055612

@at055612 at055612 commented Nov 4, 2021

Copy link
Copy Markdown
Collaborator

Fixes #185

  • Change Cursor and Txn to hold the Env instance so it can be checked for its open/closed state.
  • Add calls to env.checkNotClosed() in methods that call out to the LMDB lib to prevent the JVM crashing if the env has been closed.
  • Add lots of tests involving env closure.

Happy to re-work this if you disagree with the approach or see problems with it.

Change Cursor and Txn to hold the Env instance so it can be checked
for its open/closed state.
Add calls to env.checkNotClosed() in methods that call out to the LMDB
lib to prevent the JVM crashing if the env has been closed.
Add lots of tests involving env closure.
@at055612

at055612 commented Nov 4, 2021

Copy link
Copy Markdown
Collaborator Author

@benalexau If I run the test classes in isolation they work fine but when run via mvn test I see

# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f4ec41f6a15, pid=22462, tid=22468
#
# JRE version: OpenJDK Runtime Environment (15.0.2+7) (build 15.0.2+7-27)
# Java VM: OpenJDK 64-Bit Server VM (15.0.2+7-27, mixed mode, sharing, tiered, compressed oops, g1 gc, linux-amd64)
# Problematic frame:
# C  [libpthread.so.0+0x9a15]  __pthread_mutex_lock_full+0x335

My suspicion (with zero c knowledge) is that the various tests that are closing the env while txns/cursors/dbis are open are leaving things (i.e. mutex locks) in an untidy state that are then causing later tests to fail. Does this seem right and is there any way to get around this?

An alternative approach would be for the Env to keep a track of open txns/cursors and either prevent closure of the env if any are open or force closure of the open txns/cursors. Such an approach would add overhead though.

@bp-alex

bp-alex commented Feb 3, 2023

Copy link
Copy Markdown
Member

Thanks @at055612 for this PR and my apologies for the delay in reviewing it. I have merged your changes via commit 3db0def. I added a Maven Surefire configuration to avoid reusing the forked test processes and that overcame the error.

@bp-alex bp-alex closed this Feb 3, 2023
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.

SIGSEGV on cursorIterable.next() when the env is closed

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.