-fsanitize=signed-integer-overflow not turned on in pytorch CI

Pooja_Agarwal: <p>I saw that -fsanitize=signed-integer-overflow is not turned on in pytorch CI. Reference: ASAN, UBSAN config for PyTorch: <a href="https://github.com/pytorch/pytorch/blob/d62b025efc732a7733850ebfcd097eaf28c8778a/.ci/pytorch/build.sh#L216" class="inline-onebox" rel="noopener nofollow ugc">pytorch/.ci/pytorch/build.sh at d62b025efc732a7733850ebfcd097eaf28c8778a · pytorch/pytorch · GitHub</a></p>
<p>UBSan config does not have -fsanitize=signed-integer-overflow.</p>
<p>Also, I cross-checked the settings for tests under pytorch/pytorch/.ci/pytorch/test.sh and it does not enable signed-integer-overflow check (does not contain -fsanitize=signed-integer-overflow).</p>
<p>I checked other code locations as well but didn’t see this setting enabled.</p>
<p>By default, when we enable Asan/UBSan, it does not automatically include the signed-integer-overflow check. To explicitly enable the signed-integer-overflow check in UBSan, we need to pass the more specific flag :<br>
<code>-fsanitize=signed-integer-overflow</code></p>
<p>In Google3, --copt=-fsanitize=signed-integer-overflow is turned on for builds with ASAN turned on (part of Google-wide UBSan default config). So, this check is on at Google. This means that we get ASAN errors when importing PyTorch tests such as SymInt_test.cpp <a href="https://github.com/pytorch/pytorch/blob/4d32de14b6caeb12f874b55d590d3cbda5cec6cb/c10/test/core/SymInt_test.cpp#L25" class="inline-onebox" rel="noopener nofollow ugc">pytorch/c10/test/core/SymInt_test.cpp at 4d32de14b6caeb12f874b55d590d3cbda5cec6cb · pytorch/pytorch · GitHub</a> that intentionally cause integer overflow.</p>
<p>For now, we have an internal-to-Google patch that skips asan/ubsan on this test, but we want to know if there is a reason for -fsanitize=signed-integer-overflow to not be turned on by default in PyTorch CI? If it is enabled, we can handle upstream and mark noasan on tests that intentionally cause integer overflow.</p>
<p>Note that we see tags in Python unit tests that are skipped under UBSan, this particular instance is over a C++ test.</p>

Pooja_Agarwal: <p>I found another place where ASAN groups are being enabled: <a href="https://github.com/pytorch/pytorch/blob/0f1f0d3015f2f5ef0753468ed21d09e388d19c24/cmake/Modules/FindSanitizer.cmake#L26" class="inline-onebox" rel="noopener nofollow ugc">pytorch/cmake/Modules/FindSanitizer.cmake at 0f1f0d3015f2f5ef0753468ed21d09e388d19c24 · pytorch/pytorch · GitHub</a></p>
<p>if Line 27 and its corresponding ‘if’ is not continuing the loop for ‘undefined’ group, then it looks like <code>-fsanitize=undefined</code> would get added at Line 31.</p>
<p>Adding <code>-fsanitize=undefined</code> would enable <code>signed-integer-overflow</code> per Clang’s documentation: <a href="https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#available-checks" class="inline-onebox" rel="noopener nofollow ugc">UndefinedBehaviorSanitizer — Clang 19.0.0git documentation</a></p>
<p>Couple of questions:<br>
a) Is there a way to confirm if the upstream CI tests have <code>-fsanitize=undefined</code> enabled?<br>
b) Assuming <code>-fsanitize=undefined</code> is enabled, how is SymInt_test.cpp (link in above post, limited to 2 links per post) passing ASAN/UBSan in PyTorch CI, given it does cause integer overflow? Is there a way to see latest ASAN run for this test in PyTorch Github?</p>