Fix Main - ignore warning 6101#2471
Conversation
|
/azp run cpp - core |
|
Azure Pipelines successfully started running 1 pipeline(s). |
RickWinter
left a comment
There was a problem hiding this comment.
This warning is a great one to keep as it checks for unitialized memory. Why do we need to disable it?
| # - C6285: (<non-zero constant> || <non-zero constant>) -> VBProject static analysis on Functional header: | ||
| # _Is_large, regression from VS version 19.28.29915.0 to 19.29.30037.0 | ||
| target_compile_options(azure-core PUBLIC /wd6285) | ||
| target_compile_options(azure-core PUBLIC /wd6285 /wd6101) |
There was a problem hiding this comment.
Can you add a comment in the source that describes what /wd6101 does?
# warning C6101: Returning uninitialized memory
# https://docs.microsoft.com/en-us/cpp/code-quality/c6101?view=msvc-160
ahsonkhan
left a comment
There was a problem hiding this comment.
I had the same question, where is this warning coming from?
|
Windows Kits\10\include\10.0.19041.0\um\ws2tcpip.h(968): warning C6101: Returning uninitialized memory '*Mtu'. A successful path through the function does not set the named Out parameter. : Lines: 968, 973, 974, 975, 976, 978, 979, 994, 968 |
What code in our SDK source is triggering this? Were you able to find/drill into the specific source file that we own? |
|
/azp run cpp - core |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run cpp - core |
|
Azure Pipelines successfully started running 1 pipeline(s). |
| uint8_t buffer[chunk]; | ||
| uint8_t buffer2[chunk]; |
There was a problem hiding this comment.
Out of curiosity, what was the bug here?
There was a problem hiding this comment.
MSVC complains or throw a warning saying that the method is allocating memory in the stack beyond the limit. That's due to creating two arrays of 1M each, resulting in 2MB stack allocation.
Updating the arrays to a vector would use heap for the 2MB
| if (MSVC) | ||
| # Disable warnings | ||
| # - C6326: Google comparisons | ||
| target_compile_options(azure-perf-unit-test PUBLIC /wd6326) |
There was a problem hiding this comment.
Can you point to an example of our source that triggered this warning?
There was a problem hiding this comment.
We have this warning disabling in azure-core-tests as well and other test packages,
MSCV warns you when we do something like ASSERT_EQ(a, b) where a is a size_t const and b is size_t as well. MSVC will say that you are just comparing two constants as 4 == 2 or something like that. Because ASSER_EQ macro grom gtest ends up checking something like if(VALUE == OTHER_VALUE) => if(4 == 2).
| # _Is_large, regression from VS version 19.28.29915.0 to 19.29.30037.0 | ||
| target_compile_options(azure-core PUBLIC /wd6285) | ||
| # - C6101: Returning uninitialized memory '*Mtu' -> libcurl calling WSAGetIPUserMtu from WS2tcpip.h | ||
| target_compile_options(azure-core PUBLIC /wd6101) |
There was a problem hiding this comment.
Is there a cpp file for which, when being compiled, this warning gets emitted? If so, it is better to disable the warning via "... ifdef _MSC_VER, pragma warning disable".
If there's a header which includes the 3rd party header file that generates the warning, it also is better to disable as "... ifdef _MSC_VER, pragma warnings push, pragma warning disable, include <3rd party>, ifdef MSC pragma pop"
There was a problem hiding this comment.
@vhvb1989 Is this warning only coming from libcurl cpp file? Can you share where it is coming from (which line of code)?
ahsonkhan
left a comment
There was a problem hiding this comment.
Since this is to unblock main, it's fine to check this in as a stop gap for now.
It would be nicer to scope the warning to only where we know it is a false positive, rather than across the board, since it seems like a useful warning to keep.
|
/azp run cpp - core |
|
Azure Pipelines successfully started running 1 pipeline(s). |
| - template: /eng/pipelines/templates/steps/cmake-build.yml | ||
| parameters: | ||
| GenerateArgs: $(CmakeArgs) | ||
| BuildArgs: "$(BuildArgs)" |
There was a problem hiding this comment.
@danieljurek - I am not the expert here, can you review/speak to this?
There was a problem hiding this comment.
This was not causing Main to be broken, but it was missing to add the build args from the test matrix ( -v and --parallel )
There was a problem hiding this comment.
This looks good to me. In the case of the Ubuntu and Windows 2019 machines, the VMs have 2 cores. For I/O bound operations, like building, the process can complete faster with a degree of parallelism that is greater than the number of cores.
In the case of cmake-build.yml this parameter is inserted into the build command line: https://github.com/Azure/azure-sdk-for-cpp/blob/main/eng/pipelines/templates/steps/cmake-build.yml#L20
BuildArgs is a variable and its value is set in the matrix above (if the value is not set somewhere then it is an empty string).
The template syntax:
cmake --build . ${{ parameters.BuildArgs }}
After template substitution becomes:
cmake --build . $(BuildArgs)
In the case of MacOS_x64_with_unit_test in the matrix:
cmake --build . -j 4
According to cmake documentation for the -j parameter:
The CMAKE_BUILD_PARALLEL_LEVEL environment variable, if set, specifies a default parallel level when this option is not given.
Another way to get this outcome is to use the CMAKE_BUILD_PARALLEL_LEVEL.
Either approach will get the same effects. It might be easier to use the command line approach taken in this PR as, if the command line is logged, one can copy and paste the logged command line locally. Otherwise one would have to dig through and reassemble the state of the environment variables at build time starting at the matrix and working up to the job level (in the event that there are some global variables defined)
fixes: #2354