diff options
author | Benoit Foucher <benoit@zeroc.com> | 2017-03-23 15:29:25 +0100 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2017-03-23 15:29:25 +0100 |
commit | 1597a75419cd8049252cfbca6fce6ae95ef8b2c7 (patch) | |
tree | 2b2c858df1dbe68c1d576cae06c4713fd2ad5c40 /cpp/src | |
parent | Use Ice\None with PHP namespace mapping (diff) | |
download | ice-1597a75419cd8049252cfbca6fce6ae95ef8b2c7.tar.bz2 ice-1597a75419cd8049252cfbca6fce6ae95ef8b2c7.tar.xz ice-1597a75419cd8049252cfbca6fce6ae95ef8b2c7.zip |
Fix for ICE-7125 - Added support for Ice.ClassGraphDepthMax
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/InputStream.cpp | 52 | ||||
-rw-r--r-- | cpp/src/Ice/Instance.cpp | 14 | ||||
-rw-r--r-- | cpp/src/Ice/Instance.h | 2 | ||||
-rw-r--r-- | cpp/src/Ice/PropertyNames.cpp | 3 | ||||
-rw-r--r-- | cpp/src/Ice/PropertyNames.h | 2 | ||||
-rw-r--r-- | cpp/src/Ice/ThreadPool.cpp | 11 |
6 files changed, 79 insertions, 5 deletions
diff --git a/cpp/src/Ice/InputStream.cpp b/cpp/src/Ice/InputStream.cpp index e10bc107df9..61f71c7b5ba 100644 --- a/cpp/src/Ice/InputStream.cpp +++ b/cpp/src/Ice/InputStream.cpp @@ -167,6 +167,7 @@ Ice::InputStream::initialize(Instance* instance, const EncodingVersion& encoding _collectObjects = _instance->collectObjects(); #endif _traceSlicing = _instance->traceLevels()->slicing > 0; + _classGraphDepthMax = _instance->classGraphDepthMax(); } void @@ -179,6 +180,7 @@ Ice::InputStream::initialize(const EncodingVersion& encoding) _collectObjects = false; #endif _traceSlicing = false; + _classGraphDepthMax = 0x7fffffff; _closure = 0; _sliceValues = true; _startSeq = -1; @@ -241,6 +243,19 @@ Ice::InputStream::setTraceSlicing(bool b) _traceSlicing = b; } +void +Ice::InputStream::setClassGraphDepthMax(size_t classGraphDepthMax) +{ + if(classGraphDepthMax < 1) + { + _classGraphDepthMax = 0x7fffffff; + } + else + { + _classGraphDepthMax = classGraphDepthMax; + } +} + void* Ice::InputStream::getClosure() const { @@ -266,6 +281,7 @@ Ice::InputStream::swap(InputStream& other) std::swap(_collectObjects, other._collectObjects); #endif std::swap(_traceSlicing, other._traceSlicing); + std::swap(_classGraphDepthMax, other._classGraphDepthMax); std::swap(_closure, other._closure); std::swap(_sliceValues, other._sliceValues); @@ -1740,11 +1756,11 @@ Ice::InputStream::initEncaps() ValueFactoryManagerPtr vfm = valueFactoryManager(); if(_currentEncaps->encoding == Encoding_1_0) { - _currentEncaps->decoder = new EncapsDecoder10(this, _currentEncaps, _sliceValues, vfm); + _currentEncaps->decoder = new EncapsDecoder10(this, _currentEncaps, _sliceValues, _classGraphDepthMax, vfm); } else { - _currentEncaps->decoder = new EncapsDecoder11(this, _currentEncaps, _sliceValues, vfm); + _currentEncaps->decoder = new EncapsDecoder11(this, _currentEncaps, _sliceValues, _classGraphDepthMax, vfm); } } } @@ -1884,6 +1900,7 @@ Ice::InputStream::EncapsDecoder::addPatchEntry(Int index, PatchFunc patchFunc, v PatchEntry e; e.patchFunc = patchFunc; e.patchAddr = patchAddr; + e.classGraphDepth = _classGraphDepth; q->second.push_back(e); } @@ -2233,6 +2250,30 @@ Ice::InputStream::EncapsDecoder10::readInstance() } // + // Compute the biggest class graph depth of this object. To compute this, + // we get the class graph depth of each ancestor from the patch map and + // keep the biggest one. + // + _classGraphDepth = 0; + PatchMap::iterator patchPos = _patchMap.find(index); + if(patchPos != _patchMap.end()) + { + assert(patchPos->second.size() > 0); + for(PatchList::iterator k = patchPos->second.begin(); k != patchPos->second.end(); ++k) + { + if(k->classGraphDepth > _classGraphDepth) + { + _classGraphDepth = k->classGraphDepth; + } + } + } + + if(++_classGraphDepth > _classGraphDepthMax) + { + throw MarshalException(__FILE__, __LINE__, "maximum class graph depth reached"); + } + + // // Unmarshal the instance and add it to the map of unmarshaled instances. // unmarshal(index, v); @@ -2668,11 +2709,18 @@ Ice::InputStream::EncapsDecoder11::readInstance(Int index, PatchFunc patchFunc, startSlice(); // Read next Slice header for next iteration. } + if(++_classGraphDepth > _classGraphDepthMax) + { + throw MarshalException(__FILE__, __LINE__, "maximum class graph depth reached"); + } + // // Unmarshal the object. // unmarshal(index, v); + --_classGraphDepth; + if(!_current && !_patchMap.empty()) { // diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp index c49e386d2e9..cba9085ba4f 100644 --- a/cpp/src/Ice/Instance.cpp +++ b/cpp/src/Ice/Instance.cpp @@ -948,6 +948,7 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi _initData(initData), _messageSizeMax(0), _batchAutoFlushSize(0), + _classGraphDepthMax(0), _collectObjects(false), _toStringMode(ICE_ENUM(ToStringMode, Unicode)), _implicitContext(0), @@ -1189,6 +1190,19 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi } } + { + static const int defaultValue = 100; + Int num = _initData.properties->getPropertyAsIntWithDefault("Ice.ClassGraphDepthMax", defaultValue); + if(num < 1 || static_cast<size_t>(num) > static_cast<size_t>(0x7fffffff)) + { + const_cast<size_t&>(_classGraphDepthMax) = static_cast<size_t>(0x7fffffff); + } + else + { + const_cast<size_t&>(_classGraphDepthMax) = static_cast<size_t>(num); + } + } + const_cast<bool&>(_collectObjects) = _initData.properties->getPropertyAsInt("Ice.CollectObjects") > 0; string toStringModeStr = _initData.properties->getPropertyWithDefault("Ice.ToStringMode", "Unicode"); diff --git a/cpp/src/Ice/Instance.h b/cpp/src/Ice/Instance.h index ba1d367b84f..9bcc78e0990 100644 --- a/cpp/src/Ice/Instance.h +++ b/cpp/src/Ice/Instance.h @@ -108,6 +108,7 @@ public: Ice::PluginManagerPtr pluginManager() const; size_t messageSizeMax() const { return _messageSizeMax; } size_t batchAutoFlushSize() const { return _batchAutoFlushSize; } + size_t classGraphDepthMax() const { return _classGraphDepthMax; } bool collectObjects() const { return _collectObjects; } Ice::ToStringMode toStringMode() const { return _toStringMode; } const ACMConfig& clientACM() const; @@ -176,6 +177,7 @@ private: const DefaultsAndOverridesPtr _defaultsAndOverrides; // Immutable, not reset by destroy(). const size_t _messageSizeMax; // Immutable, not reset by destroy(). const size_t _batchAutoFlushSize; // Immutable, not reset by destroy(). + const size_t _classGraphDepthMax; // Immutable, not reset by destroy(). const bool _collectObjects; // Immutable, not reset by destroy(). const Ice::ToStringMode _toStringMode; // Immutable, not reset by destroy() ACMConfig _clientACM; diff --git a/cpp/src/Ice/PropertyNames.cpp b/cpp/src/Ice/PropertyNames.cpp index 02ee0f7ac2c..527d7e84d6d 100644 --- a/cpp/src/Ice/PropertyNames.cpp +++ b/cpp/src/Ice/PropertyNames.cpp @@ -6,7 +6,7 @@ // ICE_LICENSE file included in this distribution. // // ********************************************************************** -// Generated by makeprops.py from file ./config/PropertyNames.xml, Tue Feb 28 15:01:12 2017 +// Generated by makeprops.py from file ./config/PropertyNames.xml, Thu Mar 23 15:24:16 2017 // IMPORTANT: Do not edit this file -- any edits made here will be lost! @@ -77,6 +77,7 @@ const IceInternal::Property IcePropsData[] = IceInternal::Property("Ice.BatchAutoFlush", true, 0), IceInternal::Property("Ice.BatchAutoFlushSize", false, 0), IceInternal::Property("Ice.ChangeUser", false, 0), + IceInternal::Property("Ice.ClassGraphDepthMax", false, 0), IceInternal::Property("Ice.ClientAccessPolicyProtocol", false, 0), IceInternal::Property("Ice.Compression.Level", false, 0), IceInternal::Property("Ice.CollectObjects", false, 0), diff --git a/cpp/src/Ice/PropertyNames.h b/cpp/src/Ice/PropertyNames.h index 171fa1bed8c..485d4afaaa1 100644 --- a/cpp/src/Ice/PropertyNames.h +++ b/cpp/src/Ice/PropertyNames.h @@ -6,7 +6,7 @@ // ICE_LICENSE file included in this distribution. // // ********************************************************************** -// Generated by makeprops.py from file ./config/PropertyNames.xml, Tue Feb 28 15:01:12 2017 +// Generated by makeprops.py from file ./config/PropertyNames.xml, Thu Mar 23 15:24:16 2017 // IMPORTANT: Do not edit this file -- any edits made here will be lost! diff --git a/cpp/src/Ice/ThreadPool.cpp b/cpp/src/Ice/ThreadPool.cpp index 946a05e2b08..4b14a7e1ce8 100644 --- a/cpp/src/Ice/ThreadPool.cpp +++ b/cpp/src/Ice/ThreadPool.cpp @@ -346,7 +346,16 @@ IceInternal::ThreadPool::ThreadPool(const InstancePtr& instance, const string& p _selector.setup(_sizeIO); #endif - int stackSize = properties->getPropertyAsInt(_prefix + ".StackSize"); +#if defined(__APPLE__) + // + // We use a default stack size of 1MB on macOS and the new C++11 mapping to allow transmitting + // class graphs with a depth of 100 (maximum default), 512KB is not enough otherwise. + // + int defaultStackSize = 1024 * 1024; // 1MB +#else + int defaultStackSize = 0; +#endif + int stackSize = properties->getPropertyAsIntWithDefault(_prefix + ".StackSize", defaultStackSize); if(stackSize < 0) { Warning out(_instance->initializationData().logger); |