diff --git a/src/common/advice/advice.cpp b/src/common/advice/advice.cpp index eb579e8fe..4fc12d79c 100644 --- a/src/common/advice/advice.cpp +++ b/src/common/advice/advice.cpp @@ -153,7 +153,7 @@ namespace advice { void* allocateBuffer(size_t siz) { - try { return new char[siz]; } + try { return new char[siz]; } /////////////////////////////////////////////////////////////////////TICKET #1204 potentially misaligned catch(std::bad_alloc&) { diff --git a/src/lib/format-string.hpp b/src/lib/format-string.hpp index 079ba8067..976954388 100644 --- a/src/lib/format-string.hpp +++ b/src/lib/format-string.hpp @@ -95,6 +95,8 @@ ** using a bit of type traits and boost lexical_cast, but no boost::format. ** @warning not suited for performance critical code. About 10 times slower than printf. ** + ** TICKET #1204 : proper alignment verified 10/2019 + ** ** @see FormatString_test ** @see format-util.hpp ** @see format-obj.hpp diff --git a/src/lib/meta/virtual-copy-support.hpp b/src/lib/meta/virtual-copy-support.hpp index ff3ae4877..817f4e00c 100644 --- a/src/lib/meta/virtual-copy-support.hpp +++ b/src/lib/meta/virtual-copy-support.hpp @@ -101,6 +101,7 @@ ** copies. Additionally, if you \em really need multiple level deep inheritance, ** you need to mix in the copy implementations on \em every level \em again, and ** you need to provide custom copy operations on every level. + ** @warning please ensure the target storage for copy/clone is properly aligned. TICKET #1204 ** ** @see VirtualCopySupport_test ** @see lib::Variant usage example diff --git a/src/lib/null-value.hpp b/src/lib/null-value.hpp index d22a40a3d..c811eafcc 100644 --- a/src/lib/null-value.hpp +++ b/src/lib/null-value.hpp @@ -65,8 +65,7 @@ namespace lib { /** * Singleton holder for NIL or default value objects. * Implemented as a cluster of Meyer's singletons, maintaining - * a single value per type. As an extension point for specialisation, - * a function to emplace a "default" object is also provided. + * a single value per type. Specialisation is intended. */ template struct NullValue @@ -77,12 +76,6 @@ namespace lib { static TY nilValue; return nilValue; } - - static TY& - build (void* storage) - { - return *new(storage) TY{}; - } }; diff --git a/src/lib/opaque-holder.hpp b/src/lib/opaque-holder.hpp index ac18b9ddc..ac330e377 100644 --- a/src/lib/opaque-holder.hpp +++ b/src/lib/opaque-holder.hpp @@ -57,6 +57,8 @@ ** and you need to re-discover their concrete type, then maybe ** a visitor or variant record might be a better solution. ** + ** TICKET #1204 : proper alignment verified 10/2019 + ** ** @see opaque-holder-test.cpp ** @see function-erasure.hpp usage example ** @see variant.hpp diff --git a/src/lib/path-array.hpp b/src/lib/path-array.hpp index 381a921cc..e015abb07 100644 --- a/src/lib/path-array.hpp +++ b/src/lib/path-array.hpp @@ -122,7 +122,7 @@ namespace lib { template explicit Extension (ELMS&& ...elms) - : storage_{new Literal[1 + sizeof...(ELMS)]} + : storage_{new Literal[1 + sizeof...(ELMS)]} // proper alignment maintained here (TICKET #1204) { size(storage_) = sizeof...(ELMS); new(storage_+1) Literal[sizeof...(ELMS)] {forward(elms)...}; diff --git a/src/lib/polymorphic-value.hpp b/src/lib/polymorphic-value.hpp index 24d23a038..b4626cf65 100644 --- a/src/lib/polymorphic-value.hpp +++ b/src/lib/polymorphic-value.hpp @@ -377,6 +377,7 @@ namespace lib { enum{ siz = storage + _Traits::ADMIN_OVERHEAD }; + // WARNING: never add any member fields here /////////////////TICKET #1204 /* === embedded object in buffer === */ diff --git a/src/lib/replaceable-item.hpp b/src/lib/replaceable-item.hpp index 4392ed89a..3ec157212 100644 --- a/src/lib/replaceable-item.hpp +++ b/src/lib/replaceable-item.hpp @@ -147,7 +147,7 @@ namespace wrapper { new(&content_) X{forward (otherValue)}; } catch(...) { - NullValue::build (&content_); + new(&content_) X{NullValue::get()}; } template diff --git a/src/lib/scoped-collection.hpp b/src/lib/scoped-collection.hpp index 5623cb836..76dee7710 100644 --- a/src/lib/scoped-collection.hpp +++ b/src/lib/scoped-collection.hpp @@ -29,7 +29,8 @@ ** The storage holding all those child objects is allocated in one chunk ** and never adjusted. ** - ** \par usage patterns + ** ## usage patterns + ** ** The common ground for all usage of this container is to hold some elements ** with exclusive ownership; when the enclosing container goes out of scope, ** all the dtors of the embedded objects will be invoked. Frequently this diff --git a/src/lib/scoped-holder-transfer.hpp b/src/lib/scoped-holder-transfer.hpp index f8087308b..cd79dbc93 100644 --- a/src/lib/scoped-holder-transfer.hpp +++ b/src/lib/scoped-holder-transfer.hpp @@ -120,7 +120,7 @@ namespace lib { void construct (pointer p, const TY& ref) { - new(p) TY(); + new(p) TY(); /////////////////////TICKET #1204 ASSERT (p); ASSERT (!(*p), "protocol violation: target already manages another object."); if (ref) diff --git a/src/lib/simple-allocator.hpp b/src/lib/simple-allocator.hpp index 6e3d3b3a1..d9e55b0f9 100644 --- a/src/lib/simple-allocator.hpp +++ b/src/lib/simple-allocator.hpp @@ -70,6 +70,9 @@ namespace lib { /** * Policy: use just plain heap allocations + * @waring whenever you define a specialisation, + * _you_ are responsible for proper alignment + * @see TICKET #1204 */ template class CustomAllocator diff --git a/src/lib/typed-allocation-manager.hpp b/src/lib/typed-allocation-manager.hpp index 036a8aee0..a424dd204 100644 --- a/src/lib/typed-allocation-manager.hpp +++ b/src/lib/typed-allocation-manager.hpp @@ -55,6 +55,7 @@ ** ** @todo using a quick-n-dirty heap allocation implementation for now (8/09), ** but should write a custom allocator based on cehteh's mpool! + ** @warning this quick-n-dirty heap allocation might produce misaligned storage!! ** ** @see CommandRegistry ** @see AllocationCluster (another custom allocation scheme, which could be united) @@ -214,7 +215,7 @@ namespace lib { { ////////////////////////////////////////////////TICKET #231 :redirect to the corresponding pool allocator TRACE (memory, "release «%s»", util::typeStr().c_str()); - typedef char Storage[sizeof(XX)]; + typedef char Storage[sizeof(XX)]; //////////////TICKET #1204 : WARNING this might produce misaligned storage when the array does not start on a "void* boundary" delete[] reinterpret_cast (entry); allocCnt_.dec(); } diff --git a/src/lib/variant.hpp b/src/lib/variant.hpp index fe7720055..b213d4025 100644 --- a/src/lib/variant.hpp +++ b/src/lib/variant.hpp @@ -222,6 +222,8 @@ namespace lib { template class Variant { + // WARNING: never add any member field before the storage_ array /////////////////////////TICKET #1204 + public: enum { SIZ = meta::maxSize::value }; diff --git a/src/steam/engine/buffhandle.hpp b/src/steam/engine/buffhandle.hpp index 6cdbc2a97..1df157fc5 100644 --- a/src/steam/engine/buffhandle.hpp +++ b/src/steam/engine/buffhandle.hpp @@ -40,6 +40,12 @@ ** to an actual buffer provided and managed behind the scenes. There is no automatic ** resource management; clients are responsible to invoke BuffHandle#release when done. ** + ** @warning buffer management via BuffHandle and BufferDescriptor does _not automatically + ** maintain proper alignment._ Rather, it relies on the storage allocator to provide + ** a buffer suitably aligned for the target type to hold. In most cases, this target + ** location will actually be storage maintained on heap through some STL collection; + ** this topic is a possible subtle pitfall non the less. + ** ** @see BufferProvider ** @see BufferProviderProtocol_test usage demonstration ** @see OutputSlot diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 26e581888..dd9280630 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -50316,7 +50316,7 @@ - + @@ -50346,6 +50346,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ Aber Vorsicht: es wird noch gar nicht verwendet +

+ +
+ +
+
+ + + + + + + + + + + + + + + + +

+ typed-allocation-manager.hpp 217 +

+

+ dumme Heap-Allokation eines char[] +

+

+ !!!!!11!! +

+ + +
+ +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + @@ -50695,6 +50788,10 @@ + + + +