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

fix disposing issues and incorrect work in netcore2.0 #38

Merged
merged 7 commits into from
Mar 25, 2018

Conversation

marfenij
Copy link

So, I extend test projects to several target frameworks, remove unsupported stuff like RhinoMocks, SharpTestsEx; append test to check close/dispose workflow, and check behavior when buffer sizes changes (at this moment I got exceptions on real project)

Copy link
Owner

@dotarj dotarj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @marfenij, thanks for the PR! I've added some comments. Could you please describe the actual bug fix(es) that you made, so I can mention it in the release notes?

Some advice for future pull requests; it is better to have multiple small pull requests than to have a single large pull request with multiple (unrelated) changes. This makes it more easy to review, modify and, if necessary, easier to roll back. The removal of RhinoMocks and SharpTestsEx is good work, and would be perfect for a separate (small) pull request. For now it's fine though. :)

@@ -341,8 +341,7 @@ public bool IsDBNull(int i)

public void Close()
{
stream.Close();
IsClosed = true;
this.Dispose();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the Close() method should dispose the reader. I've checked the behavior of SqlDataReader and OdbcDataReader and the reader is not disposed when it is closed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right - correct way call Close() in Dispose method

@@ -88,7 +88,7 @@ public void ShouldThrowExceptionWhenBufferOffsetIsLessThanZero()
dataReader.Read();

// Assert
Assert.Throws<ArgumentOutOfRangeException>("bufferOffset", () => dataReader.GetBytes(0, 0, new byte[1], -1, 1));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking the parameter name ensures that the expected exception at the expected location has been thrown.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand, but old xunit, which used for net40 not support that argument

@@ -100,7 +100,7 @@ public void ShouldThrowExceptionWhenBufferOffsetIsGreaterThanBufferSize()
dataReader.Read();

// Assert
Assert.Throws<ArgumentOutOfRangeException>("bufferOffset", () => dataReader.GetBytes(0, 0, new byte[1], 10, 1));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking the parameter name ensures that the expected exception at the expected location has been thrown.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I mentioned above, this is old xUnit issue

@@ -112,7 +112,7 @@ public void ShouldThrowExceptionWhenBufferOffsetIsEqualToBufferSize()
dataReader.Read();

// Assert
Assert.Throws<ArgumentOutOfRangeException>("bufferOffset", () => dataReader.GetBytes(0, 0, new byte[1], 1, 1));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking the parameter name ensures that the expected exception at the expected location has been thrown.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I mentioned above, this is old xUnit issue

@@ -88,7 +88,7 @@ public void ShouldThrowExceptionWhenBufferOffsetIsLessThanZero()
dataReader.Read();

// Assert
Assert.Throws<ArgumentOutOfRangeException>("bufferOffset", () => dataReader.GetChars(0, 0, new char[1], -1, 1));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking the parameter name ensures that the expected exception at the expected location has been thrown.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I mentioned above, this is old xUnit issue

.gitignore Outdated
[Rr]elease*/
Ankh.NoLoad
.nuget/nuget.exe
.vs/
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.vs/ is already mentioned on line 40.

.gitignore Outdated
@@ -98,6 +98,13 @@ ipch/
*.cachefile
*.VC.db
*.VC.VC.opendb
obj/
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

obj/ is already mentioned on line 36.

.gitignore Outdated
@@ -98,6 +98,13 @@ ipch/
*.cachefile
*.VC.db
*.VC.VC.opendb
obj/
[Bb]in
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already mentioned on line 28 - 37.

.gitignore Outdated
[Bb]in
[Dd]ebug*/
[Rr]elease*/
Ankh.NoLoad
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what this is (Ankh.NoLoad).

.gitignore Outdated
@@ -98,6 +98,13 @@ ipch/
*.cachefile
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes made to .gitignore mostly seem to be double entries, better drop the changes to .gitignore.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for that, i revert .gitignore to original state https://www.gitignore.io/api/visualstudio,visualstudiocode

@marfenij
Copy link
Author

Thank you for review. I try made small changes for PR in future )) (also I know that feature I missed include, and that feature helps me debug that bug with buffers sizes)

So, on of problem it's incorrect assuming that protobuf-net always return 1024 byte in buffer.
And another thing reproduce only in netcore20, this guys made optimization for allocation memory for buffers - now buffer size equal to some power of 2 (stream copy try use standard buffer size 80k, but in netcore20 allocate buffer in 128k)

this two thing cause runtime exception that internal (circular) buffer overflow

@marfenij
Copy link
Author

@dotarj also some trouble with MSBuild.SonarQube.Runner on AppVeyor build

@dotarj dotarj merged commit 5a7f983 into dotarj:master Mar 25, 2018
@dotarj
Copy link
Owner

dotarj commented Mar 25, 2018

Thanks for updating the PR, it's merged.

There is a (sonarqube) problem with the build with pull requests from forks (secure variables are not available for security). I'll fix this later.

@dotarj
Copy link
Owner

dotarj commented Mar 25, 2018

@marfenij A new version of protobuf-net-data containing your fix is released.

@marfenij marfenij deleted the prepare_for_pr branch March 25, 2018 07:02
@marfenij
Copy link
Author

@dotarj great!!

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.

3 participants