Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-17237

'entry' may be used uninitialized in PlanCache code

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.0.0-rc8
    • Component/s: Build
    • Labels:
      None
    • ALL

      I was upgraded from gcc 4.8.x to 4.9.1 and while building rc8 I get these error messages:

      g++ -o build/linux2/norm/mongo/db/query/plan_cache.o -c -Wnon-virtual-dtor -Woverloaded-virtual -std=c++11 -fPIC -fno-strict-aliasing -ggdb -pthread -Wall -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch -pipe -Werror -O3 -Wno-unused-local-typedefs -Wno-unused-function -Wno-deprecated-declarations -Wno-unused-but-set-variable -Wno-missing-braces -fno-builtin-memcmp -DBOOST_ALL_NO_LIB -D_SCONS -DMONGO_EXPOSE_MACROS -DSUPPORT_UTF8 -DMONGO_OPTIMIZED_BUILD -DMONGO_BYTE_ORDER=1234 -D_FILE_OFFSET_BITS=64 -DMONGO_HAVE___THREAD -DMONGO_HAVE_CXX11_ATOMICS -DMONGO_HAVE_HEADER_UNISTD_H -DMONGO_HAVE_POSIX_MONOTONIC_CLOCK -DMONGO_HAVE_EXECINFO_BACKTRACE -I/foo/rocksdb/include -I/bar/include -Isrc/third_party/s2 -Isrc/third_party/pcre-8.30 -Isrc/third_party/boost -Ibuild/linux2/norm -Isrc src/mongo/db/query/plan_cache.cpp
      src/mongo/db/query/plan_cache.cpp: In member function 'mongo::Status mongo::PlanCache::getEntry(const mongo::CanonicalQuery&, mongo::PlanCacheEntry**) const':
      src/mongo/db/query/plan_cache.cpp:481:34: error: 'entry' may be used uninitialized in this function [-Werror=maybe-uninitialized]
               *entryOut = entry->clone();
                                        ^
      src/mongo/db/query/plan_cache.cpp: In member function 'mongo::Status mongo::PlanCache::get(const mongo::CanonicalQuery&, mongo::CachedSolution**) const':
      src/mongo/db/query/plan_cache.cpp:370:48: error: 'entry' may be used uninitialized in this function [-Werror=maybe-uninitialized]
               *crOut = new CachedSolution(key, *entry);
      

      Looking at the code and LRUKeyValue::get I see that it can return an error without initializing the second argument, so I think this is an error. But my C++ reading skills are rusty.

            Assignee:
            andrew.morrow@mongodb.com Andrew Morrow (Inactive)
            Reporter:
            mdcallag Mark Callaghan
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: