Comments (5)
reason :
// memory model : x64
struct Node { void* p1; }
FixedObjectPool<Node> pool(3);
// header size (int, int) ---- 8 byte
// index 1(uint32), index 2(uint32) ---- 8
// index 3(uint32), xxxxx (padding) ---- 8
// entry 1 size(void*) ---- 8
// entry 2 size(void*) ---- 8
// entry 3 size(void*) ---- 8
in this func :
ObjectPoolBlock<T>* ObjectPoolBlock<T>::create(index_t entries_per_block)
{
……
// here index size is align to entry size
const size_t indices_size = align_to(sizeof(index_t) * entries_per_block, entry_align);
……
}
// but here, u calc (index_t* + 1), in x64, this is 4byte, but Entry pointer is 8 byte
// so, u should no align index_size or convert index_t* to T*
template <typename T>
index_t* ObjectPoolBlock<T>::indices_begin() const
{
// calculcates the start of the indicies
return reinterpret_cast<index_t*>(const_cast<ObjectPoolBlock<T>*>(this + 1));
}
T* ObjectPoolBlock<T>::memory_begin() const
{
……
return reinterpret_cast<T*>(indices_begin() + entries_per_block_);
}
from objectpool.
fix :
ObjectPoolBlock<T>* ObjectPoolBlock<T>::create(index_t entries_per_block)
{
……
const size_t indices_size = align_to(sizeof(index_t) * entries_per_block, sizeof(index_t));
……
}
other fix :
T* ObjectPoolBlock<T>::memory_begin() const
{
const size_t entry_align = alignof(T);
const size_t indices_size = align_to(sizeof(index_t) * entries_per_block_, entry_align);
return reinterpret_cast<T*>(reinterpret_cast<uint8_t*>(indices_begin()) + indices_size);
}
from objectpool.
Thanks for investigating, it might be easier to make a PR if you have a fix :)
from objectpool.
:), has been submitted
from objectpool.
@bigt1234 could you please close that issue if it has been fixed? thanks
from objectpool.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from objectpool.