Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing the final compatibility issues #338

Merged
merged 18 commits into from
Aug 15, 2023

Conversation

lcartey
Copy link
Collaborator

@lcartey lcartey commented Aug 2, 2023

Description

Address the remaining compiler compatibility issues identified by our integration testing.

Summary of notable commits:

  • 3e2f72b & 25bc94d - Fix stubs for string, string.h and cstring
    • This fixes the stubs to be compatible (although not complete) with the C++ standard for those headers. Notably our tests, and therefore our stubs, assumed that C string functionality was accessible via #include <string>, and C++ string functionality was accessible via #include "string.h". All these issues have been addressed.
    • Fixes compiler compatibility issues for: A12-0-2, A27-0-2, M16-0-5, M18-0-5, DCL55-CPP, EXP62-CPP, OOP57-CPP, STR50-CPP.
  • 446ebfe & 7e49686 & a1bf303- Improve smart pointer modelling
    • In practice many standard libraries use a series of smart pointer base classes. Our queries assumed that various smart pointer functions were directly declared on the smart pointer classes themselves, and made some assumptions about the type of flow we see through smart pointers. Stubs, queries and tests have been updated to correct this issue.
    • Fixes compiler compatibility issues for: A8-4-13, A18-1-4, A20-8-1, MEM56-CPP.
  • a1bf303 - Improve data flow summaries for smart pointers
    • Our compiler testing framework showed that these queries were including flow steps in-and-out of the standard library. This commit changes the dataflow to provide summaries for these steps, then excludes the flow into the library for more stable results.
    • Fixes compiler compatibility issues for: A20-8-1, MEM56-CPP.
  • 089397a - Improve std::string::replace modelling
    • std::string on many standard libraries uses an internal typedef __const_iterator instead of the standard specified const_iterator, and this was preventing us from identifying calls to replace.
    • Fixes compiler compatibility issue for: STR51-CPP.
  • 1f9a3b4 - improve modelling of operator delete.
    • A15-5-1 is updated to determine noexcept status of the definition of a function only, and the alert message is updated to provide clarity on what is reported.
    • Fixes compiler compatibility issue for: A15-5-1.
  • e70089f - remove invalid attribute from test cases.
    • Fixes compiler compatibility issue for: A18-5-5, A18-5-6.
  • eb95419 & f283a38- update mutex stub header to better reflect real C++ libraries
    • Remove destructor for mutex and provide definitions for lock_guard constructor/destructor to match gcc/clang.
    • Fixup test cases and query for PreventDeadlockByLockingInPredefinedOrder based on these changes.
    • Fixes compiler compatibility issue for: CON50-CPP.
  • 6aaf0ee - exclude unnecessary flow steps outside source location.
    • Only consider exceptions thrown in constructors written by the user.
    • Fixes compiler compatibility issue for: A15-2-2.
  • 14e4193 - accept test results for useless include query.
    • In gcc/clang the implementation of the libraries often share a common import. In this case, the declaration of v transitively uses std::size_t, and #include <algorithm> transitively includes the file that defines std::size_t. To detect such cases we would need to report redundant includes e.g. includes for which useful symbols are provided, but which are made unnecessary by other imports in the file. For now we simply accept the results.
    • Fixes compiler compatibility issue for: A16-2-2.

Change request type

  • Release or process automation (GitHub workflows, internal scripts)
  • Internal documentation
  • External documentation
  • Query files (.ql, .qll, .qls or unit tests)
  • External scripts (analysis report or other code shipped as part of a release)

Rules with added or modified queries

  • No rules added
  • Queries have been added for the following rules:
    • rule number here
  • Queries have been modified for the following rules:
    • A12-0-2, A27-0-2, M16-0-5, M18-0-5, DCL55-CPP, EXP62-CPP, OOP57-CPP, STR50-CPP,A8-4-13, A18-1-4, A20-8-1, MEM56-CPP, A20-8-1, STR51-CPP, A15-5-1, A18-5-5, A18-5-6, CON50-CPP, A15-2-2, A16-2-2

Release change checklist

