Make sure custom allocators align memory to proper alignments
EDITED SUMMARY Make sure custom allocators align memory to alignments that cannot cause problems.
ORIGINAL ISSUE I have no idea how critical this is, but there's quite large amount of misaligned memory being accessed all over bsf. Apparently sometimes this can cause interesting problems
runtime error: reference binding to misaligned address 0x7fa1c2317e72 for type 'const std::type_info', which requires 8 byte alignment
constructor call on misaligned address 0x7fa1b667f034 for type 'bs::ProfilerCPU::ProfiledBlock', which requires 8 byte alignment
runtime error: constructor call on misaligned address 0x7fa1b667f03c for type 'std::vector<bs::ProfilerCPU::ProfileSample, bs::StdFrameAlloc<bs::ProfilerCPU::ProfileSample> > *', which requires 8 byte alignment
BsProfilerCPU.cpp:242:17: runtime error: load of misaligned address 0x7fa1b667f034 for type 'char *', which requires 8 byte alignment
Do you perhaps have a full list of problematic areas?
I wouldn't worry about this too much, until we actually run into problems. But much of it is likely caused by custom allocators like frame or stack allocators, which don't align allocations unless explicitly requested. It might be good to modify those allocators to always align to 8 bytes.
In a few places I also pre-allocate a block of memory and then use it for smaller local allocations, which could also cause misalignment.
Yup, I have a 5MB log file produced from running LowLevelRendering example :smile:, just let me know where You want it
Just upload it to dropbox or here if possible, doesn't really matter.
Put it on google drive
Thanks. Ultimately most of the errors seem to be coming from just a few places. The culprit seems likely to what I've said + syncToCore methods which sometimes serialize things like vectors/shared pointers and then manually call constructors/destructors.