codechecker
codechecker copied to clipboard
clang flag `-mllvm -x86-speculative-load-hardening` breaks the assumption that flag starting with `-x` indicates language
Describe the bug
CodeChecker fails to handle compile flag -mllvm -x86-speculative-load-hardening (I didn't check if there's any other flags like -mllvm -x<not_a_language>), see the illustrative example below.
The __get_language method in log_parser.py assumes -x always indicates the language, and this is not the only code section that makes the assumption.
CodeChecker version
CodeChecker analyzer version:
---------------------------------------------------------------
Kind | Version
---------------------------------------------------------------
Base package version | 6.22.2
Package build date | 2023-07-13T15:52
Git commit ID (hash) | a3d35cfd509b995187288cd8631446415a334257
Git tag information | 6.22.2
---------------------------------------------------------------
[INFO 2023-08-07 16:58] - CodeChecker web version:
------------------------------------------------------------------------------
Kind | Version
------------------------------------------------------------------------------
Base package version | 6.22.2
Package build date | 2023-07-13T15:52
Git commit ID (hash) | a3d35cfd509b995187288cd8631446415a334257
Git tag information | 6.22.2
Server supported Thrift API version | 6.53
Client Thrift API version | 6.53
------------------------------------------------------------------------------
To Reproduce
test.c
// no need to care about the source code
// ...
Makefile
CC = clang
test: test.c
$(CC) -g -o test -mllvm -x86-speculative-load-hardening test.c
.PHONY: clean
clean:
@rm test
run
make clean
CodeChecker log --build "make" --output ./compile_commands.json
CodeChecker analyze ./compile_commands.json --verbose debug --enable sensitive --output ./reports
output
output
[DEBUG][2023-08-07 17:12:29] {system} [51304] <140369678279040> - analyze.py:990 main() - args: Namespace(input='/home/username/compile_commands.json', jobs=6, keep_gcc_include_fixed=False, keep_gcc_intrin=False, output_format='plist', makefile=False, compile_uniqueing='none', config_file=None, func=<function main at 0x7faa5aaf5e10>, func_process_config_file=<function process_config_file at 0x7faa5aaf5990>, verbose='debug', ordered_checkers=[('sensitive', True)], output_path='/home/username/reports')
[DEBUG][2023-08-07 17:12:29] {system} [51304] <140369678279040> - analyze.py:991 main() - Output will be stored to: '/home/username/reports'
[DEBUG][2023-08-07 17:12:29] {buildlogger} [51304] <140369678279040> - log_parser.py:1029 parse_options() - Same clang is used for compilation and analysis.
[DEBUG][2023-08-07 17:12:29] {buildlogger} [51304] <140369678279040> - log_parser.py:540 dump_compiler_info() - Writing compiler info into: /home/username/reports/compiler_info.json
[DEBUG][2023-08-07 17:12:29] {buildlogger} [51304] <140369678279040> - log_parser.py:1352 parse_unique_log() - Parsing log file done.
[DEBUG_ANALYZER][2023-08-07 17:12:29] {system} [51304] <140369678279040> - analyze.py:1068 main() - Total number of compile commands without skipping or uniqueing: 1
[DEBUG_ANALYZER][2023-08-07 17:12:29] {system} [51304] <140369678279040> - analyze.py:1070 main() - Compile commands removed by uniqueing: 0
[DEBUG_ANALYZER][2023-08-07 17:12:29] {system} [51304] <140369678279040> - analyze.py:1072 main() - Compile commands skipped during log processing: 0
[DEBUG_ANALYZER][2023-08-07 17:12:29] {system} [51304] <140369678279040> - analyze.py:1074 main() - Compile commands forwarded for analysis: 1
[DEBUG_ANALYZER][2023-08-07 17:12:29] {analyzer} [51304] <140369678279040> - host_check.py:29 check_analyzer() - /usr/bin/clang-16 --version
[DEBUG_ANALYZER][2023-08-07 17:12:29] {analyzer} [51304] <140369678279040> - analyzer.py:584 construct_config_handler() - 'Namespace' object has no attribute 'clangsa_args_cfg_file'
[INFO][2023-08-07 17:12:29] {analyzer} [51304] <140369678279040> - analyzer.py:239 perform_analysis() - Enabled checkers:
clangsa: alpha.core.BoolAssignment, alpha.core.CastSize, alpha.core.Conversion, alpha.core.DynamicTypeChecker, alpha.core.SizeofPtr, alpha.core.TestAfterDivZero, alpha.cplusplus.DeleteWithNonVirtualDtor, alpha.cplusplus.EnumCastOutOfRange, alpha.cplusplus.InvalidatedIterator, alpha.cplusplus.IteratorRange, alpha.cplusplus.MismatchedIterator, alpha.cplusplus.STLAlgorithmModeling, alpha.cplusplus.SmartPtr, alpha.security.MmapWriteExec, alpha.security.ReturnPtrRange, alpha.security.cert.pos.34c, alpha.security.cert.env.InvalidPtr, alpha.security.taint.TaintPropagation, alpha.unix.BlockInCriticalSection, alpha.unix.Chroot, alpha.unix.Errno, alpha.unix.PthreadLock, alpha.unix.Stream, alpha.unix.cstring.NotNullTerminated, alpha.unix.cstring.OutOfBounds, core.CallAndMessage, core.DivideZero, core.NonNullParamChecker, core.NullDereference, core.StackAddressEscape, core.UndefinedBinaryOperatorResult, core.VLASize, core.uninitialized.ArraySubscript, core.uninitialized.Assign, core.uninitialized.Branch, core.uninitialized.CapturedBlockVariable, core.uninitialized.NewArraySize, core.uninitialized.UndefReturn, cplusplus.InnerPointer, cplusplus.Move, cplusplus.NewDelete, cplusplus.NewDeleteLeaks, cplusplus.PlacementNew, cplusplus.PureVirtualCall, cplusplus.StringChecker, deadcode.DeadStores, nullability.NullPassedToNonnull, nullability.NullReturnedFromNonnull, nullability.NullableDereferenced, nullability.NullablePassedToNonnull, nullability.NullableReturnedFromNonnull, optin.cplusplus.UninitializedObject, optin.cplusplus.VirtualCall, optin.mpi.MPI-Checker, optin.portability.UnixAPI, security.FloatLoopCounter, security.insecureAPI.UncheckedReturn, security.insecureAPI.getpw, security.insecureAPI.gets, security.insecureAPI.mkstemp, security.insecureAPI.mktemp, security.insecureAPI.rand, security.insecureAPI.vfork, unix.API, unix.Malloc, unix.MallocSizeof, unix.MismatchedDeallocator, unix.Vfork, unix.cstring.BadSizeArg, unix.cstring.NullArg, valist.CopyToSelf, valist.Uninitialized, valist.Unterminated
[INFO][2023-08-07 17:12:29] {analyzer} [51304] <140369678279040> - analyzer.py:314 perform_analysis() - Starting static analysis ...
[DEBUG_ANALYZER][2023-08-07 17:12:29] {analyzer} [51332] <140369678279040> - analyzer_types.py:211 construct_analyzer() - Constructing clangsa analyzer.
[DEBUG][2023-08-07 17:12:29] {analyzer} [51332] <140369678279040> - analyzer_base.py:94 analyze() - Running analyzer ...
[DEBUG_ANALYZER][2023-08-07 17:12:29] {analyzer} [51332] <140369678279040> - analyzer_base.py:96 analyze() -
/usr/bin/clang-16 --analyze -Qunused-arguments -Xclang -analyzer-opt-analyze-headers -Xclang -analyzer-output=plist-multi-file -o /home/username/reports/test.c_clangsa_bc4e8dc524411f5befab5fb33757f0e2.plist -Xclang -analyzer-config -Xclang expand-macros=true -Xclang -analyzer-checker=alpha.core.BoolAssignment,alpha.core.CastSize,alpha.core.Conversion,alpha.core.DynamicTypeChecker,alpha.core.SizeofPtr,alpha.core.TestAfterDivZero,alpha.cplusplus.DeleteWithNonVirtualDtor,alpha.cplusplus.EnumCastOutOfRange,alpha.cplusplus.InvalidatedIterator,alpha.cplusplus.IteratorRange,alpha.cplusplus.MismatchedIterator,alpha.cplusplus.STLAlgorithmModeling,alpha.cplusplus.SmartPtr,alpha.security.MmapWriteExec,alpha.security.ReturnPtrRange,alpha.security.cert.pos.34c,alpha.security.cert.env.InvalidPtr,alpha.security.taint.TaintPropagation,alpha.unix.BlockInCriticalSection,alpha.unix.Chroot,alpha.unix.Errno,alpha.unix.PthreadLock,alpha.unix.Stream,alpha.unix.cstring.NotNullTerminated,alpha.unix.cstring.OutOfBounds,core.CallAndMessage,core.DivideZero,core.NonNullParamChecker,core.NullDereference,core.StackAddressEscape,core.UndefinedBinaryOperatorResult,core.VLASize,core.uninitialized.ArraySubscript,core.uninitialized.Assign,core.uninitialized.Branch,core.uninitialized.CapturedBlockVariable,core.uninitialized.NewArraySize,core.uninitialized.UndefReturn,cplusplus.InnerPointer,cplusplus.Move,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,cplusplus.PlacementNew,cplusplus.PureVirtualCall,cplusplus.StringChecker,deadcode.DeadStores,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull,nullability.NullableDereferenced,nullability.NullablePassedToNonnull,nullability.NullableReturnedFromNonnull,optin.cplusplus.UninitializedObject,optin.cplusplus.VirtualCall,optin.mpi.MPI-Checker,optin.portability.UnixAPI,security.FloatLoopCounter,security.insecureAPI.UncheckedReturn,security.insecureAPI.getpw,security.insecureAPI.gets,security.insecureAPI.mkstemp,security.insecureAPI.mktemp,security.insecureAPI.rand,security.insecureAPI.vfork,unix.API,unix.Malloc,unix.MallocSizeof,unix.MismatchedDeallocator,unix.Vfork,unix.cstring.BadSizeArg,unix.cstring.NullArg,valist.CopyToSelf,valist.Uninitialized,valist.Unterminated -Xclang -analyzer-config -Xclang aggressive-binary-operation-simplification=true -x 86-speculative-load-hardening -g -mllvm /home/username/test.c
[ERROR][2023-08-07 17:12:29] {analyzer} [51332] <140369678279040> - analysis_manager.py:623 check() - Analyzing test.c with clangsa failed!
[ERROR][2023-08-07 17:12:29] {analyzer} [51332] <140369678279040> - analysis_manager.py:629 check() -
[ERROR][2023-08-07 17:12:29] {analyzer} [51332] <140369678279040> - analysis_manager.py:630 check() -
clang: error: language not recognized: '86-speculative-load-hardening'
clang: error: no input files
[DEBUG][2023-08-07 17:12:29] {analyzer} [51332] <140369678279040> - analysis_manager.py:250 handle_reproducer() - Fetching other dependent files from analyzer output...
[DEBUG][2023-08-07 17:12:29] {analyzer} [51332] <140369678279040> - analysis_manager.py:263 handle_reproducer() - Collecting debug data
[DEBUG][2023-08-07 17:12:29] {analyzer} [51332] <140369678279040> - analysis_manager.py:292 handle_reproducer() - [ZIP] Writing analyzer STDOUT to /stdout
[DEBUG][2023-08-07 17:12:29] {analyzer} [51332] <140369678279040> - analysis_manager.py:295 handle_reproducer() - [ZIP] Writing analyzer STDERR to /stderr
[DEBUG][2023-08-07 17:12:29] {analyzer} [51332] <140369678279040> - analysis_manager.py:298 handle_reproducer() - [ZIP] Writing extra information...
[DEBUG][2023-08-07 17:12:29] {analyzer} [51332] <140369678279040> - analysis_manager.py:315 handle_reproducer() - ZIP file written at '/home/username/reports/failed/test.c_clangsa_bc4e8dc524411f5befab5fb33757f0e2.plist_compile_error.zip'
[ERROR][2023-08-07 17:12:29] {analyzer} [51332] <140369678279040> - analysis_manager.py:679 check() -
[ERROR][2023-08-07 17:12:29] {analyzer} [51332] <140369678279040> - analysis_manager.py:680 check() -
clang: error: language not recognized: '86-speculative-load-hardening'
clang: error: no input files
[INFO][2023-08-07 17:12:29] {analyzer} [51304] <140369622275840> - analysis_manager.py:81 worker_result_handler() - ----==== Summary ====----
[INFO][2023-08-07 17:12:29] {analyzer} [51304] <140369622275840> - analysis_manager.py:53 print_analyzer_statistic_summary() - Failed to analyze
[INFO][2023-08-07 17:12:29] {analyzer} [51304] <140369622275840> - analysis_manager.py:58 print_analyzer_statistic_summary() - clangsa: 1
[INFO][2023-08-07 17:12:29] {analyzer} [51304] <140369678279040> - analysis_manager.py:830 start_workers() - Total analyzed compilation commands: 1
[INFO][2023-08-07 17:12:29] {analyzer} [51304] <140369678279040> - analysis_manager.py:839 start_workers() - ----=================----
[INFO][2023-08-07 17:12:29] {analyzer} [51304] <140369678279040> - analyzer.py:329 perform_analysis() - Analysis finished.
[INFO][2023-08-07 17:12:29] {analyzer} [51304] <140369678279040> - analyzer.py:330 perform_analysis() - To view results in the terminal use the "CodeChecker parse" command.
[INFO][2023-08-07 17:12:29] {analyzer} [51304] <140369678279040> - analyzer.py:332 perform_analysis() - To store results use the "CodeChecker store" command.
[INFO][2023-08-07 17:12:29] {analyzer} [51304] <140369678279040> - analyzer.py:333 perform_analysis() - See --help and the user guide for further options about parsing and storing the reports.
[INFO][2023-08-07 17:12:29] {analyzer} [51304] <140369678279040> - analyzer.py:335 perform_analysis() - ----=================----
[INFO][2023-08-07 17:12:29] {analyzer} [51304] <140369678279040> - analyzer.py:338 perform_analysis() - Analysis length: 0.13069653511047363 sec.
[WARNING][2023-08-07 17:12:29] {analyzer} [51304] <140369678279040> - analyzer_types.py:114 print_unsupported_analyzers() - Analyzer 'cppcheck' is enabled but CodeChecker is failed to execute analysis with it: 'Failed to detect analyzer binary!'. Please check your 'PATH' environment variable and the 'config/package_layout.json' file!
[WARNING][2023-08-07 17:12:29] {analyzer} [51304] <140369678279040> - analyzer_types.py:114 print_unsupported_analyzers() - Analyzer 'clang-tidy' is enabled but CodeChecker is failed to execute analysis with it: 'Failed to detect analyzer binary!'. Please check your 'PATH' environment variable and the 'config/package_layout.json' file!
[DEBUG][2023-08-07 17:12:29] {system} [51304] <140369678279040> - analyze.py:1082 main() - Cleanup metadata file started.
[DEBUG][2023-08-07 17:12:29] {system} [51304] <140369678279040> - analyze.py:1084 main() - Cleanup metadata file finished.
[DEBUG][2023-08-07 17:12:29] {system} [51304] <140369678279040> - analyze.py:1086 main() - Analysis metadata write to '/home/username/reports/metadata.json'
[DEBUG][2023-08-07 17:12:29] {system} [51304] <140369678279040> - analyze.py:1103 main() - Failed to send analyzer statistics!
As the output shows, the analyzer command is clang ... -x 86-speculative-load-hardening -g -mllvm /home/username/test.c.