SlideShare a Scribd company logo
What we had to test and
what we learnt during the
creation of the Linux version
of PVS-Studio
Svyatoslav Razmyslov
Evgeniy Ryzhkov
PVS-Studio
www.viva64.com
Who needs static code analysis?
• Beginners
• «Hindu programmers»
• Bad programmers
MySQL (C++)
A lot of similar strings.
Everything should be
fine.
static int rr_cmp(uchar *a, uchar *b)
{
if (a[0] != b[0])
return (int)a[0] - (int)b[0];
if (a[1] != b[1])
return (int)a[1] - (int)b[1];
if (a[2] != b[2])
return (int)a[2] - (int)b[2];
if (a[3] != b[3])
return (int)a[3] - (int)b[3];
if (a[4] != b[4])
return (int)a[4] - (int)b[4];
if (a[5] != b[5])
return (int)a[1] - (int)b[5];
if (a[6] != b[6])
return (int)a[6] - (int)b[6];
return (int)a[7] - (int)b[7];
}
CryEngine 3 SDK (C++)
inline bool operator != (const SEfResTexture &m) const
{
if (stricmp(m_Name.c_str(), m_Name.c_str()) != 0 ||
m_TexFlags != m.m_TexFlags ||
m_bUTile != m.m_bUTile ||
.....
m_Sampler != m.m_Sampler)
return true;
return false;
}
Linux (C) kernel
static int tc_ctl_action(struct sk_buff *skb,
struct nlmsghdr *n)
{
struct net *net = sock_net(skb->sk);
struct nlattr *tca[TCA_ACT_MAX + 1];
u32 portid = skb ? NETLINK_CB(skb).portid : 0;
....
}
The function
got an
argument:
Dereferencing
Oops, it should be checked too.
These bugs have ALWAYS been there.
Taken from Cfront compiler, year 1985:
Pexpr expr::typ(Ptable tbl)
{
....
Pclass cl;
....
cl = (Pclass) nn->tp;
cl->permanent=1;
if (cl == 0) error('i',"%k %s'sT missing",CLASS,s);
....
}
Nothing has changed for the past 30
years. Modern Clang compiler:
Instruction *InstCombiner::visitGetElementPtrInst(....) {
....
Value *StrippedPtr = PtrOp->stripPointerCasts();
PointerType *StrippedPtrTy =
dyn_cast<PointerType>(StrippedPtr->getType());
if (!StrippedPtr)
return 0;
....
}
Static analysis methodology
 Automated code review
 Regular checks
 The human factor is avoided (it is lowered, to be exact).
 Specialized tools. The more the better.
But maybe not.
What did the PVS-Studio users wanted
from the Linux version of PVS-Studio?
 Command line utility;
“We don’t need integration with IDE!”
 We don’t need an installer
"We will set everything ourselves!»
 We don’t need the documentation
“We’ll run the program ourselves”
The first build and support
 The executable file is not a product
 Porting the code is only a small part of the work
 You cannot make conclusions without full-fledged
testing - comparison of testing on Windows and Linux
Myth of knowing build scripts
 Not all developers are completely familiar with the build
system
 People need some way of getting to know the product
without integrating and setting up
 This method should be quite reliable to leave a good
impression from the product
Support of multiple Linux
distributions
The choice of the monitoring technology
 (-) Clang scan-build
 (+) strace
 (+) JSON Compilation Database
 (+/-) RD_PRELOAD
Innumerable non-standard extensions of
GCC compilers
Closed testing of a Beta version
Episode 1
 The executable file of the analyzer with the setup script
 Online documentation
 Several different ways to analyze without the integration
Closed testing of a Beta version
Episode 2
 Support of non-standard compiler extensions
 Dealing with false alarms
 Creating Deb/Rpm packages
 Small tasks concerning the analyzer and the
documentation
Closed testing of a Beta version
Episode 3
 We decided not to use the config files for a quick check
 Improved work with the log of the strace utilitiy
 Work on the DEB/RPM packages
 Other tasks concerning the analyzer and the documentation
Closed testing of a Beta version
Episode 4
(Release Candidate)
 Heading towards the integration into large projects
 Implementation of various user requests
 Our own repositories for DEB/RPM packages*
Integration into Makefile/Makefile.am
.cpp.o:
$(CXX) $(CFLAGS) $(DFLAGS) $(INCLUDES) $< -o $@
pvs-studio --cfg $(CFG_PATH) --source-file $< --language C++
--cl-params $(CFLAGS) $(DFLAGS) $(INCLUDES) $<
 Details in the analyzer setup
 Incremental analysis
 Parallelization of the analysis on the build system level
 Other pluses of the build system
Integration into CMake /CLion
include(PVS-Studio.cmake)
pvs_studio_add_target(TARGET analyze
OUTPUT FORMAT errorfile
ANALYZE target LOG target.plog
LICENSE "/path/to/PVS-Studio.lic")
Integration into CMake/QtCreator
include(PVS-Studio.cmake)
pvs_studio_add_target(TARGET analyze
OUTPUT FORMAT errorfile
ANALYZE target LOG target.plog
LICENSE "/path/to/PVS-Studio.lic")
Integration into QMake/QtCreator
pvs_studio.target = pvs
pvs_studio.output = true
pvs_studio.license = /path/to/PVS-Studio.lic
pvs_studio.cfg = /path/to/PVS-Studio.cfg
pvs_studio.cxxflags = -std=c++14
pvs_studio.sources = $${SOURCES}
include(PVS-Studio.pri)
Conclusions made during the
development process
 Installation from a package or a repository
 Getting to know the product using a quick scan
 Integration into a project so that the developer may
have incremental analysis
 Configuring a complete analysis on the build server
 Additional comment - a crazy amount of the Linux projects analyzed, so
that the tool can be considered operational.
Questions?
 Release of PVS-Studio for Linux:
October 25, Tuesday
www.viva64.com
PVS-Studio checks C,C++ and C#

More Related Content

PPTX
200 Open Source Projects Later: Source Code Static Analysis Experience
PPTX
PVS-Studio 5.00, a solution for developers of modern resource-intensive appl...
PDF
A Check of the Open-Source Project WinSCP Developed in Embarcadero C++ Builder
PDF
How to make a large C++-code base manageable
PPTX
C++17 now
PDF
Csw2016 gong pwn_a_nexus_device_with_a_single_vulnerability
PDF
Valgrind overview: runtime memory checker and a bit more aka использование #v...
PDF
Csw2016 gawlik bypassing_differentdefenseschemes
200 Open Source Projects Later: Source Code Static Analysis Experience
PVS-Studio 5.00, a solution for developers of modern resource-intensive appl...
A Check of the Open-Source Project WinSCP Developed in Embarcadero C++ Builder
How to make a large C++-code base manageable
C++17 now
Csw2016 gong pwn_a_nexus_device_with_a_single_vulnerability
Valgrind overview: runtime memory checker and a bit more aka использование #v...
Csw2016 gawlik bypassing_differentdefenseschemes

What's hot (20)

PDF
Антон Наумович, Система автоматической крэш-аналитики своими средствами
PPTX
Дмитрий Демчук. Кроссплатформенный краш-репорт
PDF
The CppCat Analyzer Checks TortoiseGit
PDF
Работа с реляционными базами данных в C++
PDF
Skiron - Experiments in CPU Design in D
PDF
clWrap: Nonsense free control of your GPU
PDF
[COSCUP 2021] A trip about how I contribute to LLVM
PDF
Checking the Source SDK Project
PPTX
Gor Nishanov, C++ Coroutines – a negative overhead abstraction
PDF
Valgrind
PPTX
Evgeniy Muralev, Mark Vince, Working with the compiler, not against it
PDF
PVS-Studio vs Chromium
PDF
PVS-Studio vs Chromium
PPTX
RuntimeUnitTestToolkit for Unity(English)
PDF
GOCON Autumn (Story of our own Monitoring Agent in golang)
PDF
用 Go 語言打造多台機器 Scale 架構
PDF
Linux Kernel, tested by the Linux-version of PVS-Studio
PDF
Bridge TensorFlow to run on Intel nGraph backends (v0.5)
ODP
The why and how of moving to php 7.x
PDF
Windbg랑 친해지기
Антон Наумович, Система автоматической крэш-аналитики своими средствами
Дмитрий Демчук. Кроссплатформенный краш-репорт
The CppCat Analyzer Checks TortoiseGit
Работа с реляционными базами данных в C++
Skiron - Experiments in CPU Design in D
clWrap: Nonsense free control of your GPU
[COSCUP 2021] A trip about how I contribute to LLVM
Checking the Source SDK Project
Gor Nishanov, C++ Coroutines – a negative overhead abstraction
Valgrind
Evgeniy Muralev, Mark Vince, Working with the compiler, not against it
PVS-Studio vs Chromium
PVS-Studio vs Chromium
RuntimeUnitTestToolkit for Unity(English)
GOCON Autumn (Story of our own Monitoring Agent in golang)
用 Go 語言打造多台機器 Scale 架構
Linux Kernel, tested by the Linux-version of PVS-Studio
Bridge TensorFlow to run on Intel nGraph backends (v0.5)
The why and how of moving to php 7.x
Windbg랑 친해지기
Ad

