Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/127.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 指针错误时程序意外关闭_C++_Qt_Pointers_User Interface_Fork - Fatal编程技术网

C++ 指针错误时程序意外关闭

C++ 指针错误时程序意外关闭,c++,qt,pointers,user-interface,fork,C++,Qt,Pointers,User Interface,Fork,我正在通过单击()上的GUI创建此类的实例。它应该是fork()一系列其他进程。它运行正常,直到GUI关闭并出现错误为止: free():无效指针:0x000000000209c608 我理解这意味着程序正试图访问一个禁止访问的内存位置。我正在使用QT creator,但似乎无法使调试器正常工作。代码如下: scriptfilefeed::scriptfilefeed() { } scriptfilefeed::scriptfilefeed(vector<vector<vector

我正在通过单击()上的GUI
创建此类的实例。它应该是
fork()
一系列其他进程。它运行正常,直到GUI关闭并出现错误为止:

free():无效指针:0x000000000209c608


我理解这意味着程序正试图访问一个禁止访问的内存位置。我正在使用QT creator,但似乎无法使调试器正常工作。代码如下:

scriptfilefeed::scriptfilefeed() { }

scriptfilefeed::scriptfilefeed(vector<vector<vector<string> > > & newFeed, double trimParam1, unsigned int trimParam2)
{
    const string min = "<TMIN>";
    const string max = "<TMAX>";
    bla[0] = "6";
    bla[1] = "47";

    input.clear();

    for (int i = 0; i < newFeed.size(); i++)
    {
        if (i == 1)
        { // then we first need to run trimlowQ to get arguments

        }
        input.clear();

        for (int j = 0; j < newFeed[i].size(); j++)
        {
            for (int k = 0; k < newFeed[i][j].size(); k++)
            {
                curstr = newFeed[i][j][k];
                input.push_back(curstr.c_str());

                if (i == 1 && input.at(j) == min)
                { // const string comp.for trim parameters
                    input.pop_back(); // remove last element
                    input.push_back(bla[0]); // insert this instead
                }

                if (i == 1 && input.at(j) == max)
                {
                    input.pop_back(); // remove last element
                    input.push_back(bla[1]);
                }
                cout << newFeed[i][j][k] << endl;
            }

        }

        while (input.size() <= 13)
        {
            input.push_back(0);
        }

        cout << "Starting Process: " << input.at(1) << endl;
        child = fork();

        int ret;
        if (child == 0)
        {
            ret = execl(input.at(0), input.at(1), input.at(2), input.at(3), input.at(4), input.at(5), input.at(6), input.at(7), input.at(8), input.at(9), input.at(10), input.at(11), input.at(12));
            printf("failed... ret=%d\n", ret);
            perror("this error occured:");
        }

        bool childEnded = false;
        while (childEnded == false)
        {
            int status;
            int result = waitpid(child, &status, WNOHANG);
            if (result == 0)
            {
                // keep going
            }
            else if (result == -1)
            {
                // continue
            }
            else
            {
                childEnded = true;
                cout << "Process Finished" << endl;
            }
        }
    }
}
scriptfilefeed::scriptfilefeed(){}
scriptfilefeed::scriptfilefeed(向量和newFeed、双trimParam1、无符号int trimParam2)
{
常量字符串min=“”;
常量字符串max=“”;
bla[0]=“6”;
bla[1]=“47”;
input.clear();
对于(int i=0;icout“我正在使用QT creator,但似乎无法使调试器正常工作。”-这是您在执行任何其他操作之前首先要解决的问题。那么什么是“bla”?为什么不使用
static const char*minValue=“6”;static const char*maxValue=“47”
并使用push_back中的命名变量,而不是高度不可读的
push_back(bla[1]);
例如。输入是一个字符串向量,对应于我输入Execl()的参数运行每个进程。我可以确认它是否按计划工作,并且在崩溃之前所有进程都已完成。A
vector
?或
vector
?向量的条目将转换为常量字符*: