PrincetonUniversity / ILAng

A Modeling and Verification Platform for SoCs using ILAs
https://bo-yuan-huang.gitbook.io/ilang/
MIT License
75 stars 18 forks source link

Static analysis error/warning #141

Closed Bo-Yuan-Huang closed 4 years ago

Bo-Yuan-Huang commented 5 years ago

Describe the bug Issues found by Coverity on the analysis of 07c9c674875daa8be15368bb423159a18a3f7051.

Detail See comments the issues.

Bo-Yuan-Huang commented 5 years ago

Unchecked dynamic_cast

Description If the dynamic_cast fails, a null pointer dereference will occur; if the dynamic_cast cannot fail, using static_cast instead offers better performance.

In ilang::​SynthAbsConverter::​CnvtNodeToExprConst(ilasynth::​Node const *): Dynamic_cast may fail and return null if the type cast is incompatible

Bo-Yuan-Huang commented 5 years ago

Time of check time of use

Description An attacker could change the filename's file association or other attributes between the check and use.

In ilang::​os_portable_mkdir(std::​__cxx11::​basic_string<char, std::​char_traits, std::​allocator> const &): A check occurs on a file's attributes before the file is used in a privileged operation, but things may have changed

Bo-Yuan-Huang commented 5 years ago

Uninitialized scalar field

Description The field will contain an arbitrary value left over from earlier computations.

In ilang::​IlaSim::​IlaSim(): A scalar field is not initialized by the constructor

Bo-Yuan-Huang commented 5 years ago

Missing break in switch

Description Execution falls through to the next case statement or default; this might indicate a common typo.

In ilang::​VerilogAnalyzer::​get_signal(std::​__cxx11::​basic_string<char, std::​char_traits, std::​allocator> const &): Missing break statement between cases in switch statement

Bo-Yuan-Huang commented 5 years ago

Uninitialized scalar field

Description The field will contain an arbitrary value left over from earlier computations.

In ilang::​VlgSglTgtGen::​VlgSglTgtGen(std::​cxx11::​basic_string<char, std::​char_traits, std::​allocator> const &, std::​shared_ptr<ilang::​Instr> const &, std::​shared_ptr<ilang::​InstrLvlAbs> const &, ilang::​VerilogGeneratorBase::​VlgGenConfig const &, nlohmann::​basic_json<std::​map, std::​vector, std::​cxx11::​basic_string<char, std::​char_traits, std::​allocator>, bool, long, unsigned long, double, std::​allocator, nlohmann::​adl_serializer> &, nlohmann::​basic_json<std::​map, std::​vector, std::​cxx11::​basic_string<char, std::​char_traits, std::​allocator>, bool, long, unsigned long, double, std::​allocator, nlohmann::​adl_serializer> &, ilang::​VerilogInfo *, std::​cxx11::​basic_string<char, std::​char_traits, std::​allocator> const &, std::​cxx11::​basic_string<char, std::​char_traits, std::​allocator> const &, std::​cxx11::​basic_string<char, std::​char_traits, std::​allocator> const &, std::​vector<std::​cxx11::​basic_string<char, std::​char_traits, std::​allocator>, std::​allocator<std::​cxx11::​basic_string<char, std::​char_traits, std::​allocator>>> const &, std::​vector<std::​cxx11::​basic_string<char, std::​char_traits, std::​allocator>, std::​allocator<std::​cxx11::​basic_string<char, std::​char_traits, std::​allocator>>> const &, ilang::​VlgVerifTgtGenBase::​_vtg_config const &, ilang::​VlgVerifTgtGenBase::​backend_selector): A scalar field is not initialized by the constructor

Bo-Yuan-Huang commented 5 years ago

Logically dead code

Description The indicated dead code may have performed some action; that action will never occur.

In ilang::​find_comments(std::​__cxx11::​basic_string<char, std::​char_traits, std::​allocator> const &): Code can never be reached because of a logical contradiction

Bo-Yuan-Huang commented 4 years ago

fix by #148