调试失败:_CrtIsValidHeapPointer(pUserData) [英] Debug Assertion Failed: _CrtIsValidHeapPointer(pUserData)

查看:256
本文介绍了调试失败:_CrtIsValidHeapPointer(pUserData)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时在调试模式下运行我的Qt项目时遇到Debug Assertion Failed错误(图片)。
我不知道在哪里错了,因为编译器什么也没说,我不知道该怎么做,以找到我的错误。

Sometimes I get this "Debug Assertion Failed" error running my Qt project in debug mode (image). I don't know where I wrong because the compiler says nothing and I don't know what to do to find my error.

我在Windows下编程Vista,使用Qt Creator 2.4.1,Qt 4.8.1。

I program under Windows Vista, using Qt Creator 2.4.1, Qt 4.8.1.

我的程序必须从激光设备读取一些信息,并将它们保存到一个文件中,到这个:

My program has to read some informations from a laser device and save them into a file with a code similar to this:

void runFunction()
{
    configure_Scanning(...);

    while(...)
    {
        // do something
        scanFunction();
        // do something
    }
}

我的incheminated函数(我认为问题是)

and this is my "incriminated" function (where I think the problem is)

void scanFunction()
{
    file.open();

    data = getDataFromDevice();

    if(flag)
    {
        if(QString::compare(lineB,"")!=0)
        {
            QTextStream out(&file);
            out << lineB << endl;
            lineB = "";
        }
        lineA.append(data+"\t");
    }
    else
    {
        if(QString::compare(lineA,"")!=0)
        {
            QTextStream out(&file);
            out << lineA << endl;
            lineA = "";
        }
        lineB.prepend(data+"\t");
    }

    file.close();
}

其中 lineA em>最初是两个void QString:我的想法是,我做一个双向扫描来保存信息在2D矩阵(从-X到​​+ X和反之亦然,而Y去指定的目标)。 lineA 会记住( - )到(+)的读数; lineB 将(+)存储到( - )读数。当扫描方向改变时,我将 lineA (或 lineB )写入文件,然后继续扫描。

Where lineA and lineB are initially two void QString: the idea is that I make a bidirectional scanning to save informations in a 2D matrix (from -X to +X and viceversa, while Y goes to a specified target). lineA memorizes the (-)to(+) reading; lineB memorizes the (+)to(-) reading. When the scanning direction changes, I write lineA (or lineB) to the file and I proceed with the scanning.

你明白我说的话吗?

感谢并对不起我的英语:P

Thanks and sorry for my English :P

推荐答案

_CrtIsValidHeapPointerUserData意味着,你有一个堆损坏,这是通过调试堆检查器注意到。怀疑可以将任何信息写入任何已删除的动态对象的每个人。
是的,你会收到heap corruction不会记住重写发生,但在下一个堆检查,这将在任何下一个内存分配/释放执行。但是应该通过单线程应用程序中的调用堆栈来简单跟踪。

_CrtIsValidHeapPointerUserData means, that you have a heap corruption, which is noticed by debug heap checker. Suspect everybody who can write any information into any deleted dynamic object. And yes, you'll receive heap corruction not immideately on rewrite occurs, but on the next heap check, which will be performed on any next memory allocation/deallocation. However should be simply tracked by a call stack in single threaded applications.

这篇关于调试失败:_CrtIsValidHeapPointer(pUserData)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