Coverity Scan Needs to be Updated after GitHub Migration

The Coverity scan of the llvm project, https://scan.coverity.com/projects/llvm is still pulling from the old subversion repository. It needs to be updated to https://github.com/llvm/llvm-project.

Who has permission to change this?

As a reminder, the Coverity scan of the llvm project, https://scan.coverity.com/projects/llvm is still pulling from the old subversion repository. It needs to be updated to https://github.com/llvm/llvm-project.

Whoever setup the original account, needs to change this. Or someone with admin permissions on github needs to create a new account? Who would I talk to about this?

I doubt anyone on this mailing list has any control over the Coverity scan. I'd suggest emailing Coverity; it looks like the address is scan-admin@coverity.com .

-Eli

+Sylvestre Ledru is the admin here.

That said, I believe that anyone with admin permissions on the LLVM organization on Github can set up a new LLVM project on the coverity website.

Hello,

The issue isn’t about the repo configuration but more having a build working with cov-build. I stop carrying for two reasons:

  • it was often regressing

  • afaik, nobody but me was paying attention to newly detected defects (if I am wrong, please let me know and I can have a look).

By the way, I have been generating these reports:

Cheers,
Sylvestre

* it was often regressing

If there is interest, I'd be willing to help with the cov-build,

* afaik, nobody but me was paying attention to newly detected defects (if I am wrong, please let me know and I can have a look).

In my experience, a weekly report of new defects helps keep engagement up and issues down. Here is an example:

http://document-foundation-mail-archive.969070.n3.nabble.com/New-Defects-reported-by-Coverity-Scan-for-LibreOffice-td4301033.html

Would a weekly scan report be welcome here?

I use to be subscribed to the weekly report and I was actually addressing regressions.
The annoying part is the large number of false positive that needed triage…

I took the time this week end to turn it back on in the apt.llvm.org CI:
Coverity Scan - Static Analysis

Should run once a day.

Currently, it finds 3 048 defects in llvm, clang, lld, lldb, etc. Keep in mind that a bunch of them are false positive.

