Repository navigation
SDL signoff requirements - please enable additional C/C++ compiler warnings #66154
Description
Activity
- ghost addeduntriagedNew issue has not been triaged by the area ownerNew issue has not been triaged by the area owner
on Mar 3, 2022 Added checkboxes...
@GrabYourPitchforks Is this for the repo all up or only for coreclr and native code in libraries?
AaronRobinsonMSFT commented
on Mar 4, 2022 on Mar 4, 2022 · Hidden as outdatedshow commentMore actionsGrabYourPitchforks commented
on Mar 4, 2022 MemberAuthorMore actions@GrabYourPitchforks Levi Broderick FTE Is this for the repo all up or only for coreclr and native code in libraries?
Only for production code, so I'd think coreclr / mono (if compiled via MSVC++) / libs. Test code is excluded.
Edit: From the same issue in the winforms repo, the rule of thumb I've been using to define "production" code is:
- Is it part of the download made available via https://dotnet.microsoft.com/en-us/download/dotnet/6.0?
- Does it contribute to the process of building the binaries available for download there? (This covers build infrastructure code, for instance.)
If it meets at least one of these bullets, we should consider it "production" code. If it's code that instead only ever executes as part of a test suite, it's non-production.
- addedhelp wanted[up-for-grabs] Good issue for external contributors[up-for-grabs] Good issue for external contributors
on Mar 6, 2022 @AaronRobinsonMSFT in case anyone would like to help with this one, could you give a pointer to the necessary cmake changes?
I am not familiar with cmake and I only found this, but it's for mono.
runtime/src/mono/CMakeLists.txt
Line 266 in 7db092a
add_compile_options(/W3) # set warning level 3 in case anyone would like to help with this one, could you give a pointer to the necessary cmake changes?
@danmoseley Sure. The way this issue is framed, it is confusing. I believe the entire repo already has
/W3set by default. The set up for this isruntime/eng/native/configurecompiler.cmake
Lines 551 to 555 in b463b16
# /W3 is added by default by CMake, so remove it string(REPLACE "/W3" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") string(REPLACE "/W3" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") # set default warning level to 3 but allow targets to override it. add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/W$<GENEX_EVAL:$<IF:$<BOOL:$<TARGET_PROPERTY:MSVC_WARNING_LEVEL>>,$<TARGET_PROPERTY:MSVC_WARNING_LEVEL>,3>>>) Note the removal of the default flag and then the conditional for CMake is added. If
TARGET_PROPERTY:MSVC_WARNING_LEVELisn't set,/W3is added back - at least that is how I understand that line. I've confirmed this by looking a the generated ninja files for coreclr. The coreclr JIT sets/W4as using the above properly and mono is explicit (see your link above). I believe this means the repo is properly targeted for/W3. Which means we need to see where any of the above warnings are disabled.In #66154 (comment), I went through coreclr and found all the places we disabled one of the target warnings. In #66234, I am removing many of them for both mono and coreclr. However, even with the above PR some still remain. I've not checked the
native/orlibraries/directories at all.4146 - Still exists in both mono and coreclr.
4244 - Still exists in both mono and coreclr.
4267 - Still exists in mono.Once #66234 is in, all others in the list have been handled in mono and coreclr.
Reacted by Dan Moseley and AraHaanFor mono, we need to pay attention to:
- AOT cross compilers running on Windows targeting Android and WebAssembly, including our LLVM fork /cc @steveisok
- Windows desktop builds of Mono, if we productize is @lateralusX
- the mono mscordbi, if we productize it @lewing @thaystg
one complication - mono doesn't use eng/native/configurecompiler.cmake and sets its own compiler flags. So we need to verify all these warnings are on.
one complication - mono doesn't use eng/native/configurecompiler.cmake and sets its own compiler flags. So we need to verify all these warnings are on.
Note that we have slowly adapted eng/native infra in mono; so it is semi-true these days. :)
4267 - Still exists in mono.
Looking at @AaronRobinsonMSFT's fixes for coreclr, it should be easy to fix. I can take a stab at it (if nobody else is working on it).
Reacted by Aleksey Kliger (λgeek)25 remaining items
@lateralusX Have you had a chance to discuss with the rest of the mono team on this one? No pressure, just want to avoid a mad rush on this kind of issue prior to RC.
I stand corrected. It looks like 4244 is still present under
src/coreclrandsrc/native/external.@lateralusX Have you had a chance to discuss with the rest of the mono team on this one? No pressure, just want to avoid a mad rush on this kind of issue prior to RC.
Finishing of another work item and then I will do a triage on the remaining ones and add them to this issue (probably fix a set of them during the triage), we could then distribute it withing the teams if needed. Hopefully I will have something done beginning of next week.
Using this comment to track progress against fixing 4018 and 4244 on Mono.
- 2022-05-12: Updated initial progress fixing 4244. Updated below table to include reference to WIP PR.
- 2022-05-19: Reached 0 outstanding 4244 warnings when building Mono runtime build on Windows x86/x64. NOTE, cross compiler builds (targeting ARM, WASM) is currently not included, and needs to be addressed once majority of fixes goes in. Until that is done, we can't enable 4244 as errors, since it will most likely fail cross compiler builds.
- 2022-05-31: Majority of 4244 in [Mono] Fix 4244 warnings. #69236 merged.
- 2022-06-15: First PR of fixing 4018 was merged. ([Mono] Fix C4018 round I #70417)
- 2022-06-21: Second PR of fixing 4018 was merged. ([Mono] Fix C4018 warnings round II #70783) The remaining will be fixed by the third and final PR soon.
- 2022-07-07: Final PR of fixing 4018 was merged. Warning checks were enabled for build. ([Mono] Fix all remaining C4018 warnings and enable the check during build #71269)
Enabling 4018 on Mono Windows build generate
14020 warnings:File Count Comment C:\git\runtime\src\mono\mono\mini\aot-compiler.c 140#71269 C:\git\runtime\src\mono\mono\mini\method-to-ir.c 116#71269 C:\git\runtime\src\mono\mono\mini\ssa.c 72#71269 C:\git\runtime\src\mono\mono\mini\mini-llvm.c 66#71269 C:\git\runtime\src\mono\mono\mini\liveness.c 56#71269 C:\git\runtime\src\mono\mono\metadata\metadata.c 54#70417 C:\git\runtime\src\mono\mono\mini\interp\transform.c 52#71269 C:\git\runtime\src\mono\mono\mini\interp\interp.c 50#71269 C:\git\runtime\src\mono\mono\mini\mini.c 48#71269 C:\git\runtime\src\mono\mono\mini\mini-generic-sharing.c 38#71269 C:\git\runtime\src\mono\mono\mini\mini-amd64.c 34#70417 C:\git\runtime\src\mono\mono\mini\decompose.c 30#71269 C:\git\runtime\src\mono\mono\component\debugger-agent.c 27#71269 C:\git\runtime\src\mono\mono\mini\dwarfwriter.c 26#71269 C:\git\runtime\src\mono\mono\utils\monobitset.c 26#71269 C:\git\runtime\src\mono\mono\mini\debug-mini.c 24#71269 C:\git\runtime\src\mono\mono\mini\dominators.c 22#71269 C:\git\runtime\src\mono\mono\metadata\class-setup-vtable.c 22#71269 C:\git\runtime\src\mono\mono\mini\mini-exceptions.c 20#71269 C:\git\runtime\src\mono\mono\mini\aot-runtime.c 20#71269 C:\git\runtime\src\mono\mono\mini\mini-x86.c 20#71269 C:\git\runtime\src\mono\mono\metadata\icall.c 18#71269 C:\git\runtime\src\mono\mono\metadata\class.c 18#71269 C:\git\runtime\src\mono\mono\metadata\sre.c 16#71269 C:\git\runtime\src\mono\mono\mini\local-propagation.c 16#71269 C:\git\runtime\src\mono\mono\component\debugger-engine.c 14#71269 C:\git\runtime\src\mono\mono\metadata\class-init.c 14#70417 C:\git\runtime\src\mono\mono\mini\mini-arm64.c 14#71269 C:\git\runtime\src\mono\mono\mini\mini-arm.c 14#71269 C:\git\runtime\src\mono\mono\sgen\sgen-marksweep.c 14#71269 C:\git\runtime\src\mono\mono\metadata\reflection.c 12#70783 C:\git\runtime\src\mono\mono\metadata\mono-hash.c 12#70783 C:\git\runtime\src\mono\mono\metadata\object.c 12#70783 C:\git\runtime\src\mono\mono\metadata\marshal.c 10#70783 C:\git\runtime\src\mono\mono\metadata\mono-basic-block.c 10#70783 C:\git\runtime\src\mono\mono\metadata\threads.c 10#70783 C:\git\runtime\src\mono\mono\eventpipe\ep-rt-mono.c 10#70417 C:\git\runtime\src\mono\mono\metadata\loader.c 8#70783 C:\git\runtime\src\mono\mono\component\hot_reload.c 8#70783 C:\git\runtime\src\mono\mono\metadata\memory-manager.c 8#70783 C:\git\runtime\src\mono\mono\mini\abcremoval.c 8#70783 C:\git\runtime\src\mono\mono\metadata\image.c 8#70783 C:\git\runtime\src\mono\mono\metadata\custom-attrs.c 8#70783 C:\git\runtime\src\mono\mono\sgen\sgen-internal.c 8#71269 C:\git\runtime\src\mono\mono\mini\mini-profiler.c 6#70783 C:\git\runtime\src\mono\mono\mini\seq-points.c 6#70783 C:\git\runtime\src\mono\mono\mini\mini-runtime.c 6#70783 C:\git\runtime\src\mono\mono\mini\driver.c 6#70783 C:\git\runtime\src\mono\mono\metadata\debug-helpers.c 6#70783 C:\git\runtime\src\mono\mono\utils\mono-flight-recorder.c 6#70783 C:\git\runtime\src\mono\mono\metadata\sgen-new-bridge.c 6#71269 C:\git\runtime\src\mono\mono\metadata\sgen-mono.c 6#71269 C:\git\runtime\src\mono\mono\mini\mini-codegen.c 4#70783 C:\git\runtime\src\mono\mono\mini\exceptions-amd64.c 4#70783 C:\git\runtime\src\mono\mono\mini\linear-scan.c 4#70783 C:\git\runtime\src\mono\mono\profiler\aot.c 4#70783 C:\git\runtime\src\mono\mono\mini\simd-intrinsics.c 4#70417 C:\git\runtime\src\mono\mono\mini\memory-access.c 4#70783 C:\git\runtime\src\mono\mono\metadata\debug-mono-ppdb.c 4#70783 C:\git\runtime\src\mono\mono\metadata\dynamic-stream.c 4#70783 C:\git\runtime\src\mono\mono\utils\mono-poll.c 4#70783 C:\git\runtime\src\mono\mono\metadata\marshal-shared.c 4#71269 C:\git\runtime\src\mono\mono\metadata\marshal-lightweight.c 4#71269 C:\git\runtime\src\mono\mono\metadata\mono-debug.c 4#71269 C:\git\runtime\src\mono\mono\sgen\sgen-pinning.c 4#71269 C:\git\runtime\src\mono\mono\sgen\sgen-debug.c 4#71269 C:\git\runtime\src\mono\mono\utils\hazard-pointer.c 4#71269 C:\git\runtime\src\mono\mono\metadata\exception.c 2#70783 C:\git\runtime\src\mono\mono\mini\unwind.c 2#70783 C:\git\runtime\src\mono\mono\mini\helpers.c 2#70783 C:\git\runtime\src\mono\mono\mini\alias-analysis.c 2#70783 C:\git\runtime\src\mono\mono\utils\lock-free-alloc.c 2#70783 C:\git\runtime\src\mono\mono\metadata\dynamic-image.c 2#70783 C:\git\runtime\src\mono\mono\mini\graph.c 2#70783 C:\git\runtime\src\mono\mono\metadata\assembly.c 2#70783 C:\git\runtime\src\mono\mono\mini\type-checking.c 2#70783 C:\git\runtime\src\mono\mono\mini\lldb.c 2#70783 C:\git\runtime\src\mono\mono\metadata\assembly-load-context.c 2#70783 C:\git\runtime\src\mono\mono\metadata\sre-encode.c 2#70783 C:\git\runtime\src\mono\mono\mini\mini-amd64-gsharedvt.c 2#70783 C:\git\runtime\src\mono\mono\mini\monovm.c 2#70783 C:\git\runtime\src\mono\mono\mini\calls.c 2#70783 C:\git\runtime\src\mono\mono\mini\branch-opts.c 2#70783 C:\git\runtime\src\mono\mono\metadata\marshal-ilgen.c 2#71269 C:\git\runtime\src\mono\mono\metadata\sgen-stw.c 2#71269 C:\git\runtime\src\mono\mono\metadata\seq-points-data.c 2#71269 C:\git\runtime\src\mono\mono\utils\os-event-win32.c 2#71269 C:\git\runtime\src\mono\mono\utils\mono-log-flight-recorder.c 2#71269 C:\git\runtime\src\mono\mono\mini\mini-x86-gsharedvt.c 2#71269 C:\git\runtime\src\mono\mono\mini\ir-emit.h 2#71269 C:\git\runtime\src\mono\mono\mini\mini-arm64-gsharedvt.c 2#71269 C:\git\runtime\src\mono\mono\mini\mini-arm-gsharedvt.c 2#71269 C:\git\runtime\src\mono\mono\sgen\sgen-cardtable.c 2#71269 C:\git\runtime\src\mono\mono\sgen\sgen-los.c 2#71269 C:\git\runtime\src\mono\mono\sgen\sgen-thread-pool.c 2#71269 C:\git\runtime\src\mono\mono\eglib\gfile.c 1#70417 C:\git\runtime\src\mono\mono\eventpipe\ep-rt-mono.h 1#70417 C:\git\runtime\src\mono\mono\eglib\gptrarray.c 1#70417 C:\git\runtime\src\mono\mono\component\debugger-state-machine.c 1#70417 C:\git\runtime\src\mono\mono\eglib\garray.c 1#70417 Grand Total 1402 Enabling 4244 on Mono runtime Windows x86/x64 build generate
26151156~5003860 warnings:File Count Comment C:\git\runtime\src\mono\mono\mini\interp\transform.c 644#69236 C:\git\runtime\src\mono\mono\mini\mini-amd64.c 386#69236 C:\git\runtime\src\mono\mono\mini\method-to-ir.c 204#69236 C:\git\runtime\src\mono\mono\mini\mini.h 123#69236 C:\git\runtime\src\mono\mono\mini\tramp-amd64.c 118#69236 C:\git\runtime\src\mono\mono\mini\aot-compiler.c 102#69236 C:\git\runtime\src\mono\mono\mini\intrinsics.c 68#69236 C:\git\runtime\src\mono\mono\metadata\sre.c 60#69236 C:\git\runtime\src\mono\mono\metadata\metadata.c 58#69236 C:\git\runtime\src\mono\mono\metadata\icall.c 58#69236 C:\git\runtime\src\mono\mono\mini\aot-runtime.c 42#69236 C:\git\runtime\src\mono\mono\mini\mini.c 38#69236 C:\git\runtime\src\mono\mono\mini\dwarfwriter.c 38#69236 C:\git\runtime\src\mono\mono\mini\interp\interp.c 32#69236 C:\git\runtime\src\mono\mono\component\debugger-agent.c 31#69236 C:\git\runtime\src\mono\mono\mini\exceptions-amd64.c 28#69236 C:\git\runtime\src\mono\mono\metadata\class.c 26#69236 C:\git\runtime\src\mono\mono\mini\tramp-amd64-gsharedvt.c 26#69236 C:\git\runtime\src\mono\mono\metadata\image.c 26#69236 C:\git\runtime\src\mono\mono\mini\ir-emit.h 26#69236 C:\git\runtime\src\mono\mono\mini\ssa.c 24#69236 C:\git\runtime\src\mono\mono\metadata\assembly.c 22#69236 C:\git\runtime\src\mono\mono\metadata\class-init.c 22#69236 C:\git\runtime\src\mono\mono\metadata\sre-encode.c 20#69236 C:\git\runtime\src\mono\mono\mini\unwind.c 20#69236 C:\git\runtime\src\mono\mono\mini\debug-mini.c 18#69236 C:\git\runtime\src\mono\mono\mini\mini-exceptions.c 18#69236 C:\git\runtime\src\mono\mono\mini\local-propagation.c 18#69236 C:\git\runtime\src\mono\mono\mini\mini-runtime.c 18#69236 C:\git\runtime\src\mono\mono\mini\decompose.c 18#69236 C:\git\runtime\src\mono\mono\metadata\reflection.c 16#69236 C:\git\runtime\src\mono\mono\mini\mini-generic-sharing.c 16#69236 C:\git\runtime\src\mono\mono\mini\liveness.c 16#69236 C:\git\runtime\src\mono\mono\mini\memory-access.c 14#69236 C:\git\runtime\src\mono\mono\metadata\marshal.c 14#69236 C:\git\runtime\src\mono\mono\mini\branch-opts.c 12#69236 C:\git\runtime\src\mono\mono\eglib\giconv.c 12#69236 C:\git\runtime\src\mono\mono\metadata\mono-basic-block.c 12#69236 C:\git\runtime\src\mono\mono\mini\abcremoval.c 10#69236 C:\git\runtime\src\mono\mono\eventpipe\ep-rt-mono.c 9#69236 C:\git\runtime\src\mono\mono\mini\mini-codegen.c 8#69236 C:\git\runtime\src\mono\mono\metadata\custom-attrs.c 8#69236 C:\git\runtime\src\mono\mono\utils\networking.c 8#69236 C:\git\runtime\src\mono\mono\mini\lldb.c 8#69236 C:\git\runtime\src\mono\mono\mini\mini-profiler.c 8#69236 C:\git\runtime\src\mono\mono\metadata\debug-helpers.c 6#69236 C:\git\runtime\src\mono\mono\mini\alias-analysis.c 6#69236 C:\git\runtime\src\mono\mono\mini\calls.c 6#69236 C:\git\runtime\src\mono\mono\metadata\loader.c 6#69236 C:\git\runtime\src\mono\mono\metadata\memory-manager.c 6#69236 C:\git\runtime\src\mono\mono\utils\mono-codeman.c 4#69236 C:\git\runtime\src\mono\mono\metadata\class-setup-vtable.c 4#69236 C:\git\runtime\src\mono\mono\metadata\profiler.c 4#69236 C:\git\runtime\src\mono\mono\utils\mono-dl.c 4#69236 C:\git\runtime\src\mono\mono\mini\type-checking.c 4#69236 C:\git\runtime\src\mono\mono\utils\mono-threads.c 4#69236 C:\git\runtime\src\mono\mono\mini\seq-points.c 4#69236 C:\git\runtime\src\mono\mono\utils\mono-error.c 4#69236 C:\git\runtime\src\mono\mono\metadata\mempool.c 4#69236 C:\git\runtime\src\mono\mono\mini\mini-trampolines.c 4#69236 C:\git\runtime\src\mono\mono\mini\simd-intrinsics.c 4#69236 C:\git\runtime\src\mono\mono\component\debugger-engine.c 3#69236 C:\git\runtime\src\mono\mono\metadata\threads.c 2#69236 C:\git\runtime\src\mono\mono\metadata\jit-info.c 2#69236 C:\git\runtime\src\mono\mono\metadata\handle.c 2#69236 C:\git\runtime\src\mono\mono\metadata\native-library.c 2#69236 C:\git\runtime\src\mono\mono\utils\mono-threads-coop.c 2#69236 C:\git\runtime\src\mono\mono\mini\driver.c 2#69236 C:\git\runtime\src\mono\mono\metadata\mono-debug.c 2#69236 C:\git\runtime\src\mono\mono\metadata\debug-mono-ppdb.c 2#69236 C:\git\runtime\src\mono\mono\mini\cfold.c 2#69236 C:\git\runtime\src\mono\mono\utils\mono-math-c.c 2#69236 C:\git\runtime\src\mono\mono\utils\mono-path.c 2#69236 C:\git\runtime\src\mono\mono\metadata\mono-hash.c 2#69236 C:\git\runtime\src\mono\mono\profiler\aot.c 2#69236 C:\git\runtime\src\mono\mono\utils\mono-time.c 2#69236 C:\git\runtime\src\mono\mono\profiler\helper.c 2#69236 C:\git\runtime\src\mono\mono\utils\lock-free-alloc.c 2#69236 C:\git\runtime\src\mono\mono\component\event_pipe.c 1#69236 C:\git\runtime\src\mono\mono\eglib\gstr.c 1#69236 C:\git\runtime\src\mono\mono\eglib\gutf8.c 1#69236 Grand Total 2615 //CC @lambdageek @vargaz
Reacted by Aaron R Robinson- added 2 commits that reference this issue
on May 31, 2022 @AaronRobinsonMSFT is CoreCLR work here now all done?
@lateralusX @fanyang-mono is Mono work still in progress, but on track for RC1 snap?@danmoseley The final piece of work should be merged no later than tmr. (#71269)
@danmoseley The final piece of work should be merged no later than tmr. (#71269)
Merged.@danmoseley The final piece of work should be merged no later than tmr. (#71269)
Merged.W00t! Thank you @fanyang-mono @lambdageek @lateralusX @elinor-fung @am11 and anyone else who helped make this happen.
@GrabYourPitchforks Do we have an audit plan from SDL. Just to make sure we didn't miss anything.
@GrabYourPitchforks ? what remains to close this..
GrabYourPitchforks commented
on Jul 19, 2022 MemberAuthorMore actionsI think we're good here! Will reopen it if new things crop up. Thanks again for the efforts. :)
Reacted by Aaron R Robinson- removedhelp wanted[up-for-grabs] Good issue for external contributors[up-for-grabs] Good issue for external contributors
on Jul 19, 2022 - ghost locked as resolved and limited conversation to collaborators
on Aug 19, 2022
Recent SDL changes require that we enable additional compiler warnings across our C/C++ projects. The requirements are:
Enable the following additional warnings, which must be fixed if they occur:
See the SDL guidelines (MSFT internal only) for further information.
To make auditing code easier prior to signoff and release, please include the string Microsoft.Security.SystemsADM.10086 somewhere in the vcxproj / cmake / whatever file which is responsible for C/C++ compilation where all of these flags are defined. That gives the code auditors a target string to search against and validate that the proper warnings are enabled. See below an example of how to do this in a cmake file.
Once the work is finished, or if there is no work to perform, please feel free to close this issue.
Thanks for your assistance!
Quick FAQ
What code is bound to this requirement?
This affects only production code. Production code is generally defined as code which ships as part of the product and which runs on customer machines or which manages infrastructure, such as our build labs. Unit and functional test projects are not considered production code.
Does this need to be backported?
No backporting plans at this time. If actual bugs are found during this process, individual product teams have discretion to selectively backport into the next downlevel servicing vehicle.
What about forked third-party code?
This requirement applies to all code that MSFT builds from source, regardless of its provenance. Ideally any changes that we make to local forked copies can be submitted upstream as a PR so that the wider ecosystem can enjoy their benefits.
If this is impractical, exceptions to this requirement can be sought on an as-needed basis. However, exceptions are: (a) not guaranteed to be granted; and (b) time-constrained. The exception process is not intended to provide a permanent deferral of this work. Please contact the fxsecurity alias if an exception is needed.
What about C# and other languages?
This requirement only affects C/C++ code. Requirements for other languages will be filed as separate issues.