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

Add stream size checks #270

Merged
merged 2 commits into from
Mar 5, 2019
Merged

Add stream size checks #270

merged 2 commits into from
Mar 5, 2019

Conversation

DanRStevens
Copy link
Member

This addresses Issue #135.

Ideally, some test code should be added here to exercise the overflow checks.

Additional checks were added for Reader. Writer checks were already sufficient. Only commenting was adding for Writer.

Not directly addressed in the issue is if trivially false checks are zero cost at runtime. That may require examining assembly output to determine. It may be true, but hasn't been verified.

@DanRStevens DanRStevens requested a review from Brett208 February 26, 2019 16:05
Copy link
Member

@Brett208 Brett208 left a comment

Choose a reason for hiding this comment

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

Compiled in debug configuration and ran tests with no issues. Used code to unpack a file from a clm archive without issue.

Sorry for the long wait on reviewing.

@DanRStevens
Copy link
Member Author

I did some checking of assembly output with Clang, to determine if the checks are indeed zero-cost when they're not actually needed. I noticed the string for negative values check appeared in the output assembly listing using default build settings. It didn't seem to be used in the main code path though. Turning on optimizations with -O2, or guarding the if statement using a constexpr-if (and no optimization) caused the string to be omitted from the assembly output.

I'm thinking perhaps constexpr-if guards should be added around some of the checks.

To enable constexpr-if checks, we should switch compiler settings from C++14 to C++17.

Should such checks be added? Should they be added now before merging, or done as a new branch?

@Brett208
Copy link
Member

Brett208 commented Mar 5, 2019

Our current nuget package for gtest will fail if we switch to C++17 explicitly in the MSVC build. Maybe preprocessor guard it for Linux only until we figure out a different gtest solution or just push an issue for it.

Brett

@DanRStevens
Copy link
Member Author

Ok, I created issue #275 to track possible future work here. I think we can merge what we have now.

@DanRStevens DanRStevens merged commit e11ca13 into master Mar 5, 2019
@DanRStevens DanRStevens deleted the addStreamSizeChecks branch March 5, 2019 19:17
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.

2 participants