C 矢量push_back访问违规
c++ vector push_back access violation
我在使用std :: vector时遇到随机例外。
这是主要元素:
struct Stroke
{
std::vector<vec2> points;
Pixel color;
std::vector<unsigned int> pixelIds;
};
void myFunc()
{
while (strokes.size() < 5000)
{
if (/*A condition that is always met at some point*/)
{
break;
}
//Some code
newStroke->pixelIds.clear();
newStroke->pixelIds.resize(0);
strokes.push_back(newStroke);
}
for (int i = 0; i < strokes.size(); ++i)
{
drawStroke(strokes[i]);
}
}
void drawStroke(Stroke * currentStroke)
{
std::vector<int> roundIds;
//Fill roundIds
//Some loops and conditions
for (int i = 0; i < roundIds.size(); ++i)
{
if (/*Check condition*/)
{
// Exception is raised deeper in the stack here
currentStroke->pixelIds.push_back(currentRoundId);
}
}
}
我忽略了代码的大部分,这些部分不应该真正影响这一点,因为我不知道问题可能来自何处(所以我必须复制/粘贴整个代码:D)。在最后一行中,我在堆栈中随机更深入访问违规(_orphan_range std :: vector的方法)。
我在手表中没有看到弯曲式的任何问题,要点向量看起来很正常,颜色也是颜色,我想某些像素的内部值被损坏了(_myfirst = 0x000000000000000038c700 _myEnd = 0x00000000000000000000000000000000000000000000000000000000000000000000 c不太好我,但我不确定)。
我对STL的细节不是很有经验,我不知道要寻找什么与向量的内部值混乱。
任何建议或建议将不胜感激!谢谢!
myfunct具有一个无尽的循环,可以填充stoke vector,直到您离开内存。
相关文章:
- 通过方法访问结构
- 使用不带参数的函数访问结构元素
- 如果我只是不访问queue_front节点的子节点,而是将它们推到队列中呢?还是BFS吗
- 用于访问容器<T>数据成员的正确 API
- 访问者访问变体并返回不同类型时出错
- 尝试通过多个向量访问变量时,向量下标超出范围
- 无法访问嵌套类.类的使用无效
- 写入位置0x0000000C时发生访问冲突
- 我们可以访问一个不存在的联盟的成员吗
- C++从另一个类访问公共静态向量的正确方法是什么
- 我的简单if-else语句是如何无法访问的代码
- 从C++dll访问C#中的一行主要参数
- 概念TS检查忽略私有访问修饰符
- 访问被拒绝后,c++中的故障保护代码
- 在c++中访问int到类对象的映射时出错
- 我想访问std::unique_ptr中的一个特定元素
- 为什么示例代码访问IUnknown中已删除的内存
- C++:无法访问声明的受保护成员
- 通过指向指针数组的指针访问子类的属性
- 如何使用单独文件中的派生类访问友元函数对象