[SERVER-17237]  'entry' may be used uninitialized in PlanCache code Created: 10/Feb/15  Updated: 24/May/16  Resolved: 20/Feb/15

Status: Closed
Project: Core Server
Component/s: Build
Affects Version/s: 3.0.0-rc8
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Mark Callaghan Assignee: Andrew Morrow (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-24240 Ubuntu 16.04 on the v3.2 branch needs... Closed
Operating System: ALL
Participants:

 Description   

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.



 Comments   
Comment by Githook User [ 24/May/16 ]

Author:

{u'username': u'acmorrow', u'name': u'Andrew Morrow', u'email': u'acm@mongodb.com'}

Message: SERVER-24240 SERVER-17237 Suppress warnings with newer compilers
Branch: v3.2
https://github.com/mongodb/mongo/commit/d54133690a66797b210a6fd1eac408c0516f6d34

Comment by Mark Callaghan [ 20/Feb/15 ]

Please close it. Sorry for wasting time, still learning how to deal with g++ version upgrades.

Comment by Andrew Morrow (Inactive) [ 20/Feb/15 ]

Hi mcallaghan@fb.com - Is there any further action that you would like to see taken regarding this ticket? Otherwise, I would like to close it if it really is a false positive.

Comment by Asya Kamsky [ 18/Feb/15 ]

mdcallag you are correct, this appears to be a false positive - we actually use static analysis on all of MongoDB source (Coverity) and it also flags a similar pattern as it's problematic for any static analysis to track an allocation that depends on a specific value of a different returned variable.

Comment by Mark Callaghan [ 10/Feb/15 ]

And now I wonder whether this is a bogus bug report as this code might prevent the use of 'entry' after an error

if (!cacheStatus.isOK())

{ return cacheStatus; }
Generated at Thu Feb 08 03:43:44 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.