Hello --
I've got some C++ code which has worked on OSX 10.6, as well as a
couple of linux machines. This weekend, I upgraded to OSX 10.7 Lion,
and now my code crashes (gdb trace below). I posted about this
function of mine a little while ago, but didn't get any responses:
"Is there a better way to read a vector of strings?"
http://mail.hdfgroup.org/pipermail/hdf-forum_hdfgroup.org/2011-June/004778.html
So since my code is crashing, and presumably the HDF5 people have good
unit tests, my code is doing something incorrectly... Can anybody give
me some suggestions?
thanks!
Amos.
void
SolutionSet::
loadBinaryFile(const std::string& filename,
energy::pEnergyModel model) {
H5::H5File file (filename, H5F_ACC_RDONLY);
H5::StrType st(H5::PredType::C_S1, H5T_VARIABLE);
H5::DataType dt = H5::PredType::NATIVE_DOUBLE;
hsize_t dims[1];
H5::DataSet dataset;
dataset = file.openDataSet(_H5_scores);
dataset.getSpace().getSimpleExtentDims(dims, NULL);
Vector_double scores (dims[0]); // this is just
std::vector<double>
dataset.read(&scores[0],dt);
for(std::size_t i=0; i<scores.size(); i++){
std::stringstream confName;
confName << _H5_conf << i;
dataset = file.openDataSet(confName.str());
dataset.getSpace().getSimpleExtentDims(dims, NULL);
Vector_string conf(dims[0]); // this is just
std::vector<std::string>
for(std::size_t j=0; j<dims[0]; j++){
H5::DataSpace file_space = dataset.getSpace();
hsize_t count[1] = {1};
hsize_t start[1] = {j};
file_space.selectHyperslab(H5S_SELECT_SET,count,start);
hsize_t dim1[1] = {1};
H5::DataSpace mem_space(1,dim1);
dataset.read(conf[j],st,mem_space,file_space); // this is
line 393
}
std::stringstream crdName;
crdName << _H5_coords << i;
dataset = file.openDataSet(crdName.str());
dataset.getSpace().getSimpleExtentDims(dims, NULL);
Vector_double coords(dims[0]);
dataset.read(&coords[0],dt);
deserialize(model,conf,coords,scores[i]);
}
}
Python(85973) malloc: *** error for object 0x103ff2820: pointer being
freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Program received signal SIGABRT, Aborted.
0x00007fff8ec7282a in __kill ()
(gdb) where
#0 0x00007fff8ec7282a in __kill ()
#1 0x00007fff8d999a9c in abort ()
#2 0x00007fff8d9f884c in free ()
#3 0x00007fff8c3fb702 in std::string::_Rep::_M_dispose ()
#4 0x00007fff8c3fcaab in std::string::_M_mutate ()
#5 0x00007fff8c3fcb2d in std::string::_M_replace_safe ()
#6 0x000000010412c175 in H5::DataSet::p_read_variable_len ()
#7 0x000000010412e660 in H5::DataSet::read ()
#8 0x00000001004d8ccc in triad::opt::SolutionSet::loadBinaryFile
(this=0x7fff5fbfeba0, filename=@0x1315c6c90, model=@0x7fff5fbfeba0) at
SolutionSet.cc:393