Viewers also liked (12)

PPTX
Teoria del color
PPTX
Aparato respiratorio
DOCX
COMPARATIVO DE INICIATIVAS RELATIVAS A LA LEY GENERAL DEL SISTEMA NACIONAL AN...
PDF
Revista de Economia I
PDF
PlumbingDrainWasteVentcoursecompletion
PDF
Public notices for June 5, 2012
DOCX
Trabajo práctico n°6
DOCX
Informe completo acerca de la escuela
PPTX
ευριπίδου άλκηστης
PPTX
Linux ppt
PPTX
Linux.ppt
Teoria del color
Aparato respiratorio
COMPARATIVO DE INICIATIVAS RELATIVAS A LA LEY GENERAL DEL SISTEMA NACIONAL AN...
Revista de Economia I
PlumbingDrainWasteVentcoursecompletion
Public notices for June 5, 2012
Trabajo práctico n°6
Informe completo acerca de la escuela
ευριπίδου άλκηστης
Linux ppt
Linux.ppt
Ad

Similar to PVS-Studio for Linux (CoreHard presentation) (20)

PDF
The Development History of PVS-Studio for Linux
PDF
PVS-Studio confesses its love for Linux
PDF
An Experiment with Checking the glibc Library
PDF
R&D on PVS-Studio
PDF
PVS-Studio Now Supports Any Build System under Windows and Any Compiler. Easy...
PDF
Bugs found in GCC with the help of PVS-Studio
PDF
You can now use PVS-Studio with Visual Studio absent; just give it the prepro...
PDF
Comparing Functionalities of PVS-Studio and CppCat Static Code Analyzers
PDF
PVS-Studio delved into the FreeBSD kernel
PPTX
The operation principles of PVS-Studio static code analyzer
PPTX
PVS-Studio static analyzer: advanced features
PDF
Finding bugs in the code of LLVM project with the help of PVS-Studio
PDF
How PVS-Studio does the bug search: methods and technologies
PPTX
Effective C++
PDF
GNU Compiler Collection - August 2005
PPT
From gcc to the autotools
PDF
Checking the Source SDK Project
PDF
PVS-Studio in the Clouds: Travis CI
PDF
Checking the Code of LDAP-Server ReOpenLDAP on Our Readers' Request
PDF
Linux programming
The Development History of PVS-Studio for Linux
PVS-Studio confesses its love for Linux
An Experiment with Checking the glibc Library
R&D on PVS-Studio
PVS-Studio Now Supports Any Build System under Windows and Any Compiler. Easy...
Bugs found in GCC with the help of PVS-Studio
You can now use PVS-Studio with Visual Studio absent; just give it the prepro...
Comparing Functionalities of PVS-Studio and CppCat Static Code Analyzers
PVS-Studio delved into the FreeBSD kernel
The operation principles of PVS-Studio static code analyzer
PVS-Studio static analyzer: advanced features
Finding bugs in the code of LLVM project with the help of PVS-Studio
How PVS-Studio does the bug search: methods and technologies
Effective C++
GNU Compiler Collection - August 2005
From gcc to the autotools
Checking the Source SDK Project
PVS-Studio in the Clouds: Travis CI
Checking the Code of LDAP-Server ReOpenLDAP on Our Readers' Request
Linux programming

More from Andrey Karpov (20)

