Domanda

I'm having a seg fault: 11 when I run a particular program. I feel like this problem wasn't present before I upgraded my system to Mac OS X 10.9, but it's possible I just overlooked it..

Anyway, my function looks like:

// 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;

}

where the cout line at the end was just checking to see I'd got to the end of the function properly (which I have). Any thoughts on why this would be segfaulting here? I appreciate it might be hard to tell without seeing what the individual function calls do, and so I'll add those if necessary.

It doesn't actually matter too much, as this function is the last thing to be called (so the seg fault doesn't interrupt anything), but I still would rather get to the bottom of it!

È stato utile?

Soluzione

The only thing that happens "after" the function are destructor calls. Check all your destructors of local variables. It looks like ObjectiveFunction is the only local variable that's not a primitive or standard library container, so check ObjectiveFunction::~ObjectiveFunction() for potential problems.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top