-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix it so that disposing the RocksDb instance twice does not throw Ac…
…cessViolationException and crash the process
- Loading branch information
1 parent
5b4b0bc
commit 7727d24
Showing
2 changed files
with
59 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System; | ||
using System.IO; | ||
using RocksDbSharp; | ||
using Xunit; | ||
// ReSharper disable RedundantArgumentDefaultValue | ||
// ReSharper disable ArgumentsStyleLiteral | ||
|
||
namespace RocksDbSharpTest | ||
{ | ||
public class LifestyleTest | ||
{ | ||
[Fact] | ||
public void DoubleDisposableDoesNotThrow() | ||
{ | ||
var testdir = Path.Combine(Path.GetTempPath(), "lifestyle_test"); | ||
var testdb = Path.Combine(testdir, "main"); | ||
var path = Environment.ExpandEnvironmentVariables(testdb); | ||
|
||
if (Directory.Exists(testdir)) | ||
{ | ||
Directory.Delete(testdir, recursive: true); | ||
} | ||
|
||
Directory.CreateDirectory(testdir); | ||
|
||
var options = new DbOptions().SetCreateIfMissing(true).EnableStatistics(); | ||
|
||
var db = RocksDb.Open(options, path); | ||
|
||
db.Dispose(); | ||
|
||
// throws AccessViolationException, which on my machine crashed the process so hard that XUnit coulnd't cope... | ||
// | ||
db.Dispose(); | ||
// | ||
// got this in Event Viewer though: | ||
// | ||
// Application: dotnet.exe | ||
// CoreCLR Version: 4.6.28619.1 | ||
// Description: The process was terminated due to an internal error in the .NET Runtime at IP 00007FFF39BC5AA3 (00007FFF39A20000) with exit code c0000005. | ||
// | ||
} | ||
} | ||
} |