我在运行特定程序时出现seg错误:11。我觉得像我之前升级我的系统的Mac OS X 10.9这个问题是不存在的,但它可能只是我忽略了它..函数结束后的seg fault(C++)
无论如何,我的函数看起来像:
// this applies a warp to the field given, and saves output. simple!
void Apply(string warpName, string fieldName, bool conserve, string outName) {
// get lon, lat dimensions of warp
int noLongs = GetDimension(warpName, 3, "warp");
int noLats = GetDimension(warpName, 2, "warp");
int origNoLongs = noLongs, origNoLats = noLats;
// read in params
vector<double> params = ImportWarpFromNetCDF(warpName);
// rescale field to warp's dimensions, and read in
string tempName = "scaledField";
ReScale(fieldName, tempName, noLongs, noLats);
vector<vector<vector<double> > >inIntensities = ImportFieldFromNetCDF(tempName);
RemoveFile(tempName);
// just enter inIntensities for ref image, and 1 for lambda, to keep objective function happy
ObjectiveFunction objective(inIntensities, inIntensities, conserve, 1, false);
objective.setParameters(params);
// output files
ExportOutputToNetCDF(objective, outName);
cout << "BAH?!" << endl;
}
其中COUT最后一行只是检查我是否已经正确地结束了函数(我有)。任何想法为什么这将在这里segfaulting?我很欣赏可能很难说没有看到个别函数调用了什么,所以我会在必要时添加这些函数。
它实际上并没有太大的关系,因为该功能被称为(所以赛格故障不会中断任何东西)的最后一件事,但我还是宁愿得到它的底部!
如果'cout'之后,但返回的功能之前,那么这将是在局部变量之一的析构函数的段错误发生。你的调试器应该告诉你它到底发生了什么。 –