PDF
60 антипаттернов для С++ программиста
PDF
60 terrible tips for a C++ developer
PPTX
Ошибки, которые сложно заметить на code review, но которые находятся статичес...
PDF
PVS-Studio in 2021 - Error Examples
PDF
PVS-Studio in 2021 - Feature Overview
PDF
PVS-Studio в 2021 - Примеры ошибок
PDF
PVS-Studio в 2021
PPTX
Make Your and Other Programmer’s Life Easier with Static Analysis (Unreal Eng...
PPTX
Best Bugs from Games: Fellow Programmers' Mistakes
PPTX
Does static analysis need machine learning?
PPTX
Typical errors in code on the example of C++, C#, and Java
PPTX
How to Fix Hundreds of Bugs in Legacy Code and Not Die (Unreal Engine 4)
PPTX
Game Engine Code Quality: Is Everything Really That Bad?
PPTX
C++ Code as Seen by a Hypercritical Reviewer
PPTX
The Use of Static Code Analysis When Teaching or Developing Open-Source Software
PPTX
Static Code Analysis for Projects, Built on Unreal Engine
PPTX
Safety on the Max: How to Write Reliable C/C++ Code for Embedded Systems
PPTX
The Great and Mighty C++
PPTX
Static code analysis: what? how? why?
PDF
Zero, one, two, Freddy's coming for you
60 антипаттернов для С++ программиста
60 terrible tips for a C++ developer
Ошибки, которые сложно заметить на code review, но которые находятся статичес...
PVS-Studio in 2021 - Error Examples
PVS-Studio in 2021 - Feature Overview
PVS-Studio в 2021 - Примеры ошибок
PVS-Studio в 2021
Make Your and Other Programmer’s Life Easier with Static Analysis (Unreal Eng...
Best Bugs from Games: Fellow Programmers' Mistakes
Does static analysis need machine learning?
Typical errors in code on the example of C++, C#, and Java
How to Fix Hundreds of Bugs in Legacy Code and Not Die (Unreal Engine 4)
Game Engine Code Quality: Is Everything Really That Bad?
C++ Code as Seen by a Hypercritical Reviewer
The Use of Static Code Analysis When Teaching or Developing Open-Source Software
Static Code Analysis for Projects, Built on Unreal Engine
Safety on the Max: How to Write Reliable C/C++ Code for Embedded Systems
The Great and Mighty C++
Static code analysis: what? how? why?
Zero, one, two, Freddy's coming for you

Recently uploaded (20)

PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
ai tools demonstartion for schools and inter college
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
Nekopoi APK 2025 free lastest update
PDF
Digital Strategies for Manufacturing Companies
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPTX
history of c programming in notes for students .pptx
PDF
top salesforce developer skills in 2025.pdf
PDF
AI in Product Development-omnex systems
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Upgrade and Innovation Strategies for SAP ERP Customers
Odoo Companies in India – Driving Business Transformation.pdf
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
ai tools demonstartion for schools and inter college
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Nekopoi APK 2025 free lastest update
Digital Strategies for Manufacturing Companies
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PTS Company Brochure 2025 (1).pdf.......
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Wondershare Filmora 15 Crack With Activation Key [2025
Odoo POS Development Services by CandidRoot Solutions
Design an Analysis of Algorithms II-SECS-1021-03
history of c programming in notes for students .pptx
top salesforce developer skills in 2025.pdf
AI in Product Development-omnex systems
How to Migrate SBCGlobal Email to Yahoo Easily
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus

PVS-Studio for Linux (CoreHard presentation)

  • 1. What we had to test and what we learnt during the creation of the Linux version of PVS-Studio Svyatoslav Razmyslov Evgeniy Ryzhkov PVS-Studio www.viva64.com
  • 2. Who needs static code analysis? • Beginners • «Hindu programmers» • Bad programmers
  • 3. MySQL (C++) A lot of similar strings. Everything should be fine. static int rr_cmp(uchar *a, uchar *b) { if (a[0] != b[0]) return (int)a[0] - (int)b[0]; if (a[1] != b[1]) return (int)a[1] - (int)b[1]; if (a[2] != b[2]) return (int)a[2] - (int)b[2]; if (a[3] != b[3]) return (int)a[3] - (int)b[3]; if (a[4] != b[4]) return (int)a[4] - (int)b[4]; if (a[5] != b[5]) return (int)a[1] - (int)b[5]; if (a[6] != b[6]) return (int)a[6] - (int)b[6]; return (int)a[7] - (int)b[7]; }
  • 4. CryEngine 3 SDK (C++) inline bool operator != (const SEfResTexture &m) const { if (stricmp(m_Name.c_str(), m_Name.c_str()) != 0 || m_TexFlags != m.m_TexFlags || m_bUTile != m.m_bUTile || ..... m_Sampler != m.m_Sampler) return true; return false; }
  • 5. Linux (C) kernel static int tc_ctl_action(struct sk_buff *skb, struct nlmsghdr *n) { struct net *net = sock_net(skb->sk); struct nlattr *tca[TCA_ACT_MAX + 1]; u32 portid = skb ? NETLINK_CB(skb).portid : 0; .... } The function got an argument: Dereferencing Oops, it should be checked too.
  • 6. These bugs have ALWAYS been there. Taken from Cfront compiler, year 1985: Pexpr expr::typ(Ptable tbl) { .... Pclass cl; .... cl = (Pclass) nn->tp; cl->permanent=1; if (cl == 0) error('i',"%k %s'sT missing",CLASS,s); .... }
  • 7. Nothing has changed for the past 30 years. Modern Clang compiler: Instruction *InstCombiner::visitGetElementPtrInst(....) { .... Value *StrippedPtr = PtrOp->stripPointerCasts(); PointerType *StrippedPtrTy = dyn_cast<PointerType>(StrippedPtr->getType()); if (!StrippedPtr) return 0; .... }
  • 8. Static analysis methodology  Automated code review  Regular checks  The human factor is avoided (it is lowered, to be exact).  Specialized tools. The more the better. But maybe not.
  • 9. What did the PVS-Studio users wanted from the Linux version of PVS-Studio?  Command line utility; “We don’t need integration with IDE!”  We don’t need an installer "We will set everything ourselves!»  We don’t need the documentation “We’ll run the program ourselves”
  • 10. The first build and support  The executable file is not a product  Porting the code is only a small part of the work  You cannot make conclusions without full-fledged testing - comparison of testing on Windows and Linux
  • 11. Myth of knowing build scripts  Not all developers are completely familiar with the build system  People need some way of getting to know the product without integrating and setting up  This method should be quite reliable to leave a good impression from the product
  • 12. Support of multiple Linux distributions
  • 13. The choice of the monitoring technology  (-) Clang scan-build  (+) strace  (+) JSON Compilation Database  (+/-) RD_PRELOAD
  • 15. Closed testing of a Beta version Episode 1  The executable file of the analyzer with the setup script  Online documentation  Several different ways to analyze without the integration
  • 16. Closed testing of a Beta version Episode 2  Support of non-standard compiler extensions  Dealing with false alarms  Creating Deb/Rpm packages  Small tasks concerning the analyzer and the documentation
  • 17. Closed testing of a Beta version Episode 3  We decided not to use the config files for a quick check  Improved work with the log of the strace utilitiy  Work on the DEB/RPM packages  Other tasks concerning the analyzer and the documentation
  • 18. Closed testing of a Beta version Episode 4 (Release Candidate)  Heading towards the integration into large projects  Implementation of various user requests  Our own repositories for DEB/RPM packages*
  • 19. Integration into Makefile/Makefile.am .cpp.o: $(CXX) $(CFLAGS) $(DFLAGS) $(INCLUDES) $< -o $@ pvs-studio --cfg $(CFG_PATH) --source-file $< --language C++ --cl-params $(CFLAGS) $(DFLAGS) $(INCLUDES) $<  Details in the analyzer setup  Incremental analysis  Parallelization of the analysis on the build system level  Other pluses of the build system
  • 20. Integration into CMake /CLion include(PVS-Studio.cmake) pvs_studio_add_target(TARGET analyze OUTPUT FORMAT errorfile ANALYZE target LOG target.plog LICENSE "/path/to/PVS-Studio.lic")
  • 21. Integration into CMake/QtCreator include(PVS-Studio.cmake) pvs_studio_add_target(TARGET analyze OUTPUT FORMAT errorfile ANALYZE target LOG target.plog LICENSE "/path/to/PVS-Studio.lic")
  • 22. Integration into QMake/QtCreator pvs_studio.target = pvs pvs_studio.output = true pvs_studio.license = /path/to/PVS-Studio.lic pvs_studio.cfg = /path/to/PVS-Studio.cfg pvs_studio.cxxflags = -std=c++14 pvs_studio.sources = $${SOURCES} include(PVS-Studio.pri)
  • 23. Conclusions made during the development process  Installation from a package or a repository  Getting to know the product using a quick scan  Integration into a project so that the developer may have incremental analysis  Configuring a complete analysis on the build server  Additional comment - a crazy amount of the Linux projects analyzed, so that the tool can be considered operational.
  • 24. Questions?  Release of PVS-Studio for Linux: October 25, Tuesday www.viva64.com PVS-Studio checks C,C++ and C#