-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Turn on CheckForOverflowUnderflow on all projects in Debug #15152
Comments
Sounds like a good idea. |
@weshaggard Do you still think this is something we should enable? If we enable this across the board and don't see any errors, is it something we should just go ahead and do? |
I'm 100% sure there will be errors / regressions if/when we enable this everywhere. ;) That's not to say we shouldn't do it, but I don't think it's as simple as changing a build configuration entry. |
I do think this is probably worth doing, but I agree that it is likely not as simple as flipping a build configuration on. |
Yes I spoke too soon 😄 . We'd definitely need a lot of work to enable it globally. Perhaps it's smarter to start with a few high-value projects and see how much work it is. |
Next steps: Flip individual projects and mark code which overflows on purpose as unchecked. |
And measure critical paths to ensure nothing regresses perf-wise (unless we're only flipping the switch for debug, in which case it doesn't matter). |
I opened this suggesting debug-only. I'd still recommend starting with that. |
I could take this one. Is it sufficient to run the outerloop tests after turning checks on for a project or is there anything else I should try? |
@dennisdietrich I think that would be a good start. Like @nguerrera said, it's probably a good idea to enable this for Debug builds only, at first. In order to do that, you can condition the property on |
@mellinoe, definitely. Performance aside, turning this on for Release obviously could introduce breaking changes in the form of unexpected exceptions being thrown. Very well, please assign to me. |
@mellinoe After thinking about this some more I don't think going for the individual project files is the right approach. We do want this for all projects so it makes more sense to have this in a props file used by all projects. I've noticed that there's already a whole bunch of them so I'll first check if any of those would be suitable (pointers welcome ;)). |
If you do it across all projects, it's very likely that there'd be a very large number of regressions, so you'd have to change all of those regressions, so it would likely be a massive one-shot PR. If you do it project by project it's more likely to lead to small easier-to-review PRs, and then the setting could be moved up to being global after that. |
For the sake of reviewers: Please do NOT do large PRs, break them up :) |
Imagine you doing the code review: For how long do you want to scroll down and review code? Here's recent example of rather larger-ish PR: dotnet/corefx#15597. I would personally break it down into smaller chunks - it is easier to review each chunk in 1 session, rather than to remember where you last left off. If the chunk is large ... you are forced to push through the review all at once. |
Suspending further work on this until @stephentoub 's concerns raised in RP dotnet/corefx#15690 are addressed. |
Another reason piecewise change can be nice is (if we merge without squashing) we can selectively revert or bisect if there's an issue that emerges. |
FWIW, turning on overflow checks in debug builds by default was considered several times in full .NET Framework. It was never done because of it did not have positive ROI. It never found enough bugs to pay for its cost. There is a price you pay for diverging behavior of debug and release build, maintaining annotations in large body of the code, and dealing with bugs introduced by maintaining the annotations. Having said that, doing experimental runs with overflow checks on and adding some annotations for the heavy hitters should be ok. |
I am pretty sure that turning this on for release builds is non-starter. |
Marking code that may intentionally lead to over or underflows with unchecked in preparation of turning on CheckForOverflowUnderflow for all projects (issue #3140)
Marking code that may intentionally lead to over or underflows with unchecked in preparation of turning on CheckForOverflowUnderflow for all projects (issue #3140)
Marking code that may intentionally lead to over or underflows with unchecked in preparation of turning on CheckForOverflowUnderflow for all projects (issue #3140) NOTE: Commit contains only tests for System.Linq.Expressions
Quick update: Including some code changes I haven't committed yet I'm down to about 50 failing inner loop test projects on Windows so it'll probably be a few more days until I'm done with that, after which I'll take a look at running inner loop on Linux (and after that, obviously, I'll check outer loop). |
thanks @dennisdietrich this is awesome! |
Just noticed some UAP PAL source files. Is that an environment I should check too? If so, how? The building and debugging instructions for Windows don't seem to mention UAP. |
We are just bringing UAP back to life, I think it is fine to skip it for now cc: @joperezr @weshaggard. |
Marking code that may intentionally lead to over or underflows with unchecked in preparation of turning on CheckForOverflowUnderflow for all projects (issue #3140)
@karelz Okay. What about endianness? I believe that ARM is typically bi-endinan (or fixed to little) and with Xbox having moved to x64 I don't think anyone cares about PowerPC anymore. Still, did just come across some PAL code with |
How is endianness related to CheckForOverflowUnderflow? It should be transparent to most of the system, right? |
It is not, but keep in mind that I'm working my way through overflow exception; I'm not doing a manual code inspection so any code that's big-endian only will go untested with the current approach. |
I see. |
Fair enough. That said, what about the System.IO.Ports tests? Since I'm running the tests in a VM that doesn't even have a (virtual) serial port I get 425 skipped tests. Is there a virtual null modem I could install to get those to run? |
Marking code that may intentionally lead to over or underflows with unchecked in preparation of turning on CheckForOverflowUnderflow for all projects (issue #3140)
* Marking code as unchecked (pt 7) Marking code that may intentionally lead to over or underflows with unchecked in preparation of turning on CheckForOverflowUnderflow for all projects (issue #3140) * Marking code as unchecked (pt 7a) Additional fixes from a debugging session on macOS * Marking code as unchecked (pt 7b) Added missing unchecked to ConcurrentBag
Update: I have an almost clean inner loop run on Windows 10 at this point. Outer loop runs and inner loop on macOS and Ubuntu are not clean but as far as I can tell the failures are all due to environmental issues (e.g. DNS tests, HTTP tests, certificate tests). Regarding the last inner loop issue on Windows 10 I've already enlisted @tarekgh's support (thanks Tarek! :)) as I'm not sure what's going on. |
Marking code that may intentionally lead to over or underflows with unchecked in preparation of turning on CheckForOverflowUnderflow for all projects (issue #3140)
People on this issue, we are getting close to enable CheckForOverflowUnderflow for the whole corefx for the debug build. this may happen in the next couple of days. please let's know if you have any concern before doing that. Thanks. |
@tarekgh @karelz I have not created a PR yet but I have prepared a new branch and this one includes the change to dir.props: https://github.com/dennisdietrich/corefx/commits/Unchecked-Part9 Local inner loop results:
However, I can't get a clean outer loop run on any of my VMs but going through the test failures they still look like environmental issues. That said, at this point I would like to get test run results from the CI machines. |
@dennisdietrich you may start submitting the PR and enable all CI checks on this PR and let's look what is failing there and we can progress from there. |
@dennisdietrich I would to thank you for all your work done here. that is really awesome. |
Don't mention it. Happy to contribute. :) |
Agreed, great job @dennisdietrich.
|
@karelz Sure am. Looks like dotnet/corefx#14344 will be next. |
Right now, only System.Reflection.Metadata has CheckForOverflowUnderflow on in Debug.
I think there's value in doing this across the board. Expressions that are allowed to overflow by design should be explicitly marked
unchecked
.cc @weshaggard @stephentoub
The text was updated successfully, but these errors were encountered: