"fopen-usage" checker should ignore gtest include files
Categories
(Developer Infrastructure :: Source Code Analysis, defect)
Tracking
(firefox-esr68 unaffected, firefox73 unaffected, firefox74 unaffected, firefox75 fixed)
| Tracking | Status | |
|---|---|---|
| firefox-esr68 | --- | unaffected |
| firefox73 | --- | unaffected |
| firefox74 | --- | unaffected |
| firefox75 | --- | fixed |
People
(Reporter: emk, Assigned: andi)
References
(Regression)
Details
(Keywords: regression)
Attachments
(1 file)
gtest-port.h spams "fopen-usage" check failure here:
https://searchfox.org/mozilla-central/rev/1db5ef59eba65d32d6a29a494e87b6078453e559/testing/gtest/gtest/include/gtest/internal/gtest-port.h#2517
even though testing/gtest/gtest/ is a third-party path:
https://searchfox.org/mozilla-central/rev/1db5ef59eba65d32d6a29a494e87b6078453e559/tools/rewriting/ThirdPartyPaths.txt#129
A sample warning message:
55:53.93 e:/m/mozilla-unified/obj-x86_64-pc-mingw32/dist/include\gtest/internal/gtest-port.h(2517,10): note: On Windows executed functions: fopen, fopen_s, open, _open, _sopen, _sopen_s, OpenFile, CreateFileA should never be used due to lossy conversion from UTF8 to ANSI.
| Assignee | ||
Updated•6 years ago
|
| Reporter | ||
Comment 1•6 years ago
|
||
Adding dist/include/gtest/internal/ to ThirdPartyPaths.txt fixed the issue.
| Assignee | ||
Comment 2•6 years ago
|
||
Are we sure we want to exclude that from formatting also?
| Reporter | ||
Comment 3•6 years ago
|
||
Yes, because they are third-party code. We only import them from upstream.
| Assignee | ||
Comment 4•6 years ago
|
||
What I was saying is that we shouldn't include this dist/include/gtest/internal/ into our exclusion, since this is not a path from the tree but a path from the obj directory.
| Reporter | ||
Comment 5•6 years ago
|
||
We don't have to care about formatting anyway because we will not edit files under objdir manually and they are not in the repository.
| Assignee | ||
Comment 6•6 years ago
|
||
True but we shouldn't add files from build directory to the ThirdPartyPaths.txt.
| Reporter | ||
Comment 7•6 years ago
|
||
So how can we exclude them from static analysis?
| Assignee | ||
Comment 8•6 years ago
|
||
For start we know that most of the files from the obj/include are in fact symlinks to the appropriate files from the source so we should check if that file is a symlink and if so use real_path.
| Reporter | ||
Comment 9•6 years ago
|
||
(In reply to Andi-Bogdan Postelnicu [:andi] from comment #8)
For start we know that most of the files from the
obj/includeare in fact symlinks
It may not hold on Windows (if objdir is located on FAT32/exFAT voume.) I'm intentionally using this configuration to catch filesystem dependent problems (such as bug 1496050).
| Reporter | ||
Comment 10•6 years ago
|
||
I think we can generate a path mapping from <objdir>/install_dist_include.track.
| Reporter | ||
Comment 11•6 years ago
|
||
_build_manifests/install/dist_include would be better. python/mozbuild/mozpack/manifests.py is the parser for this file.
| Reporter | ||
Comment 12•6 years ago
|
||
How about ignoring gtest namespaces for fopen-usage checker? (like implicit-constructor or explicit-operator-bool) It would be much faster.
| Reporter | ||
Comment 13•6 years ago
|
||
Or whitelisting "gtest-port.h" is OK (like nan-expr checker.)
| Assignee | ||
Comment 14•6 years ago
|
||
(In reply to Masatoshi Kimura [:emk] from comment #13)
Or whitelisting "gtest-port.h" is OK (like
nan-exprchecker.)
I think this is the path that we should go, are there any other files that should be added to this exception?
| Reporter | ||
Comment 15•6 years ago
|
||
gtest-port.h is the only file that we need the exception for.
https://searchfox.org/mozilla-central/search?q=open&case=true®exp=false&path=include%2Fgtest
https://searchfox.org/mozilla-central/search?q=OpenFile&case=false®exp=false&path=include%2Fgtest
https://searchfox.org/mozilla-central/search?q=CreateFileA&case=false®exp=false&path=include%2Fgtest
I also skimmed through the build log.
| Assignee | ||
Comment 16•6 years ago
|
||
:emk Thanks for this, will push a patch shortly.
| Assignee | ||
Comment 17•6 years ago
|
||
Updated•6 years ago
|
Updated•6 years ago
|
Comment 18•6 years ago
|
||
Comment 19•6 years ago
|
||
Backed out for build bustages on CustomMatchers.h
Push with failure: https://treeherder.mozilla.org/#/jobs?repo=autoland&selectedJob=289083803&resultStatus=testfailed%2Cbusted%2Cexception&revision=e56af64a3199b70f0c80ea025e337bce40283ffb
Failure log: https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=289083803&repo=autoland&lineNumber=781
Backout: https://hg.mozilla.org/integration/autoland/rev/845fc7e6b7e9074d9ff98d04ac8c9919634e3e8c
Comment 21•6 years ago
|
||
Comment 22•6 years ago
|
||
| bugherder | ||
Updated•6 years ago
|
Updated•6 years ago
|
Updated•6 years ago
|
Updated•3 years ago
|
Description
•