C++:vector <string>*args = new vector <string>(); 导致SIGABRT

Jus*_*kva 3 c++ new-operator stdvector sigabrt

非常自我解释.这是导致'new vector'行上的SIGABRT的方法:

vector<string> * Task::arguments() {
    vector<string> *args = new vector<string>(); // CAUSES SIGABRT
    int count = sizeof(_arguments);
    for (int x = 0; x < count; x++) {
        string argument(_arguments[x]);
        args->push_back(argument);
    }
    return args;
}
Run Code Online (Sandbox Code Playgroud)

请注意,在其他地方我称之为确切的行没有任何问题.以下是Task类中包含的列表:

#include <vector>
#include <unistd.h>
#include <string>
using namespace std;
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
Run Code Online (Sandbox Code Playgroud)

有什么想法吗?

sbi*_*sbi 6

这段代码中没有真正的错误,虽然样式表明你迫切需要一本好的C++书.

正如@James在对这个问题的评论中所说,使用动态分配的矢量对象几乎肯定是错误的,并且不将它保存在智能指针中肯定是错误的.
如果你在你的代码中的其他地方也这样做了,你很可能搞乱了堆,这是我能想到什么时候new崩溃的唯一情况.