The component view broken currently (doesn't refresh with new configurations).

As attachment, a screenshot of the kind of defect Coverity is identifying.

Cheers,
Sylvestre

I took the time this week end to turn it back on in the apt.llvm.org CI:
Coverity Scan - Static Analysis

Should run once a day.

Currently, it finds 3 048 defects in llvm, clang, lld, lldb, etc. Keep in mind that a bunch of them are false positive.

The component view broken currently (doesn't refresh with new configurations).

Screenshot of the kind of defect Coverity is identifying:
Imgur

Cheers,
Sylvestre

I took the time this week end to turn it back on in the apt.llvm.org CI:
https://scan.coverity.com/projects/llvm

Should run once a day.

Currently, it finds 3 048 defects in llvm, clang, lld, lldb, etc. Keep in mind that a bunch of them are false positive.

The component view broken currently (doesn't refresh with new configurations).

Screenshot of the kind of defect Coverity is identifying:
https://imgur.com/729Yrtp

Cheers,
Sylvestre

https://scan.coverity.com/projects/llvm
Should run once a day.

Sylvester,
The report seems to be working perfectly. Thank you for taking the time to get this up and running again!

My only concern is that there is no visibly on these reports. Without the new issues being reported here, it is highly unlikely that they will get addressed.

Since there was interest and no objections, could you please add the [llvm-dev] list to the email?

You can do this by going to the "Project Settings" page:
https://scan.coverity.com/projects/llvm?tab=project_settings

"Additional Emails for New Defect Notifications"
-> llvm-dev@lists.llvm.org

Then could you please lower the report frequency to once or twice a week? With that we will receive weekly reports like this:

http://document-foundation-mail-archive.969070.n3.nabble.com/New-Defects-reported-by-Coverity-Scan-for-LibreOffice-td4301203.html

Do the reports have deltas? (highlighting new defects with as fine revision granularity as possible) or do they only show the total set of findings at a given revision?

Yes (see below sample email from today), which is why I’d prefer to keep this daily rather than weekly. llvm-commits@ may be more suitable than llvm-dev@ for this?

From Coverity:

Please find the latest report on new defect(s) introduced to llvm found with Coverity Scan.

8 new defect(s) introduced to llvm found with Coverity Scan.
19 defect(s), reported by Coverity Scan earlier, were marked fixed in the recent build analyzed by Coverity Scan.

New defect(s) Reported-by: Coverity Scan
Showing 8 of 8 defect(s)

** CID 1457502: Uninitialized members (UNINIT_CTOR)
/lld/MachO/InputSection.h: 109 in lld::macho::StringPiece::StringPiece(unsigned long, unsigned int)()

Do the reports have deltas? (highlighting new defects with as fine revision granularity as possible) or do they only show the total set of findings at a given revision?

Yes (see below sample email from today), which is why I’d prefer to keep this daily rather than weekly.

Ah, cool - thanks!

llvm-commits@ may be more suitable than llvm-dev@ for this?

Yeah, not sure. I don’t feel too strongly either way.

From Coverity:

Please find the latest report on new defect(s) introduced to llvm found with Coverity Scan.

8 new defect(s) introduced to llvm found with Coverity Scan.
19 defect(s), reported by Coverity Scan earlier, were marked fixed in the recent build analyzed by Coverity Scan.

New defect(s) Reported-by: Coverity Scan
Showing 8 of 8 defect(s)

** CID 1457502: Uninitialized members (UNINIT_CTOR)
/lld/MachO/InputSection.h: 109 in lld::macho::StringPiece::StringPiece(unsigned long, unsigned int)()

Is it easy for us to disable low-value findings (both on a per-instance, but also per-check-tye) basis in source (ie: without having to modify an external config)?

For instance, I’m not sure it’s valuable for us to get notification on any member not initialized by a ctor. That could readily be detected by clang-tidy or clang warnings and we don’t implement such checks in those places (which would be higher value because they can find the issue sooner rather than waiting for a long-running static analysis to come back with results).

Keeping the warnings low-noise would be really important (so whoever set this up or requested it I hope is really pushing to reduce the noise until nearly all results have pretty broad agreement that they should be fixed).


*** CID 1457502: Uninitialized members (UNINIT_CTOR)
/lld/MachO/InputSection.h: 109 in lld::macho::StringPiece::StringPiece(unsigned long, unsigned int)()
103 // Offset from the start of the containing input section.
104 uint32_t inSecOff;
105 uint32_t hash;
106 // Offset from the start of the containing output section.
107 uint64_t outSecOff;
108

CID 1457502: Uninitialized members (UNINIT_CTOR)
Non-static class member “outSecOff” is not initialized in this constructor nor in any functions that it calls.
109 StringPiece(uint64_t off, uint32_t hash) : inSecOff(off), hash(hash) {}
110 };
111
112 // CStringInputSections are composed of multiple null-terminated string
113 // literals, which we represent using StringPieces. These literals can be
114 // deduplicated and tail-merged, so translating offsets between the input and

** CID 1457501: Uninitialized members (UNINIT_CTOR)
/llvm/lib/ObjectYAML/XCOFFEmitter.cpp: 36 in ::XCOFFWriter::XCOFFWriter(llvm::XCOFFYAML::Object &, llvm::raw_ostream &, llvm::function_ref<void (const llvm::Twine &)>)()


*** CID 1457501: Uninitialized members (UNINIT_CTOR)
/llvm/lib/ObjectYAML/XCOFFEmitter.cpp: 36 in ::XCOFFWriter::XCOFFWriter(llvm::XCOFFYAML::Object &, llvm::raw_ostream &, llvm::function_ref<void (const llvm::Twine &)>)()
30
31 class XCOFFWriter {
32 public:
33 XCOFFWriter(XCOFFYAML::Object &Obj, raw_ostream &OS, yaml::ErrorHandler EH)
34 : Obj(Obj), W(OS, support::big), ErrHandler(EH) {
35 Is64Bit = Obj.Header.Magic == (llvm::yaml::Hex16)XCOFF::XCOFF64;

CID 1457501: Uninitialized members (UNINIT_CTOR)
Non-static class member “StartOffset” is not initialized in this constructor nor in any functions that it calls.
36 }
37 bool writeXCOFF();
38
39 private:
40 bool initFileHeader(uint64_t CurrentOffset);
41 bool initSectionHeader(uint64_t &CurrentOffset);

** CID 1457500: Incorrect expression (SIZEOF_MISMATCH)
/compiler-rt/lib/dfsan/dfsan_custom.cpp: 2367 in format_buffer(char *, unsigned long, const char *, unsigned char *, unsigned char *, unsigned int *, unsigned int *, __va_list_tag *)()


*** CID 1457500: Incorrect expression (SIZEOF_MISMATCH)
/compiler-rt/lib/dfsan/dfsan_custom.cpp: 2367 in format_buffer(char *, unsigned long, const char *, unsigned char *, unsigned char *, unsigned int *, unsigned int *, __va_list_tag *)()
2361 case ‘n’: {
2362 int *ptr = va_arg(ap, int *);
2363 *ptr = (int)formatter.str_off;
2364 va_labels++;
2365 if (va_origins)
2366 va_origins++;

CID 1457500: Incorrect expression (SIZEOF_MISMATCH)
Passing argument “ptr” of type “int " and argument "8UL / sizeof (ptr) */” to function “dfsan_set_label” is suspicious.
2367 dfsan_set_label(0, ptr, sizeof(ptr));

I think clang has a sizeof warning for things like memcpy, right? I wonder if this more broad warning provides a lot of value, or not?

2368 end_fmt = true;
2369 break;
2370 }
2371
2372 case ‘%’:

** CID 1457499: Incorrect expression (DIVIDE_BY_ZERO)
/llvm/lib/Analysis/CFGPrinter.cpp: 308 in llvm::DOTGraphTraits<llvm::DOTFuncInfo *>::isNodeHidden(const llvm::BasicBlock *, const llvm::DOTFuncInfo *)()


*** CID 1457499: Incorrect expression (DIVIDE_BY_ZERO)
/llvm/lib/Analysis/CFGPrinter.cpp: 308 in llvm::DOTGraphTraits<llvm::DOTFuncInfo *>::isNodeHidden(const llvm::BasicBlock *, const llvm::DOTFuncInfo *)()
302 const DOTFuncInfo *CFGInfo) {
303 if (HideColdPaths.getNumOccurrences() > 0)
304 if (auto *BFI = CFGInfo->getBFI()) {
305 uint64_t NodeFreq = BFI->getBlockFreq(Node).getFrequency();
306 uint64_t EntryFreq = BFI->getEntryFreq();
307 // Hide blocks with relative frequency below HideColdPaths threshold.

CID 1457499: Incorrect expression (DIVIDE_BY_ZERO)
In expression “(double)NodeFreq / EntryFreq”, division by expression “EntryFreq” which may be zero has undefined behavior.
308 if ((double)NodeFreq / EntryFreq < HideColdPaths)
309 return true;
310 }
311 if (HideUnreachablePaths || HideDeoptimizePaths) {
312 if (isOnDeoptOrUnreachablePath.find(Node) ==
313 isOnDeoptOrUnreachablePath.end())

** CID 1457498: (DEADCODE)
/clang/lib/Sema/SemaDeclCXX.cpp: 11843 in clang::Sema::CheckUsingShadowDecl(clang::BaseUsingDecl *, clang::NamedDecl *, const clang::LookupResult &, clang::UsingShadowDecl *&)()
/clang/lib/Sema/SemaDeclCXX.cpp: 11789 in clang::Sema::CheckUsingShadowDecl(clang::BaseUsingDecl *, clang::NamedDecl *, const clang::LookupResult &, clang::UsingShadowDecl *&)()


*** CID 1457498: (DEADCODE)
/clang/lib/Sema/SemaDeclCXX.cpp: 11843 in clang::Sema::CheckUsingShadowDecl(clang::BaseUsingDecl *, clang::NamedDecl *, const clang::LookupResult &, clang::UsingShadowDecl *&)()
11837 return true;
11838 }
11839
11840 // No conflict between a tag and a non-tag.
11841 if (!NonTag) return false;
11842

CID 1457498: (DEADCODE)
Execution cannot reach this statement: " = this->Diag(cl…".
11843 Diag(BUD->getLocation(), diag::err_using_decl_conflict);
11844 Diag(Target->getLocation(), diag::note_using_decl_target);
11845 Diag(NonTag->getLocation(), diag::note_using_decl_conflict);
11846 BUD->setInvalidDecl();
11847 return true;
11848 }
/clang/lib/Sema/SemaDeclCXX.cpp: 11789 in clang::Sema::CheckUsingShadowDecl(clang::BaseUsingDecl *, clang::NamedDecl *, const clang::LookupResult &, clang::UsingShadowDecl *&)()
11783 // Always emit a diagnostic for a mismatch between an unresolved
11784 // using_if_exists and a resolved using declaration in either direction.
11785 if (isa(Target) !=
11786 (isa_and_nonnull(NonTag))) {
11787 if (!NonTag && !Tag)
11788 return false;

CID 1457498: (DEADCODE)
Execution cannot reach this statement: " = this->Diag(cl…".
11789 Diag(BUD->getLocation(), diag::err_using_decl_conflict);
11790 Diag(Target->getLocation(), diag::note_using_decl_target);
11791 Diag((NonTag ? NonTag : Tag)->getLocation(),
11792 diag::note_using_decl_conflict);
11793 BUD->setInvalidDecl();
11794 return true;

** CID 1457497: Integer handling issues (NEGATIVE_RETURNS)


*** CID 1457497: Integer handling issues (NEGATIVE_RETURNS)
/lld/MachO/InputSection.cpp: 117 in lld::macho::CStringInputSection::getStringPiece(unsigned long) const()
111 const StringPiece &CStringInputSection::getStringPiece(uint64_t off) const {
112 if (off >= data.size())
113 fatal(toString(this) + “: offset is outside the section”);
114
115 auto it =
116 partition_point(pieces, [=](StringPiece p) { return p.inSecOff <= off; });

CID 1457497: Integer handling issues (NEGATIVE_RETURNS)
A negative constant “-1L” is passed as an argument to a parameter that cannot be negative.

Doesn’t sound correct - negatively indexing from an iterator is valid, I believe? (though perhaps this check is using some info about the nature of partition_point being able to return the begin iterator)

From Coverity:

Please find the latest report on new defect(s) introduced to llvm found with Coverity Scan.

8 new defect(s) introduced to llvm found with Coverity Scan.
19 defect(s), reported by Coverity Scan earlier, were marked fixed in the recent build analyzed by Coverity Scan.

New defect(s) Reported-by: Coverity Scan
Showing 8 of 8 defect(s)

** CID 1457502: Uninitialized members (UNINIT_CTOR)
/lld/MachO/InputSection.h: 109 in lld::macho::StringPiece::StringPiece(unsigned long, unsigned int)()

Is it easy for us to disable low-value findings (both on a per-instance, but also per-check-tye) basis in source (ie: without having to modify an external config)?

Source annotations are available for suppressing per-instance issues, but no source annotations are available to disable checkers entirely.

I don't see an option for disabling specific checkers in Coverity Scan. Checker enable/disable and tuning options are available when using a Coverity installation. I don't know why those capabilities wouldn't be exposed to Coverity Scan users.

For instance, I'm not sure it's valuable for us to get notification on any member not initialized by a ctor. That could readily be detected by clang-tidy or clang warnings and we don't implement such checks in those places (which would be higher value because they can find the issue sooner rather than waiting for a long-running static analysis to come back with results).

Keeping the warnings low-noise would be really important (so whoever set this up or requested it I hope is really pushing to reduce the noise until nearly all results have pretty broad agreement that they should be fixed).

Yes, the general deployment recommendation is to tune to minimize FPs and low value results and then relax such tuning as issues are addressed.

Tom.

I confirmed with internal Coverity support that such options are not currently exposed to Coverity Scan users. Enhancement requests sent to will be considered for future Coverity Scan updates (I encourage sending an enhancement request).

From Coverity:

Please find the latest report on new defect(s) introduced to llvm found with Coverity Scan.

8 new defect(s) introduced to llvm found with Coverity Scan.
19 defect(s), reported by Coverity Scan earlier, were marked fixed in the recent build analyzed by Coverity Scan.

New defect(s) Reported-by: Coverity Scan
Showing 8 of 8 defect(s)

** CID 1457502: Uninitialized members (UNINIT_CTOR)
/lld/MachO/InputSection.h: 109 in lld::macho::StringPiece::StringPiece(unsigned long, unsigned int)()

Is it easy for us to disable low-value findings (both on a per-instance, but also per-check-tye) basis in source (ie: without having to modify an external config)?

Source annotations are available for suppressing per-instance issues, but no source annotations are available to disable checkers entirely.

I don’t see an option for disabling specific checkers in Coverity Scan. Checker enable/disable and tuning options are available when using a Coverity installation. I don’t know why those capabilities wouldn’t be exposed to Coverity Scan users.

I confirmed with internal Coverity support that such options are not currently exposed to Coverity Scan users. Enhancement requests sent to scan-admin@coverity.com will be considered for future Coverity Scan updates (I encourage sending an enhancement request).

Having not setup the scanning/emails/etc I don’t think I have enough context (I’m not exactly a “user” - at best I’ve read one email produced by the tool) to make a feature request.

For instance, I’m not sure it’s valuable for us to get notification on any member not initialized by a ctor. That could readily be detected by clang-tidy or clang warnings and we don’t implement such checks in those places (which would be higher value because they can find the issue sooner rather than waiting for a long-running static analysis to come back with results).

I’m going to push back on this a bit. I’ve had to debug problems in Clang that turned out to be due to failure to initialize a data member. I find the number of uninitialized data member issues that Coverity reports on LLVM to be out of line with respect to other projects I’ve seen scanned. I’m skeptical that omitting initializers has a significant impact on performance.

The tradeoff is that initializing values that aren’t meant to be used reduces msan’s ability to identify bugs if such a value is really used.

Understood. If you find yourself unhappy with the results of any particular checker, I’ll be happy to work with you, Sylvestre, or anyone else interested to craft an ER.

From Coverity:

Please find the latest report on new defect(s) introduced to llvm found with Coverity Scan.

8 new defect(s) introduced to llvm found with Coverity Scan.
19 defect(s), reported by Coverity Scan earlier, were marked fixed in the recent build analyzed by Coverity Scan.

New defect(s) Reported-by: Coverity Scan
Showing 8 of 8 defect(s)

** CID 1457502: Uninitialized members (UNINIT_CTOR)
/lld/MachO/InputSection.h: 109 in lld::macho::StringPiece::StringPiece(unsigned long, unsigned int)()

Is it easy for us to disable low-value findings (both on a per-instance, but also per-check-tye) basis in source (ie: without having to modify an external config)?

Source annotations are available for suppressing per-instance issues, but no source annotations are available to disable checkers entirely.

I don’t see an option for disabling specific checkers in Coverity Scan. Checker enable/disable and tuning options are available when using a Coverity installation. I don’t know why those capabilities wouldn’t be exposed to Coverity Scan users.

I confirmed with internal Coverity support that such options are not currently exposed to Coverity Scan users. Enhancement requests sent to scan-admin@coverity.com will be considered for future Coverity Scan updates (I encourage sending an enhancement request).

Having not setup the scanning/emails/etc I don’t think I have enough context (I’m not exactly a “user” - at best I’ve read one email produced by the tool) to make a feature request.

Understood. If you find yourself unhappy with the results of any particular checker, I’ll be happy to work with you, Sylvestre, or anyone else interested to craft an ER.

For instance, I’m not sure it’s valuable for us to get notification on any member not initialized by a ctor. That could readily be detected by clang-tidy or clang warnings and we don’t implement such checks in those places (which would be higher value because they can find the issue sooner rather than waiting for a long-running static analysis to come back with results).

I’m going to push back on this a bit. I’ve had to debug problems in Clang that turned out to be due to failure to initialize a data member. I find the number of uninitialized data member issues that Coverity reports on LLVM to be out of line with respect to other projects I’ve seen scanned. I’m skeptical that omitting initializers has a significant impact on performance.

The tradeoff is that initializing values that aren’t meant to be used reduces msan’s ability to identify bugs if such a value is really used.

Yes, fair enough. Perhaps there is a way to provide a poisened initializer that is (effectively) elided when msan is enabled and used otherwise?

struct S {
int *p = POISON(nullptr);
};

Fair, I’d be open to something like that I think.