Having a strange Error. I have a UE module which uses a dynamic library. Inside the library I create on a stack a std::vector<std::pair<struct, int>>>
and return the created object by copy.
Inside UE module I loop through items and add them to a TArray<FTransform>
. Then return by copy(?). And suddenly I have an Error which is really strange.
EXCEPTION_ACCESS_VIOLATION writing address 0x0000000000000010
UE4Editor_Core!__TBB_LockByte()
UE4Editor_Core!rml::internal::Block::freePublicObject()
UE4Editor_Core!scalable_free()
UE4Editor_Core!FMemory::Free() [C:\UE_4.26.1_Source\Engine\Source\Runtime\Core\Public\HAL\FMemory.inl:80]
TArray<FTransform> UGMazeGeneratorActorComponent::GenerateMaze() const
{
TArray<FTransform> Grid;
for (const auto& item : graph_r.getRealWorldCoords()) //copy of std::vector<std::pair<struct, int>>> returned by value
{
const Vertex from = item.first;
const float rotation = item.second;
const float X = from.column * m_WallHeight;
const float Y = from.row * m_WallWidth;
const auto wall = FTransform(FRotator(0, rotation, 0), FVector(X, Y, 0));
Grid.Add(wall);
} // this line EXCEPTION_ACCESS_VIOLATION writing address 0x0000000000000010
return Grid;
}
std::vector<std::pair<Vertex, int>> Graph::getRealWorldCoords() const
{
std::vector<std::pair<Vertex, int>> realWorldCoords;
realWorldCoords.push_back(std::make_pair(Vertex(x1, y1), 0));
return realWorldCoords;
}
If I use my custom iterator to loop through std::vector<std::pair<struct, int>>>
which returns an item by the reference everything is ok.