A change note (development_handbook.md#change-notes) is required for any pull request which modifies:

  • The structure or layout of the release artifacts.
  • The evaluation performance (memory, execution time) of an existing query.
  • The results of an existing query in any circumstance.

If you are only adding new rule queries, a change note is not required.

Author: Is a change note required?

  • Yes
  • No

🚨🚨🚨
Reviewer: Confirm that format of shared queries (not the .qll file, the
.ql file that imports it) is valid by running them within VS Code.

  • Confirmed

Reviewer: Confirm that either a change note is not required or the change note is required and has been added.

  • Confirmed

Query development review checklist

For PRs that add new queries or modify existing queries, the following checklist should be completed by both the author and reviewer:

Author

  • Have all the relevant rule package description files been checked in?
  • Have you verified that the metadata properties of each new query is set appropriately?
  • Do all the unit tests contain both "COMPLIANT" and "NON_COMPLIANT" cases?
  • Are the alert messages properly formatted and consistent with the style guide?
  • Have you run the queries on OpenPilot and verified that the performance and results are acceptable?
    As a rule of thumb, predicates specific to the query should take no more than 1 minute, and for simple queries be under 10 seconds. If this is not the case, this should be highlighted and agreed in the code review process.
  • Does the query have an appropriate level of in-query comments/documentation?
  • Have you considered/identified possible edge cases?
  • Does the query not reinvent features in the standard library?
  • Can the query be simplified further (not golfed!)

Reviewer

  • Have all the relevant rule package description files been checked in?
  • Have you verified that the metadata properties of each new query is set appropriately?
  • Do all the unit tests contain both "COMPLIANT" and "NON_COMPLIANT" cases?
  • Are the alert messages properly formatted and consistent with the style guide?
  • Have you run the queries on OpenPilot and verified that the performance and results are acceptable?
    As a rule of thumb, predicates specific to the query should take no more than 1 minute, and for simple queries be under 10 seconds. If this is not the case, this should be highlighted and agreed in the code review process.
  • Does the query have an appropriate level of in-query comments/documentation?
  • Have you considered/identified possible edge cases?
  • Does the query not reinvent features in the standard library?
  • Can the query be simplified further (not golfed!)

lcartey and others added 16 commits August 1, 2023 21:21
This should have no impact on tests, but addresses an incompatibility with
the standard library structure.
This commit restructures the string, string.h and cstring headers to match the
expected headers and namespaces of C++ standard declarations. This addresses
compatibility issues with real compilers because our test cases expected to
access C string functionality through the "#include <string>" header include,
which is not the case in practice.

This commit addresses compiler compatibility issues in the following rules:
 * A12-0-2
 * A27-0-2
 * M16-0-5
 * M18-0-5
 * DCL55-CPP
 * EXP62-CPP
 * OOP57-CPP
 * STR50-CPP
clang also supports -w for disabling all options.

clang/A1-1-2 was not on the list of open issues, but gcc/A1-1-2 was - I think
this is an error in the matrix testing.
Fix false positives identified by compiler compatibility testing on gcc/clang,
which identified that shared_ptr used a hidden base class in real compilers
causing our detection of modifying function calls to fail. This has been
addressed, with a bonus modification to more accurately represent which
pointer/reference types are captured.
reset() is sometimes declared on a base class. Similar issue to A8-4-13, so I
have refactored the SmartPointer class to provide predicates which identify
the operations across multiple compilers.
Fix false negative issues related to the library structure of smart pointers.

This commit makes the following changes:
 * Update `memory` stubs to move more functions to the __shared_ptr base class
 * Add dataflow summaries for smart pointer constructor calls and smart
   pointer get calls.
 * Add sanitizers to prevent flow into library code for the dataflow summaries
   added above.
The std::string::replace function uses an internal typedef __const_iterator in
libstdc++, instead of the const_iterator typedef.
Mark ~mutex() as deleted, as that is what we see in real libraries.

Also modify lock_guard. This didn't have any affect on the test, but retained
to ensure we better reflect real compilers.
This query included some spurious edges for results that are outside the
source location. We now exclude constructors outside the source archive
to avoid these spurious edges, and make the result more stable.
Our useless include query is looking for includes where nothing from the
included file is used by the including file. In this case, the declaration of
v transitively uses std::size_t, and `#include <algorithm>` transitively
includes the file that defines std::size_t. To detect such cases we would need
to report redundant includes e.g. includes for which useful symbols are
provided, but which are made unnecessary by other imports in the file.

For now we just exclude these expected results, as modifying the query is
tricky. Furthermore, the intention of the rule is actually that we check
standard library includes against the list of symbols as per the standard
library, but again this is challenging.
Fix for `PreventDeadlockByLockingInPredefinedOrder`
@lcartey lcartey changed the title (DRAFT) Fixing the final compatibility issues Fixing the final compatibility issues Aug 10, 2023
@lcartey lcartey marked this pull request as ready for review August 10, 2023 22:36
@lcartey
Copy link
Collaborator Author

lcartey commented Aug 10, 2023

/test-matrix

@lcartey
Copy link
Collaborator Author

lcartey commented Aug 10, 2023

/test-performance

@github-actions
Copy link

🤖 Beep Boop! Matrix Testing for this PR has been initiated. Please check back later for results.

💡 If you do not hear back from me please check my status! I will report even if this PR does not contain files eligible for matrix testing.

@github-actions
Copy link

🏁 Beep Boop! Performance testing for this PR has been initiated. Please check back later for results. Note that the query package generation step must complete before testing will start so it might be a minute.

💡 If you do not hear back from me please check my status! I will report even if I fail!

@jsinglet
Copy link
Contributor

🤖 Beep Boop! qcc/cpp/AARCH64LE Matrix Testing for this PR won't happen because it is outside of license window!

@jsinglet
Copy link
Contributor

🤖 Beep Boop! qcc/c/AARCH64LE Matrix Testing for this PR won't happen because it is outside of license window!

@jsinglet
Copy link
Contributor

🤖 Beep Boop! gcc/c/X86_64 Matrix Testing for this PR has been completed but I didn't find anything to test!

@jsinglet
Copy link
Contributor

🤖 Beep Boop! clang/c/X86_64 Matrix Testing for this PR has been completed but I didn't find anything to test!

@jsinglet
Copy link
Contributor

🤖 Beep Boop! clang/cpp/X86_64 Matrix Testing for this PR has been completed. See below for the results!


QUERY                : ConstructorErrorLeavesObjectInInvalidState
COMPILE_PASS         : True
RULE                 : A15-2-2
TEST_PASS            : True
SUITE                : AUTOSAR
PACKAGE              : Exceptions2
TEST_DIFFERENCE      : 
COMPILE_ERROR_OUTPUT : 

QUERY                : SpecialFunctionMissingNoExceptSpecification
COMPILE_PASS         : True
RULE                 : A15-5-1
TEST_PASS            : True
SUITE                : AUTOSAR
PACKAGE              : Exceptions2
TEST_DIFFERENCE      : 
COMPILE_ERROR_OUTPUT : 

QUERY                : SpecialFunctionExitsWithException
COMPILE_PASS         : True
RULE                 : A15-5-1
TEST_PASS            : True
SUITE                : AUTOSAR
PACKAGE              : Exceptions2
TEST_DIFFERENCE      : 
COMPILE_ERROR_OUTPUT : 

QUERY                : PointerToAnElementOfAnArrayPassedToASmartPointer
COMPILE_PASS         : True
RULE                 : A18-1-4
TEST_PASS            : False
SUITE                : AUTOSAR
PACKAGE              : Pointers
TEST_DIFFERENCE      : --- expected
                       +++ actual
                       @@ -1,18 +1,26 @@
                        edges
                       +| file:///usr/include/c++/9/bits/unique_ptr.h:640:7:640:7 | this | file:///usr/include/c++/9/bits/unique_ptr.h:644:9:644:11 | __p |
                        | test.cpp:3:36:3:45 | new[] | test.cpp:19:27:19:44 | call to allocate_int_array |
                        | test.cpp:3:36:3:45 | new[] | test.cpp:23:12:23:29 | call to allocate_int_array |
                        | test.cpp:3:36:3:45 | new[] | test.cpp:27:20:27:37 | call to allocate_int_array |
                       +| test.cpp:11:29:11:41 | call to unique_ptr | test.cpp:12:27:12:28 | v2 |
                        | test.cpp:11:29:11:41 | call to unique_ptr | test.cpp:12:30:12:36 | call to release |
                       +| test.cpp:12:27:12:28 | v2 | file:///usr/include/c++/9/bits/unique_ptr.h:640:7:640:7 | this |
                       +| test.cpp:12:27:12:28 | v2 | test.cpp:12:30:12:36 | call to release |
                        | test.cpp:27:20:27:37 | call to allocate_int_array | test.cpp:32:12:32:20 | int_array |
                        nodes
                       +| file:///usr/include/c++/9/bits/unique_ptr.h:640:7:640:7 | this | semmle.label | this |
                       +| file:///usr/include/c++/9/bits/unique_ptr.h:644:9:644:11 | __p | semmle.label | __p |
                        | test.cpp:3:36:3:45 | new[] | semmle.label | new[] |
                        | test.cpp:11:29:11:41 | call to unique_ptr | semmle.label | call to unique_ptr |
                       +| test.cpp:12:27:12:28 | v2 | semmle.label | v2 |
                        | test.cpp:12:30:12:36 | call to release | semmle.label | call to release |
                        | test.cpp:19:27:19:44 | call to allocate_int_array | semmle.label | call to allocate_int_array |
                        | test.cpp:23:12:23:29 | call to allocate_int_array | semmle.label | call to allocate_int_array |
                        | test.cpp:27:20:27:37 | call to allocate_int_array | semmle.label | call to allocate_int_array |
                        | test.cpp:32:12:32:20 | int_array | semmle.label | int_array |
                        subpaths
                       +| test.cpp:12:27:12:28 | v2 | file:///usr/include/c++/9/bits/unique_ptr.h:640:7:640:7 | this | file:///usr/include/c++/9/bits/unique_ptr.h:644:9:644:11 | __p | test.cpp:12:30:12:36 | call to release |
                        #select
                        | test.cpp:12:30:12:36 | call to release | test.cpp:11:29:11:41 | call to unique_ptr | test.cpp:12:30:12:36 | call to release | A pointer to an element of an array of objects flows to a smart pointer of a single object type. |
                        | test.cpp:19:27:19:44 | call to allocate_int_array | test.cpp:3:36:3:45 | new[] | test.cpp:19:27:19:44 | call to allocate_int_array | A pointer to an element of an array of objects flows to a smart pointer of a single object type. |
                       [1/1 comp 39.2s eval 3.1s] FAILED(RESULT) /__w/codeql-coding-standards-release-engineering/codeql-coding-standards-release-engineering/codeql-coding-standards/cpp/autosar/test/rules/A18-1-4/PointerToAnElementOfAnArrayPassedToASmartPointer.qlref
                       
COMPILE_ERROR_OUTPUT : 

QUERY                : SharedPtrPassedToFunctionWithImproperSemantics
COMPILE_PASS         : True
RULE                 : A8-4-13
TEST_PASS            : True
SUITE                : AUTOSAR
PACKAGE              : SmartPointers1
TEST_DIFFERENCE      : 
COMPILE_ERROR_OUTPUT : 

QUERY                : OperationsAssumingMemoryLayoutPerformedOnObjects
COMPILE_PASS         : True
RULE                 : A12-0-2
TEST_PASS            : True
SUITE                : AUTOSAR
PACKAGE              : Expressions
TEST_DIFFERENCE      : 
COMPILE_ERROR_OUTPUT : 

QUERY                : UnusedIncludeDirectives
COMPILE_PASS         : True
RULE                 : A16-2-2
TEST_PASS            : True
SUITE                : AUTOSAR
PACKAGE              : Includes
TEST_DIFFERENCE      : 
COMPILE_ERROR_OUTPUT : 

QUERY                : MemoryManagementFunctionInvariants
COMPILE_PASS         : True
RULE                 : A18-5-5
TEST_PASS            : True
SUITE                : AUTOSAR
PACKAGE              : Invariants
TEST_DIFFERENCE      : 
COMPILE_ERROR_OUTPUT : 

QUERY                : DynamicMemoryManagementFailureMode
COMPILE_PASS         : True
RULE                 : A18-5-6
TEST_PASS            : True
SUITE                : AUTOSAR
PACKAGE              : Allocations
TEST_DIFFERENCE      : 
COMPILE_ERROR_OUTPUT : 

QUERY                : UnboundedFunctionsOfLibraryCstringUsed
COMPILE_PASS         : True
RULE                 : M18-0-5
TEST_PASS            : True
SUITE                : AUTOSAR
PACKAGE              : BannedFunctions
TEST_DIFFERENCE      : 
COMPILE_ERROR_OUTPUT : 

QUERY                : MemcpyUsedToAccessObjectRepresentation
COMPILE_PASS         : True
RULE                 : EXP62-CPP
TEST_PASS            : True
SUITE                : CERT-C++
PACKAGE              : Representation
TEST_DIFFERENCE      : 
COMPILE_ERROR_OUTPUT : 

QUERY                : MemcmpUsedToAccessObjectRepresentation
COMPILE_PASS         : True
RULE                 : EXP62-CPP
TEST_PASS            : True
SUITE                : CERT-C++
PACKAGE              : Representation
TEST_DIFFERENCE      : 
COMPILE_ERROR_OUTPUT : 

QUERY                : MemsetUsedToAccessObjectRepresentation
COMPILE_PASS         : True
RULE                 : EXP62-CPP
TEST_PASS            : True
SUITE                : CERT-C++
PACKAGE              : Representation
TEST_DIFFERENCE      : 
COMPILE_ERROR_OUTPUT : 

QUERY                : PreferSpecialMemberFunctionsAndOverloadedOperatorsToCStandardLibraryFunctions
COMPILE_PASS         : True
RULE                 : OOP57-CPP
TEST_PASS            : True
SUITE                : CERT-C++
PACKAGE              : BannedFunctions
TEST_DIFFERENCE      : 
COMPILE_ERROR_OUTPUT : 

QUERY                : OperationMayNotNullTerminateCStyleStringCert
COMPILE_PASS         : True
RULE                 : STR50-CPP
TEST_PASS            : True
SUITE                : CERT-C++
PACKAGE              : Strings
TEST_DIFFERENCE      : 
COMPILE_ERROR_OUTPUT : 

QUERY                : BasicStringMayNotBeNullTerminatedCert
COMPILE_PASS         : True
RULE                 : STR50-CPP
TEST_PASS            : True
SUITE                : CERT-C++
PACKAGE              : Strings
TEST_DIFFERENCE      : 
COMPILE_ERROR_OUTPUT : 

QUERY                : OperationMayNotNullTerminateCStyleStringAutosar
COMPILE_PASS         : True
RULE                 : A27-0-2
TEST_PASS            : True
SUITE                : AUTOSAR
PACKAGE              : Strings
TEST_DIFFERENCE      : 
COMPILE_ERROR_OUTPUT : 

QUERY                : BasicStringMayNotBeNullTerminatedAutosar
COMPILE_PASS         : True
RULE                 : A27-0-2
TEST_PASS            : True
SUITE                : AUTOSAR
PACKAGE              : Strings
TEST_DIFFERENCE      : 
COMPILE_ERROR_OUTPUT : 

QUERY                : DoNotDestroyAMutexWhileItIsLocked
COMPILE_PASS         : True
RULE                 : CON50-CPP
TEST_PASS            : True
SUITE                : CERT-C++
PACKAGE              : Concurrency
TEST_DIFFERENCE      : 
COMPILE_ERROR_OUTPUT : 

QUERY                : DoNotAllowAMutexToGoOutOfScopeWhileLocked
COMPILE_PASS         : True
RULE                 : CON50-CPP
TEST_PASS            : True
SUITE                : CERT-C++
PACKAGE              : Concurrency
TEST_DIFFERENCE      : 
COMPILE_ERROR_OUTPUT : 

QUERY                : InformationLeakageAcrossTrustBoundaries
COMPILE_PASS         : True
RULE                 : DCL55-CPP
TEST_PASS            : True
SUITE                : CERT-C++
PACKAGE              : Uninitialized
TEST_DIFFERENCE      : 
COMPILE_ERROR_OUTPUT : 

QUERY                : OwnedPointerValueStoredInUnrelatedSmartPointerCert
COMPILE_PASS         : True
RULE                 : MEM56-CPP
TEST_PASS            : True
SUITE                : CERT-C++
PACKAGE              : SmartPointers2
TEST_DIFFERENCE      : 
COMPILE_ERROR_OUTPUT : 

QUERY                : OwnedPointerValueStoredInUnrelatedSmartPointerAsar
COMPILE_PASS         : True
RULE                 : A20-8-1
TEST_PASS            : True
SUITE                : AUTOSAR
PACKAGE              : SmartPointers1
TEST_DIFFERENCE      : 
COMPILE_ERROR_OUTPUT : 

QUERY                : FunctionLikeMacroArgsContainHashToken
COMPILE_PASS         : True
RULE                 : M16-0-5
TEST_PASS            : True
SUITE                : AUTOSAR
PACKAGE              : Macros
TEST_DIFFERENCE      : 
COMPILE_ERROR_OUTPUT : 


@jsinglet
Copy link
Contributor

🤖 Beep Boop! gcc/cpp/X86_64 Matrix Testing for this PR has been completed. See below for the results!


SUITE                : AUTOSAR
TEST_PASS            : True
COMPILE_ERROR_OUTPUT : 
COMPILE_PASS         : True
QUERY                : ConstructorErrorLeavesObjectInInvalidState
RULE                 : A15-2-2
PACKAGE              : Exceptions2
TEST_DIFFERENCE      : 

SUITE                : AUTOSAR
TEST_PASS            : True
COMPILE_ERROR_OUTPUT : 
COMPILE_PASS         : True
QUERY                : SpecialFunctionMissingNoExceptSpecification
RULE                 : A15-5-1
PACKAGE              : Exceptions2
TEST_DIFFERENCE      : 

SUITE                : AUTOSAR
TEST_PASS            : True
COMPILE_ERROR_OUTPUT : 
COMPILE_PASS         : True
QUERY                : SpecialFunctionExitsWithException
RULE                 : A15-5-1
PACKAGE              : Exceptions2
TEST_DIFFERENCE      : 

SUITE                : AUTOSAR
TEST_PASS            : False
COMPILE_ERROR_OUTPUT : 
COMPILE_PASS         : True
QUERY                : PointerToAnElementOfAnArrayPassedToASmartPointer
RULE                 : A18-1-4
PACKAGE              : Pointers
TEST_DIFFERENCE      : --- expected
                       +++ actual
                       @@ -1,18 +1,26 @@
                        edges
                       +| file:///usr/include/c++/8/bits/unique_ptr.h:618:7:618:7 | this | file:///usr/include/c++/8/bits/unique_ptr.h:622:9:622:11 | __p |
                        | test.cpp:3:36:3:45 | new[] | test.cpp:19:27:19:44 | call to allocate_int_array |
                        | test.cpp:3:36:3:45 | new[] | test.cpp:23:12:23:29 | call to allocate_int_array |
                        | test.cpp:3:36:3:45 | new[] | test.cpp:27:20:27:37 | call to allocate_int_array |
                       +| test.cpp:11:29:11:41 | call to unique_ptr | test.cpp:12:27:12:28 | v2 |
                        | test.cpp:11:29:11:41 | call to unique_ptr | test.cpp:12:30:12:36 | call to release |
                       +| test.cpp:12:27:12:28 | v2 | file:///usr/include/c++/8/bits/unique_ptr.h:618:7:618:7 | this |
                       +| test.cpp:12:27:12:28 | v2 | test.cpp:12:30:12:36 | call to release |
                        | test.cpp:27:20:27:37 | call to allocate_int_array | test.cpp:32:12:32:20 | int_array |
                        nodes
                       +| file:///usr/include/c++/8/bits/unique_ptr.h:618:7:618:7 | this | semmle.label | this |
                       +| file:///usr/include/c++/8/bits/unique_ptr.h:622:9:622:11 | __p | semmle.label | __p |
                        | test.cpp:3:36:3:45 | new[] | semmle.label | new[] |
                        | test.cpp:11:29:11:41 | call to unique_ptr | semmle.label | call to unique_ptr |
                       +| test.cpp:12:27:12:28 | v2 | semmle.label | v2 |
                        | test.cpp:12:30:12:36 | call to release | semmle.label | call to release |
                        | test.cpp:19:27:19:44 | call to allocate_int_array | semmle.label | call to allocate_int_array |
                        | test.cpp:23:12:23:29 | call to allocate_int_array | semmle.label | call to allocate_int_array |
                        | test.cpp:27:20:27:37 | call to allocate_int_array | semmle.label | call to allocate_int_array |
                        | test.cpp:32:12:32:20 | int_array | semmle.label | int_array |
                        subpaths
                       +| test.cpp:12:27:12:28 | v2 | file:///usr/include/c++/8/bits/unique_ptr.h:618:7:618:7 | this | file:///usr/include/c++/8/bits/unique_ptr.h:622:9:622:11 | __p | test.cpp:12:30:12:36 | call to release |
                        #select
                        | test.cpp:12:30:12:36 | call to release | test.cpp:11:29:11:41 | call to unique_ptr | test.cpp:12:30:12:36 | call to release | A pointer to an element of an array of objects flows to a smart pointer of a single object type. |
                        | test.cpp:19:27:19:44 | call to allocate_int_array | test.cpp:3:36:3:45 | new[] | test.cpp:19:27:19:44 | call to allocate_int_array | A pointer to an element of an array of objects flows to a smart pointer of a single object type. |
                       [1/1 comp 40.4s eval 3.1s] FAILED(RESULT) /__w/codeql-coding-standards-release-engineering/codeql-coding-standards-release-engineering/codeql-coding-standards/cpp/autosar/test/rules/A18-1-4/PointerToAnElementOfAnArrayPassedToASmartPointer.qlref
                       

SUITE                : AUTOSAR
TEST_PASS            : True
COMPILE_ERROR_OUTPUT : 
COMPILE_PASS         : True
QUERY                : SharedPtrPassedToFunctionWithImproperSemantics
RULE                 : A8-4-13
PACKAGE              : SmartPointers1
TEST_DIFFERENCE      : 

SUITE                : AUTOSAR
TEST_PASS            : True
COMPILE_ERROR_OUTPUT : 
COMPILE_PASS         : True
QUERY                : OperationsAssumingMemoryLayoutPerformedOnObjects
RULE                 : A12-0-2
PACKAGE              : Expressions
TEST_DIFFERENCE      : 

SUITE                : AUTOSAR
TEST_PASS            : True
COMPILE_ERROR_OUTPUT : 
COMPILE_PASS         : True
QUERY                : UnusedIncludeDirectives
RULE                 : A16-2-2
PACKAGE              : Includes
TEST_DIFFERENCE      : 

SUITE                : AUTOSAR
TEST_PASS            : True
COMPILE_ERROR_OUTPUT : 
COMPILE_PASS         : True
QUERY                : MemoryManagementFunctionInvariants
RULE                 : A18-5-5
PACKAGE              : Invariants
TEST_DIFFERENCE      : 

SUITE                : AUTOSAR
TEST_PASS            : True
COMPILE_ERROR_OUTPUT : 
COMPILE_PASS         : True
QUERY                : DynamicMemoryManagementFailureMode
RULE                 : A18-5-6
PACKAGE              : Allocations
TEST_DIFFERENCE      : 

SUITE                : AUTOSAR
TEST_PASS            : True
COMPILE_ERROR_OUTPUT : 
COMPILE_PASS         : True
QUERY                : UnboundedFunctionsOfLibraryCstringUsed
RULE                 : M18-0-5
PACKAGE              : BannedFunctions
TEST_DIFFERENCE      : 

SUITE                : CERT-C++
TEST_PASS            : True
COMPILE_ERROR_OUTPUT : 
COMPILE_PASS         : True
QUERY                : MemcmpUsedToAccessObjectRepresentation
RULE                 : EXP62-CPP
PACKAGE              : Representation
TEST_DIFFERENCE      : 

SUITE                : CERT-C++
TEST_PASS            : True
COMPILE_ERROR_OUTPUT : 
COMPILE_PASS         : True
QUERY                : MemsetUsedToAccessObjectRepresentation
RULE                 : EXP62-CPP
PACKAGE              : Representation
TEST_DIFFERENCE      : 

SUITE                : CERT-C++
TEST_PASS            : True
COMPILE_ERROR_OUTPUT : 
COMPILE_PASS         : True
QUERY                : MemcpyUsedToAccessObjectRepresentation
RULE                 : EXP62-CPP
PACKAGE              : Representation
TEST_DIFFERENCE      : 

SUITE                : CERT-C++
TEST_PASS            : True
COMPILE_ERROR_OUTPUT : 
COMPILE_PASS         : True
QUERY                : PreferSpecialMemberFunctionsAndOverloadedOperatorsToCStandardLibraryFunctions
RULE                 : OOP57-CPP
PACKAGE              : BannedFunctions
TEST_DIFFERENCE      : 

SUITE                : CERT-C++
TEST_PASS            : True
COMPILE_ERROR_OUTPUT : 
COMPILE_PASS         : True
QUERY                : OperationMayNotNullTerminateCStyleStringCert
RULE                 : STR50-CPP
PACKAGE              : Strings
TEST_DIFFERENCE      : 

SUITE                : CERT-C++
TEST_PASS            : True
COMPILE_ERROR_OUTPUT : 
COMPILE_PASS         : True
QUERY                : BasicStringMayNotBeNullTerminatedCert
RULE                 : STR50-CPP
PACKAGE              : Strings
TEST_DIFFERENCE      : 

SUITE                : AUTOSAR
TEST_PASS            : True
COMPILE_ERROR_OUTPUT : 
COMPILE_PASS         : True
QUERY                : OperationMayNotNullTerminateCStyleStringAutosar
RULE                 : A27-0-2
PACKAGE              : Strings
TEST_DIFFERENCE      : 

SUITE                : AUTOSAR
TEST_PASS            : True
COMPILE_ERROR_OUTPUT : 
COMPILE_PASS         : True
QUERY                : BasicStringMayNotBeNullTerminatedAutosar
RULE                 : A27-0-2
PACKAGE              : Strings
TEST_DIFFERENCE      : 

SUITE                : CERT-C++
TEST_PASS            : True
COMPILE_ERROR_OUTPUT : 
COMPILE_PASS         : True
QUERY                : DoNotAllowAMutexToGoOutOfScopeWhileLocked
RULE                 : CON50-CPP
PACKAGE              : Concurrency
TEST_DIFFERENCE      : 

SUITE                : CERT-C++
TEST_PASS            : True
COMPILE_ERROR_OUTPUT : 
COMPILE_PASS         : True
QUERY                : DoNotDestroyAMutexWhileItIsLocked
RULE                 : CON50-CPP
PACKAGE              : Concurrency
TEST_DIFFERENCE      : 

SUITE                : CERT-C++
TEST_PASS            : True
COMPILE_ERROR_OUTPUT : 
COMPILE_PASS         : True
QUERY                : InformationLeakageAcrossTrustBoundaries
RULE                 : DCL55-CPP
PACKAGE              : Uninitialized
TEST_DIFFERENCE      : 

SUITE                : CERT-C++
TEST_PASS            : True
COMPILE_ERROR_OUTPUT : 
COMPILE_PASS         : True
QUERY                : OwnedPointerValueStoredInUnrelatedSmartPointerCert
RULE                 : MEM56-CPP
PACKAGE              : SmartPointers2
TEST_DIFFERENCE      : 

SUITE                : AUTOSAR
TEST_PASS            : True
COMPILE_ERROR_OUTPUT : 
COMPILE_PASS         : True
QUERY                : OwnedPointerValueStoredInUnrelatedSmartPointerAsar
RULE                 : A20-8-1
PACKAGE              : SmartPointers1
TEST_DIFFERENCE      : 

SUITE                : AUTOSAR
TEST_PASS            : True
COMPILE_ERROR_OUTPUT : 
COMPILE_PASS         : True
QUERY                : FunctionLikeMacroArgsContainHashToken
RULE                 : M16-0-5
PACKAGE              : Macros
TEST_DIFFERENCE      : 


@jsinglet
Copy link
Contributor

🤖 Beep Boop! Matrix Testing for this PR has been completed. If no reports were posted it means this PR does not contain things that need matrix testing!

@jsinglet
Copy link
Contributor

🏁 Beep Boop! Performance testing complete! See below for performance of the last 3 runs vs your PR. Times are based on predicate performance. You can find full graphs and stats in the PR that was created for this test in the release engineering repo.


Release                            : v2.20.0
Platform                           : x86-linux
Language                           : c
Total_Serialized_Execution_Time_Ms : 2983369
Mean_Predicate_Execution_Time_Ms   : 80.49019290435722
Median_Predicate_Execution_Time_Ms : 1.0
Standard_Deviation_Ms              : 812.7769764280572
Total_Serialized_Execution_Time_s  : 2983.369
Mean_Query_Execution_Time_s        : 0.0804901929043572
Median_Predicate_Execution_Time_s  : 0.001
Percentile95_Ms                    : 183.0
Number_of_Predicates               : 37065

Release                            : v2.20.0
Platform                           : x86-linux
Language                           : cpp
Total_Serialized_Execution_Time_Ms : 3271097
Mean_Predicate_Execution_Time_Ms   : 79.19756434157325
Median_Predicate_Execution_Time_Ms : 1.0
Standard_Deviation_Ms              : 1216.7021436787627
Total_Serialized_Execution_Time_s  : 3271.097
Mean_Query_Execution_Time_s        : 0.0791975643415732
Median_Predicate_Execution_Time_s  : 0.001
Percentile95_Ms                    : 156.0
Number_of_Predicates               : 41303

Release                            : v2.20.0
Platform                           : x86-windows
Language                           : c
Total_Serialized_Execution_Time_Ms : 3323606
Mean_Predicate_Execution_Time_Ms   : 89.50063282617477
Median_Predicate_Execution_Time_Ms : 2.0
Standard_Deviation_Ms              : 885.803234847289
Total_Serialized_Execution_Time_s  : 3323.606
Mean_Query_Execution_Time_s        : 0.0895006328261747
Median_Predicate_Execution_Time_s  : 0.002
Percentile95_Ms                    : 206.29999999999563
Number_of_Predicates               : 37135

Release                            : v2.20.0
Platform                           : x86-windows
Language                           : cpp
Total_Serialized_Execution_Time_Ms : 3698496
Mean_Predicate_Execution_Time_Ms   : 90.41009093575828
Median_Predicate_Execution_Time_Ms : 2.0
Standard_Deviation_Ms              : 1369.993033711765
Total_Serialized_Execution_Time_s  : 3698.496
Mean_Query_Execution_Time_s        : 0.0904100909357582
Median_Predicate_Execution_Time_s  : 0.002
Percentile95_Ms                    : 183.0
Number_of_Predicates               : 40908

Release                            : v2.21.0
Platform                           : x86-windows
Language                           : c
Total_Serialized_Execution_Time_Ms : 3343159
Mean_Predicate_Execution_Time_Ms   : 90.05384656825773
Median_Predicate_Execution_Time_Ms : 2.0
Standard_Deviation_Ms              : 895.0686158000931
Total_Serialized_Execution_Time_s  : 3343.159
Mean_Query_Execution_Time_s        : 0.0900538465682577
Median_Predicate_Execution_Time_s  : 0.002
Percentile95_Ms                    : 208.0
Number_of_Predicates               : 37124

Release                            : v2.21.0
Platform                           : x86-linux
Language                           : c
Total_Serialized_Execution_Time_Ms : 2958950
Mean_Predicate_Execution_Time_Ms   : 80.16010619564923
Median_Predicate_Execution_Time_Ms : 1.0
Standard_Deviation_Ms              : 793.7839873192156
Total_Serialized_Execution_Time_s  : 2958.95
Mean_Query_Execution_Time_s        : 0.0801601061956492
Median_Predicate_Execution_Time_s  : 0.001
Percentile95_Ms                    : 189.0
Number_of_Predicates               : 36913

Release                            : v2.21.0
Platform                           : x86-linux
Language                           : cpp
Total_Serialized_Execution_Time_Ms : 3230480
Mean_Predicate_Execution_Time_Ms   : 78.4916296134315
Median_Predicate_Execution_Time_Ms : 1.0
Standard_Deviation_Ms              : 1199.1949622346183
Total_Serialized_Execution_Time_s  : 3230.48
Mean_Query_Execution_Time_s        : 0.0784916296134315
Median_Predicate_Execution_Time_s  : 0.001
Percentile95_Ms                    : 160.0
Number_of_Predicates               : 41157

Release                            : v2.21.0
Platform                           : x86-windows
Language                           : cpp
Total_Serialized_Execution_Time_Ms : 3575250
Mean_Predicate_Execution_Time_Ms   : 87.56643562173944
Median_Predicate_Execution_Time_Ms : 2.0
Standard_Deviation_Ms              : 1351.655128024238
Total_Serialized_Execution_Time_s  : 3575.25
Mean_Query_Execution_Time_s        : 0.0875664356217394
Median_Predicate_Execution_Time_s  : 0.002
Percentile95_Ms                    : 175.0
Number_of_Predicates               : 40829

Release                            : 338
Platform                           : x86-linux
Language                           : cpp
Total_Serialized_Execution_Time_Ms : 3180125
Mean_Predicate_Execution_Time_Ms   : 77.32074691823287
Median_Predicate_Execution_Time_Ms : 1.0
Standard_Deviation_Ms              : 1180.0538627998292
Total_Serialized_Execution_Time_s  : 3180.125
Mean_Query_Execution_Time_s        : 0.0773207469182328
Median_Predicate_Execution_Time_s  : 0.001
Percentile95_Ms                    : 159.0
Number_of_Predicates               : 41129

Release                            : 338
Platform                           : x86-linux
Language                           : c
Total_Serialized_Execution_Time_Ms : 2999925
Mean_Predicate_Execution_Time_Ms   : 80.85615330709935
Median_Predicate_Execution_Time_Ms : 1.0
Standard_Deviation_Ms              : 813.2797269837727
Total_Serialized_Execution_Time_s  : 2999.925
Mean_Query_Execution_Time_s        : 0.0808561533070993
Median_Predicate_Execution_Time_s  : 0.001
Percentile95_Ms                    : 186.0
Number_of_Predicates               : 37102


🏁 Below are the slowest predicates for the last 2 releases vs this PR.


Release           : v2.21.0
Run               : 2023-08-02_20-20-14
Platform          : x86-windows
Language          : cpp
Suite             : autosar-default
Predicate         : PreProcessorShallOnlyBeUsedForCertainDirectivesPatterns#32e68f1c::getAGuard#1#ff
Execution_Time_Ms : 30957

Release           : v2.21.0
Run               : 2023-08-02_20-20-14
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : RepeatedInitializationOfAggregateObjectElement#76b22bdc::hasMultipleInitializerExprsForSameField#2#ff
Execution_Time_Ms : 55357

Release           : v2.21.0
Run               : 2023-08-02_20-20-14
Platform          : x86-windows
Language          : cpp
Suite             : cert-default
Predicate         : SSAConstruction#2b11997e::DefUse::hasNonPhiDefinition#4#ffff
Execution_Time_Ms : 32596

Release           : v2.21.0
Run               : 2023-08-02_20-20-14
Platform          : x86-windows
Language          : cpp
Suite             : autosar-default
Predicate         : m##DataFlowUtil#7572fbec::localFlowStep#2Plus#bf
Execution_Time_Ms : 146724

Release           : v2.21.0
Run               : 2023-08-02_20-20-14
Platform          : x86-windows
Language          : cpp
Suite             : autosar-default
Predicate         : Dependency#b0c9183e::dependsOnTransitive#2#ff
Execution_Time_Ms : 180746

Release           : v2.21.0
Run               : 2023-08-02_20-20-14
Platform          : x86-windows
Language          : cpp
Suite             : autosar-default
Predicate         : SSAConstruction#2b11997e::DefUse::hasNonPhiDefinition#4#ffff
Execution_Time_Ms : 29296

Release           : v2.21.0
Run               : 2023-08-02_20-20-14
Platform          : x86-windows
Language          : c
Suite             : misra-default
Predicate         : #select#cpe#123#fff
Execution_Time_Ms : 33035

Release           : v2.21.0
Run               : 2023-08-02_20-20-14
Platform          : x86-windows
Language          : c
Suite             : misra-default
Predicate         : RepeatedInitializationOfAggregateObjectElement#76b22bdc::hasMultipleInitializerExprsForSameIndexInternal#4#ffff_3012#join_rhs
Execution_Time_Ms : 34287

Release           : v2.21.0
Run               : 2023-08-02_20-20-14
Platform          : x86-windows
Language          : c
Suite             : misra-default
Predicate         : RepeatedInitializationOfAggregateObjectElement#76b22bdc::hasMultipleInitializerExprsForSameField#2#ff
Execution_Time_Ms : 51452

Release           : v2.21.0
Run               : 2023-08-02_20-20-14
Platform          : x86-windows
Language          : c
Suite             : misra-default
Predicate         : _Literal#c5958f4a::ArrayOrVectorAggregateLiteral::getArraySize#0#dispred#bf_Literal#c5958f4a::ArrayO__#join_rhs
Execution_Time_Ms : 65074

Release           : v2.21.0
Run               : 2023-08-02_20-20-14
Platform          : x86-windows
Language          : c
Suite             : cert-default
Predicate         : SSAConstruction#2b11997e::PhiInsertion::definitionHasRedefinition#3#fff
Execution_Time_Ms : 30844

Release           : v2.21.0
Run               : 2023-08-02_20-20-14
Platform          : x86-linux
Language          : cpp
Suite             : autosar-default
Predicate         : UnusedIncludeDirectives#574b69bc::getANonLocalDependency#1#ff
Execution_Time_Ms : 26110

Release           : v2.21.0
Run               : 2023-08-02_20-20-14
Platform          : x86-linux
Language          : cpp
Suite             : autosar-default
Predicate         : PreProcessorShallOnlyBeUsedForCertainDirectivesPatterns#32e68f1c::getAGuard#1#ff
Execution_Time_Ms : 30378

Release           : v2.21.0
Run               : 2023-08-02_20-20-14
Platform          : x86-linux
Language          : cpp
Suite             : autosar-default
Predicate         : Dependency#b0c9183e::dependsOnTransitive#2#ff
Execution_Time_Ms : 139733

Release           : v2.21.0
Run               : 2023-08-02_20-20-14
Platform          : x86-linux
Language          : cpp
Suite             : autosar-default
Predicate         : m##DataFlowUtil#7572fbec::localFlowStep#2Plus#bf
Execution_Time_Ms : 154688

Release           : v2.21.0
Run               : 2023-08-02_20-20-14
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : #select#cpe#123#fff
Execution_Time_Ms : 26663

Release           : v2.21.0
Run               : 2023-08-02_20-20-14
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : _Contracts3#5e6bc86c::Contracts3Package::onlyTestErrnoRightAfterErrnoSettingFunctionQuery#0#f_Deviat__#antijoin_rhs
Execution_Time_Ms : 31364

Release           : v2.21.0
Run               : 2023-08-02_20-20-14
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : RepeatedInitializationOfAggregateObjectElement#76b22bdc::hasMultipleInitializerExprsForSameIndexInternal#4#ffff_3012#join_rhs
Execution_Time_Ms : 33723

Release           : v2.21.0
Run               : 2023-08-02_20-20-14
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : _Literal#c5958f4a::ArrayOrVectorAggregateLiteral::getArraySize#0#dispred#bf_Literal#c5958f4a::ArrayO__#join_rhs
Execution_Time_Ms : 50415

Release           : v2.21.0
Run               : 2023-08-02_20-20-14
Platform          : x86-linux
Language          : cpp
Suite             : autosar-default
Predicate         : SSAConstruction#2b11997e::DefUse::hasNonPhiDefinition#4#ffff
Execution_Time_Ms : 24291

Release           : 338
Run               : 2023-08-10_23-06-50
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : _Literal#c5958f4a::ArrayOrVectorAggregateLiteral::getArraySize#0#dispred#bf_Literal#c5958f4a::ArrayO__#join_rhs
Execution_Time_Ms : 51452

Release           : 338
Run               : 2023-08-10_23-06-50
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : RepeatedInitializationOfAggregateObjectElement#76b22bdc::hasMultipleInitializerExprsForSameIndexInternal#4#ffff_3012#join_rhs
Execution_Time_Ms : 33611

Release           : 338
Run               : 2023-08-10_23-06-50
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : _Contracts3#5e6bc86c::Contracts3Package::onlyTestErrnoRightAfterErrnoSettingFunctionQuery#0#f_Deviat__#antijoin_rhs
Execution_Time_Ms : 31472

Release           : 338
Run               : 2023-08-10_23-06-50
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : #select#cpe#123#fff
Execution_Time_Ms : 31457

Release           : 338
Run               : 2023-08-10_23-06-50
Platform          : x86-linux
Language          : cpp
Suite             : autosar-default
Predicate         : UnusedIncludeDirectives#574b69bc::getANonLocalDependency#1#ff
Execution_Time_Ms : 25851

Release           : 338
Run               : 2023-08-10_23-06-50
Platform          : x86-linux
Language          : cpp
Suite             : autosar-default
Predicate         : Dependency#b0c9183e::dependsOnTransitive#2#ff
Execution_Time_Ms : 137312

Release           : 338
Run               : 2023-08-10_23-06-50
Platform          : x86-linux
Language          : cpp
Suite             : autosar-default
Predicate         : PreProcessorShallOnlyBeUsedForCertainDirectivesPatterns#32e68f1c::getAGuard#1#ff
Execution_Time_Ms : 29855

Release           : 338
Run               : 2023-08-10_23-06-50
Platform          : x86-linux
Language          : cpp
Suite             : cert-default
Predicate         : SSAConstruction#2b11997e::DefUse::hasNonPhiDefinition#4#ffff
Execution_Time_Ms : 25152

Release           : 338
Run               : 2023-08-10_23-06-50
Platform          : x86-linux
Language          : cpp
Suite             : autosar-default
Predicate         : m##DataFlowUtil#7572fbec::localFlowStep#2Plus#bf
Execution_Time_Ms : 151401

Release           : 338
Run               : 2023-08-10_23-06-50
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : RepeatedInitializationOfAggregateObjectElement#76b22bdc::hasMultipleInitializerExprsForSameField#2#ff
Execution_Time_Ms : 57042


libc++ defines release inline in the header, which causes extraneous paths to
be reported by CodeQL. Adjust to summarize and exclude.
…hub/codeql-coding-standards into lcartey/final-compiler-compat-issues
@lcartey
Copy link
Collaborator Author

lcartey commented Aug 13, 2023

No performance concerns, and I've addressed the A18-1-4 matrix testing compiler compatibility issue reported above.

@mbaluda mbaluda self-requested a review August 14, 2023 14:39
@jsinglet jsinglet self-requested a review August 15, 2023 14:20
Copy link
Contributor

@jsinglet jsinglet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great Luke! Thanks for all this work getting these sorted 💪 🚀

@jsinglet jsinglet added this pull request to the merge queue Aug 15, 2023
Merged via the queue into main with commit a79ad24 Aug 15, 2023
17 checks passed
@jsinglet jsinglet deleted the lcartey/final-compiler-compat-issues branch August 15, 2023 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

2 participants