This is an archive of the discontinued LLVM Phabricator instance.

[scudo][NFC] Suppress warnings for missing-noreturn, conditional-uninitialized, zero-length-array
ClosedPublic

Authored by ddcc on Mar 16 2022, 2:09 PM.

Diff Detail

Event Timeline

ddcc created this revision.Mar 16 2022, 2:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 16 2022, 2:09 PM
ddcc requested review of this revision.Mar 16 2022, 2:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 16 2022, 2:09 PM
vitalybuka added inline comments.Mar 24 2022, 11:56 AM
compiler-rt/lib/scudo/standalone/memtag.h
46

can you avoid pragmas with NORETURN?

compiler-rt/lib/scudo/standalone/secondary.h
247–271
248

Please don't mix different warning types in a single patch?

397

Can you avoid this by extractioing Quarantine with template specialization

class <size_t Size>
class Quarantine {
  doStuff1() {blocks...}
  doStuff2() {blocks...}
private
  CachedBlock blocks[Size];
};

template<> class Quarantine<0> {
  doStuff1() {}
  doStuff2() {}
}
ddcc added inline comments.Mar 25 2022, 4:42 PM
compiler-rt/lib/scudo/standalone/memtag.h
46

Sorry, I don't understand the question. The UNREACHABLE macro calls the die() function that is labeled with NORETURN, which causes the compiler to warn about functions that don't return but that aren't labeled NORETURN. I can remove NORETURN from that function, but that would also require changing its' callers as well, such as dieOnMapUnmapError.

compiler-rt/lib/scudo/standalone/secondary.h
247–271

The issue is on HeaderPos; for some reason the compiler thinks it may be uninitialized. I can just initialize that to zero instead.

397

I'll split this off into another patch.

ddcc updated this revision to Diff 418358.Mar 25 2022, 4:43 PM

Initialize HeaderPos, drop Quarantine changes

zero-length-array in description is not needed

compiler-rt/lib/scudo/standalone/memtag.h
46

I am asking about:
NORETURN inline uptr archMemoryTagGranuleSize()

If this does not suppress the warning then just
return 0;

Which compiler do you use?
Can you paste warning content with context?

ddcc updated this revision to Diff 418783.Mar 28 2022, 10:02 PM

Add noreturn attribute

ddcc added inline comments.Mar 28 2022, 10:07 PM
compiler-rt/lib/scudo/standalone/memtag.h
46

Oh sorry I misunderstood. Yeah adding noreturn avoids most of the warnings, except for the one on setRandomTag. This is because that warning only gets emitted while compiling memtag_test.cpp, which does not include combined.h, which has the only non-fatal uses of setRandomTag. But it's not correct to declare it noreturn in general, because the other uses are not fatal.

include/internal/scudo/memtag.h:305:62: error: function 'setRandomTag' could be declared with attribute 'noreturn'
      [-Werror,-Wmissing-noreturn]
                         uptr *TaggedBegin, uptr *TaggedEnd) {
                                                             ^
include/internal/scudo/memtag.h:308:1: error: function declared 'noreturn' should not return [-Werror,-Winvalid-noreturn]
}
vitalybuka accepted this revision.Mar 29 2022, 12:53 PM
vitalybuka added inline comments.
compiler-rt/lib/scudo/standalone/memtag.h
46

I don't like pragma there but NORETURN setRandomTag is incorrect.

This revision is now accepted and ready to land.Mar 29 2022, 12:53 PM

BTW, I suspect your fixes are going to regress with the time.
Would you like to update scudo_standalone cmake files so buildbots check these warnings?

ddcc added a comment.Mar 29 2022, 2:22 PM

BTW, I suspect your fixes are going to regress with the time.
Would you like to update scudo_standalone cmake files so buildbots check these warnings?

Sure, I'll handle that in a follow-up. I'm not familiar with how the current build; are scudo/CMakeLists.txt and scudo/standalone/CMakeLists.txt separate projects? Are there instructions somewhere for just building standalone scudo instead of compiler-rt + scudo?

This revision was landed with ongoing or failed builds.Mar 29 2022, 2:26 PM
This revision was automatically updated to reflect the committed changes.

BTW, I suspect your fixes are going to regress with the time.
Would you like to update scudo_standalone cmake files so buildbots check these warnings?

Sure, I'll handle that in a follow-up. I'm not familiar with how the current build; are scudo/CMakeLists.txt and scudo/standalone/CMakeLists.txt separate projects? Are there instructions somewhere for just building standalone scudo instead of compiler-rt + scudo?

standalone is replacement of scudo which uses no stuff from compiler-rt/lib/sanitizer_common/
scudo (not scudo/standalone) should be deleted and @hctim has some pending patch, so ignore that one.

bots should do: ninja check-scudo_standalone
e.g. here https://lab.llvm.org/buildbot/#/builders/37/builds/11999

abrachet added inline comments.
compiler-rt/lib/scudo/standalone/memtag.h
313

These need to be wrapped in #if __clang__. This doesn't build with gcc + -Werror=unknown-pragmas

mcgrathr added inline comments.Mar 29 2022, 5:39 PM
compiler-rt/lib/scudo/standalone/memtag.h
313

For warning switches that GCC also has, you should instead be using #pragma GCC diagnostic ....
Clang's feature is the same as GCC's, and Clang also supports the GCC syntax (which predates the Clang-specific pragma AFAIK). -Wmissing-noreturn is a warning switch both compilers have and that works the same in both.

ddcc added a comment.Mar 29 2022, 5:53 PM

Reverting for now, looks like there's some other build failures.