Uploaded image for project: 'HPCC'
  1. HPCC
  2. HPCC-29163

Coverity scan reported new defects related to jhinplace.cpp

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Not specified
    • Resolution: Fixed
    • 9.0.0
    • 9.0.0
    • JLib
    • None
    • Coverity scan

    Description

      The reported problems are:

      CID Impact Type Category File Function
      1536702 High Memset fill value of '0' Memory - illegal accesses /home/centos/build/CE/platform/HPCC-Platform/system/jhtree/jhtree.cpp buildTestKey
      1536704 Low An array is captured by a lambda Performance inefficiencies /home/centos/build/CE/platform/HPCC-Platform/system/jhtree/jhinplace.cpp operator ()
      1536705 Low 'Constant' variable guards dead code Possible Control flow issues /home/centos/build/CE/platform/HPCC-Platform/system/jhtree/jhinplace.cpp write

       

       *** CID 1536705:    (DEADCODE)
      /home/centos/build/CE/platform/HPCC-Platform/system/jhtree/jhinplace.cpp: 2046 in CInplaceLeafWriteNode::write(IFileIOStream *, CRC32 *)()
      2040             }
      2041
      2042             if (keyLen != keyCompareLen)
      2043             {
      2044                 if (useUncompressed)
      2045                 {
      >>>     CID 1536705:    (DEADCODE)
      >>>     Execution cannot reach this statement: "if (this->isVariable)
        ser...".
      2046                     if (isVariable)
      2047                         serializePacked(data, uncompressed.length());
      2048                     data.append(uncompressed.length(), uncompressed.bufferBase());
      2049                 }
      2050                 else
      2051                 {
      /home/centos/build/CE/platform/HPCC-Platform/system/jhtree/jhinplace.cpp: 2023 in CInplaceLeafWriteNode::write(IFileIOStream *, CRC32 *)()
      2017             //Pack these by scaling and reducing the number of bytes
      2018             unsigned bytesPerPosition = 0;
      2019             if (minPosition != maxPosition)
      2020                 bytesPerPosition = bytesRequired(maxPosition-minPosition);
      2021
      2022             bool useUncompressed = false; // Implement in HPCC-19115
      >>>     CID 1536705:    (DEADCODE)
      >>>     Execution cannot reach the expression "64" inside this statement: "sizeMask = (byte)bytesPerPo...".
      2023             byte sizeMask = (byte)bytesPerPosition | (useUncompressed ? NSFuncompressedPayload : 0);
      2024             data.append(sizeMask);
      2025             serializePacked(data, minPosition);
      2026             if (bytesPerPosition != 0)
      2027             {
      2028                 for (unsigned i=0; i < positions.ordinality(); i++)** CID 1536704:  Performance inefficiencies  (PASS_BY_VALUE)
      /home/centos/build/CE/platform/HPCC-Platform/system/jhtree/jhinplace.cpp: 2227 in InplaceIndexTest::testSearching()::[lambda(const char *) (instance 2)]::operator ()(const char *) const()
      ________________________________________________________________________________________________________
      *** CID 1536704:  Performance inefficiencies  (PASS_BY_VALUE)
      /home/centos/build/CE/platform/HPCC-Platform/system/jhtree/jhinplace.cpp: 2227 in InplaceIndexTest::testSearching()::[lambda(const char *) (instance 2)]::operator ()(const char *) const()
      2221
      2222                 if (!searcher.getValueAt(i, result))
      2223                     printf("%u: getValue() failed\n", i);
      2224                 else if (!streq(entry, result))
      2225                     printf("%u: '%s', '%s'\n", i, entry, result);
      2226
      >>>     CID 1536704:  Performance inefficiencies  (PASS_BY_VALUE)
      >>>     Capturing variable "entries", which is a C-array, in a lambda.  Unlike function parameters, this array is copied and passed by value.
      2227                 auto callback = [numEntries, entries, &searcher](const char * search)
      2228                 {
      2229                     for (unsigned j= 0; j < numEntries; j++)
      2230                     {
      2231                         int expected = normalizeCompare(strcmp(search, entries[j]));
      2232                         int actual = normalizeCompare(searcher.compareValueAt(search, j));** CID 1536703:  Null pointer dereferences  (FORWARD_NULL)
      /home/centos/build/CE/platform/HPCC-Platform/testing/unittests/datamaskingtests.cpp: 730 in DataMaskingEngineTests::assertQueriedProfile(DataMasking::CEngine *, const char *, unsigned char, const char *, unsigned char)()
      ________________________________________________________________________________________________________
      *** CID 1536702:  Memory - illegal accesses  (NO_EFFECT)
      /home/centos/build/CE/platform/HPCC-Platform/system/jhtree/jhtree.cpp: 3445 in IKeyManagerTest::buildTestKey(const char *, bool, bool, bool, bool, bool, IOutputMetaData *, const char *)()
      3439                     (useTrailingHeader ? USE_TRAILING_HEADER : 0) |
      3440                     (noSeek ? TRAILING_HEADER_ONLY : 0) |
      3441                     0,
      3442                     maxRecSize, NODESIZE, keyedSize, 0, &helper, true, false);
      3443
      3444             char keybuf[18];
      >>>     CID 1536702:  Memory - illegal accesses  (NO_EFFECT)
      >>>     Function "memset" with fill value "'0'" (the zero character) in "memset(keybuf, 48, 18UL)".
      3445             memset(keybuf, '0', 18);
      3446             uint32_t maxRecordSizeSeen = 0;
      3447             for (unsigned count = 0; count < 10000; count++)
      3448             {
      3449                 unsigned datasize = 10;
      3450                 if (variable && (count % 10)==0)

      To view the defects in Coverity Scan visit, https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fu15810271.ct.sendgrid.net%2Fls%2Fclick%3Fupn%3DHRESupC-2F2Czv4BOaCWWCy7my0P0qcxCbhZ31OYv50ypQjb0hTUkvcp9raSmREwFq6YYouACn74NAOJog3t-2B9hwML-2BjS1JaRteOgFFK87Rag-3D54CY_8MqIhCRnGbt-2F8erpzfaQPKt49wIYlz1MQCVtEp8qAdHk7irCucNjUjg-2FLmHLNLFldeDVt8i-2F4AwLrtdQ1yyZ712592sSrcn8HfKpkuGxUtLoWrNyc-2FIynvn9NQvdQO-2BfIQkghRTbv5MzDHTh6R2Xflc1ktGwuE2k6-2FcgWd7kt2ZcYFgyID8ME42ozXZN74xoZeL6yZJG20He02mgx2OBnom1PtLoa975mjmrCAqRwis-3D&data=05%7C01%7Cattila.vamos%40lexisnexis.com%7C8701d648b1b34234207a08db2391f70b%7C9274ee3f94254109a27f9fb15c10675d%7C0%7C0%7C638142882054271322%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=J53scStCz%2Fjx7HH6FGlzOhgH5uEwH1GAdG%2FKQWQwygk%3D&reserved=0

       

      Attachments

        Activity

          People

            ghalliday Gavin Halliday
            attilavamos Attila Vamos
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: