# My code crashes upon upgrade to OSX 10.7 Lion

**URL:** <https://forum.hdfgroup.org/t/my-code-crashes-upon-upgrade-to-osx-10-7-lion/2293>\
**Category:** Hdf-forum archives\
**Created:** [September 6, 2011, 11:55pm UTC](https://forum.hdfgroup.org/t/my-code-crashes-upon-upgrade-to-osx-10-7-lion/2293 "2011-09-06T23:55:14Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amos\_Anderson](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/a/8797f3/32.png) [@Amos\_Anderson](https://forum.hdfgroup.org/u/Amos_Anderson)\
**Post date:** [September 6, 2011, 11:55pm UTC](https://forum.hdfgroup.org/t/my-code-crashes-upon-upgrade-to-osx-10-7-lion/2293/1 "2011-09-06T23:55:14Z")

</div>

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](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,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;energy::pEnergyModel model) {  
&nbsp;&nbsp;&nbsp;H5::H5File file (filename, H5F\_ACC\_RDONLY);  
&nbsp;&nbsp;&nbsp;H5::StrType st(H5::PredType::C\_S1, H5T\_VARIABLE);  
&nbsp;&nbsp;&nbsp;H5::DataType dt = H5::PredType::NATIVE\_DOUBLE;  
&nbsp;&nbsp;&nbsp;hsize\_t dims[1];  
&nbsp;&nbsp;&nbsp;H5::DataSet dataset;

&nbsp;&nbsp;&nbsp;dataset = file.openDataSet(\_H5\_scores);  
&nbsp;&nbsp;&nbsp;dataset.getSpace().getSimpleExtentDims(dims, NULL);  
&nbsp;&nbsp;&nbsp;Vector\_double scores (dims[0]); // this is just  
std::vector\<double\>  
&nbsp;&nbsp;&nbsp;dataset.read(&scores[0],dt);

&nbsp;&nbsp;&nbsp;for(std::size\_t i=0; i\<scores.size(); i++){  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::stringstream confName;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;confName \<\< \_H5\_conf \<\< i;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dataset = file.openDataSet(confName.str());  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dataset.getSpace().getSimpleExtentDims(dims, NULL);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Vector\_string conf(dims[0]); // this is just  
std::vector\<std::string\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for(std::size\_t j=0; j\<dims[0]; j++){  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;H5::DataSpace file\_space = dataset.getSpace();  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hsize\_t count[1] = {1};  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hsize\_t start[1] = {j};  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;file\_space.selectHyperslab(H5S\_SELECT\_SET,count,start);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hsize\_t dim1[1] = {1};  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;H5::DataSpace mem\_space(1,dim1);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dataset.read(conf[j],st,mem\_space,file\_space); // this is  
line 393  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::stringstream crdName;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;crdName \<\< \_H5\_coords \<\< i;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dataset = file.openDataSet(crdName.str());  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dataset.getSpace().getSimpleExtentDims(dims, NULL);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Vector\_double coords(dims[0]);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dataset.read(&coords[0],dt);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;deserialize(model,conf,coords,scores[i]);  
&nbsp;&nbsp;&nbsp;}  
}

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

---

<div class="post-metadata">

**Author:** ![sean](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/s/f0a364/32.png) [@sean](https://forum.hdfgroup.org/u/sean)\
**Post date:** [September 7, 2011, 1:59pm UTC](https://forum.hdfgroup.org/t/my-code-crashes-upon-upgrade-to-osx-10-7-lion/2293/2 "2011-09-07T13:59:52Z")

</div>

Did you set that breakpoint? On Mac OS, these kinds of bugs can often be found more easily using the env vars documented in 'man malloc' and by using guard malloc, documented in 'man libgmalloc'.

> **···**
>
> On Tue, 6 Sep 2011 16:55:14 -0700, Amos Anderson said:
> 
> > Python(85973) malloc: \*\*\* error for object 0x103ff2820: pointer being  
> > freed was not allocated  
> > \*\*\* set a breakpoint in malloc\_error\_break to debug
> 
> --  
> \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> Sean McBride, B. Eng sean@rogue-research.com  
> Rogue Research [www.rogue-research.com](http://www.rogue-research.com)  
> Mac Software Developer Montréal, Québec, Canada

---

<div class="post-metadata">

**Author:** ![bmribler](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/b/a6a055/32.png) [@bmribler](https://forum.hdfgroup.org/u/bmribler)\
**Post date:** [September 7, 2011, 6:32pm UTC](https://forum.hdfgroup.org/t/my-code-crashes-upon-upgrade-to-osx-10-7-lion/2293/3 "2011-09-07T18:32:06Z")

</div>

Hello Amos,

I'm trying to help figuring out the crash problem. Would that be possible  
for you to send me your data file so I can investigate further?

Thanks,  
Binh-Minh

> **···**
>
> -------------  
> The HDF Group
> 
> -----Original Message-----  
> From: [hdf-forum-bounces@hdfgroup.org](mailto:hdf-forum-bounces@hdfgroup.org) [[mailto:hdf-forum-bounces@hdfgroup.org](mailto:hdf-forum-bounces@hdfgroup.org)]  
> On Behalf Of Amos Anderson  
> Sent: Tuesday, September 06, 2011 7:55 PM  
> To: [hdf-forum@hdfgroup.org](mailto:hdf-forum@hdfgroup.org); HDF Helpdesk  
> Subject: [Hdf-forum] My code crashes upon upgrade to OSX 10.7 Lion
> 
> 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.h](http://mail.hdfgroup.org/pipermail/hdf-forum_hdfgroup.org/2011-June/004778.h)  
> tml
> 
> 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,  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;energy::pEnergyModel model) {  
> &nbsp;&nbsp;&nbsp;H5::H5File file (filename, H5F\_ACC\_RDONLY);  
> &nbsp;&nbsp;&nbsp;H5::StrType st(H5::PredType::C\_S1, H5T\_VARIABLE);  
> &nbsp;&nbsp;&nbsp;H5::DataType dt = H5::PredType::NATIVE\_DOUBLE;  
> &nbsp;&nbsp;&nbsp;hsize\_t dims[1];  
> &nbsp;&nbsp;&nbsp;H5::DataSet dataset;
> 
> &nbsp;&nbsp;&nbsp;dataset = file.openDataSet(\_H5\_scores);  
> &nbsp;&nbsp;&nbsp;dataset.getSpace().getSimpleExtentDims(dims, NULL);  
> &nbsp;&nbsp;&nbsp;Vector\_double scores (dims[0]); // this is just  
> std::vector\<double\>  
> &nbsp;&nbsp;&nbsp;dataset.read(&scores[0],dt);
> 
> &nbsp;&nbsp;&nbsp;for(std::size\_t i=0; i\<scores.size(); i++){  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::stringstream confName;  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;confName \<\< \_H5\_conf \<\< i;  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dataset = file.openDataSet(confName.str());  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dataset.getSpace().getSimpleExtentDims(dims, NULL);  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Vector\_string conf(dims[0]); // this is just  
> std::vector\<std::string\>  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for(std::size\_t j=0; j\<dims[0]; j++){  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;H5::DataSpace file\_space = dataset.getSpace();  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hsize\_t count[1] = {1};  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hsize\_t start[1] = {j};  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;file\_space.selectHyperslab(H5S\_SELECT\_SET,count,start);  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hsize\_t dim1[1] = {1};  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;H5::DataSpace mem\_space(1,dim1);  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dataset.read(conf[j],st,mem\_space,file\_space); // this is  
> line 393  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::stringstream crdName;  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;crdName \<\< \_H5\_coords \<\< i;  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dataset = file.openDataSet(crdName.str());  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dataset.getSpace().getSimpleExtentDims(dims, NULL);  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Vector\_double coords(dims[0]);  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dataset.read(&coords[0],dt);
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;deserialize(model,conf,coords,scores[i]);  
> &nbsp;&nbsp;&nbsp;}  
> }
> 
> 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
> 
> \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> Hdf-forum is for HDF software users discussion.  
> [Hdf-forum@hdfgroup.org](mailto:Hdf-forum@hdfgroup.org)  
> [http://mail.hdfgroup.org/mailman/listinfo/hdf-forum\_hdfgroup.org](http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org)
> 
> --  
> Internal Virus Database is out-of-date.  
> Checked by AVG.  
> Version: 7.5.549 / Virus Database: 270.9.0/1778 - Release Date: 11/9/2008  
> 2:14 PM

---

<div class="post-metadata">

**Author:** ![Amos\_Anderson](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/a/8797f3/32.png) [@Amos\_Anderson](https://forum.hdfgroup.org/u/Amos_Anderson)\
**Post date:** [September 8, 2011, 1:15am UTC](https://forum.hdfgroup.org/t/my-code-crashes-upon-upgrade-to-osx-10-7-lion/2293/4 "2011-09-08T01:15:32Z")

</div>

Hello Binh-Minh --

I extracted a unit test for myself which is completely independent of  
our code, and I've attached it. However, this unit test passes  
(there's no crash). This implies that the problem depends on something  
else in our code.... Unfortunately, valgrind has not been updated to  
work with OSX Lion yet... so no help there.

However, if I insert an extra line:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;H5::DataSpace mem\_space(1,dim1);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;conf[j] = std::string("this is a long string"); // the extra line  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dataset.read(conf[j],st,mem\_space,file\_space);

i.e. initializing the std::string to something other than ""

Then my original code produces the correct result...

but then if I replace that line with:  
conf[j] = std::string("");

then I get the crash. So I guess the question is how well HDF5 can  
work with std::string instead of char\*.... because the string ends up  
with the right length when I initialized it to "this is a long  
string", but if it's "" then it can't resize it?

Hi Sean --

> Did you set that breakpoint? On Mac OS, these kinds of bugs can often be found more easily using the env vars documented in 'man malloc' and by using guard malloc, documented in 'man libgmalloc'.

Yes, I did set the breakpoint, but it didn't give me any new  
information. I'll have to give those env variables a try if we can't  
figure it out without them.

Amos.

[hdf5\_str.cc](https://hdf-discourse-1.s3.amazonaws.com/original/1X/24c27ae98ad97d263c4a2fb978fd48d4fc233aaa.cc) (2.52 KB)

[test.solns](https://hdf-discourse-1.s3.amazonaws.com/original/1X/f363da2c24d00dfaf3a6d26e27447fc7c611477c.solns) (1.85 MB)

> **···**
>
> On Wed, Sep 7, 2011 at 11:32 AM, Binh-Minh Ribler \<bmribler@hdfgroup.org\> wrote:
> 
> > Hello Amos,
> > 
> > I'm trying to help figuring out the crash problem. Would that be possible  
> > for you to send me your data file so I can investigate further?
> > 
> > Thanks,  
> > Binh-Minh  
> > -------------  
> > The HDF Group
> > 
> > -----Original Message-----  
> > From: hdf-forum-bounces@hdfgroup.org [mailto:hdf-forum-bounces@hdfgroup.org]  
> > On Behalf Of Amos Anderson  
> > Sent: Tuesday, September 06, 2011 7:55 PM  
> > To: hdf-forum@hdfgroup.org; HDF Helpdesk  
> > Subject: [Hdf-forum] My code crashes upon upgrade to OSX 10.7 Lion
> > 
> > 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.h](http://mail.hdfgroup.org/pipermail/hdf-forum_hdfgroup.org/2011-June/004778.h)  
> > tml
> > 
> > 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 &lt;&lt; \_H5\_coords &lt;&lt; i;
> > dataset = file\.openDataSet\(crdName\.str\(\)\);
> > dataset\.getSpace\(\)\.getSimpleExtentDims\(dims, NULL\);
> > Vector\_double coords\(dims\[0\]\);
> > dataset\.read\(&amp;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
> > 
> > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> > Hdf-forum is for HDF software users discussion.  
> > Hdf-forum@hdfgroup.org  
> > [http://mail.hdfgroup.org/mailman/listinfo/hdf-forum\_hdfgroup.org](http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org)
> > 
> > --  
> > Internal Virus Database is out-of-date.  
> > Checked by AVG.  
> > Version: 7.5.549 / Virus Database: 270.9.0/1778 - Release Date: 11/9/2008  
> > 2:14 PM
> > 
> > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> > Hdf-forum is for HDF software users discussion.  
> > Hdf-forum@hdfgroup.org  
> > [http://mail.hdfgroup.org/mailman/listinfo/hdf-forum\_hdfgroup.org](http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org)
> 
> --  
> ~\<\>~\<\>~\<\>~\<\>~\<\>~\<\>~\<\>~\<\>~  
> Amos G. Anderson  
> +1-626-399-8958 (cell)

---

<div class="post-metadata">

**Author:** ![Bojan\_Nikolic](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/b/3ab097/32.png) [@Bojan\_Nikolic](https://forum.hdfgroup.org/u/Bojan_Nikolic)\
**Post date:** [September 28, 2011, 10:48am UTC](https://forum.hdfgroup.org/t/my-code-crashes-upon-upgrade-to-osx-10-7-lion/2293/5 "2011-09-28T10:48:38Z")

</div>

I haven't had the time to test this hypothesis but looking at the HDF5  
C++ wrapping code it looks like it may not be terminating the string  
before converting to C++ std::string if the H5Dread doesn't do that by  
itself for some reason. Maybe worth trying this patch?

\*\*\* hdf5-1.8.7/c++/src/H5DataSet-fix.cpp 2011-09-28 11:44:09.000000000 +0100  
--- hdf5-1.8.7/c++/src/H5DataSet.cpp 2011-04-20 22:23:08.000000000 +0100

> **···**
>
> \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> \*\*\* 721,729 \*\*\*\*  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;throw DataSetIException("DataSet::read", "H5Dread failed for fixed length string");  
> &nbsp;&nbsp;&nbsp;&nbsp;}  
> &nbsp;&nbsp;  
> - // Terminate the string  
> - strg\_C[attr\_size]=0;  
> -  
> &nbsp;&nbsp;&nbsp;&nbsp;// Get string from the C char\* and release resource allocated locally  
> &nbsp;&nbsp;&nbsp;&nbsp;strg = strg\_C;  
> &nbsp;&nbsp;&nbsp;&nbsp;delete []strg\_C;  
> --- 721,726 ----
> 
> --  
> Bojan Nikolic || [http://www.bnikolic.co.uk](http://www.bnikolic.co.uk)

---

<div class="post-metadata">

**Author:** ![Amos\_Anderson](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/a/8797f3/32.png) [@Amos\_Anderson](https://forum.hdfgroup.org/u/Amos_Anderson)\
**Post date:** [September 28, 2011, 5:28pm UTC](https://forum.hdfgroup.org/t/my-code-crashes-upon-upgrade-to-osx-10-7-lion/2293/6 "2011-09-28T17:28:52Z")

</div>

Hi Bojan --

The crash is not happening in DataSet::p\_read\_fixed\_len. I tried a  
bunch of things with Binh-Minh Ribler, but we were unable to resolve  
it, but here's a summary. The crash is in DataSet::p\_read\_variable\_len  
on the line with:

strg = strg\_C;

The error is a double free on strg:

Python(10981) malloc: \*\*\* error for object 0x104010820: pointer being  
freed was not allocated  
\*\*\* set a breakpoint in malloc\_error\_break to debug  
[amosa:10981] \*\*\* Process received signal \*\*\*  
[amosa:10981] Signal: Abort trap: 6 (6)  
[amosa:10981] Signal code: (0)  
[amosa:10981] [0] 2 libsystem\_c.dylib  
0x00007fff8ce3bcfa \_sigtramp + 26  
[amosa:10981] [1] 3 libhdf5.7.dylib  
0x00000001042ec3f1 H5S\_select\_hyperslab + 1393  
[amosa:10981] [2] 4 libsystem\_c.dylib  
0x00007fff8ce3984c free + 389  
[amosa:10981] [3] 5 libstdc++.6.dylib  
0x00007fff8c8f3702 \_ZNSs4\_Rep10\_M\_disposeERKSaIcE + 60  
[amosa:10981] [4] 6 libstdc++.6.dylib  
0x00007fff8c8f4aab \_ZNSs9\_M\_mutateEmmm + 281  
[amosa:10981] [5] 7 libstdc++.6.dylib  
0x00007fff8c8f4b2d \_ZNSs15\_M\_replace\_safeEmmPKcm + 37  
[amosa:10981] [6] 8 libhdf5\_cpp.7.dylib  
0x000000010414af90 \_ZNK2H57DataSet19p\_read\_variable\_lenEiiiiRSs + 1316  
[amosa:10981] [7] 9 libhdf5\_cpp.7.dylib  
0x000000010414d5ea  
\_ZNK2H57DataSet4readERSsRKNS\_8DataTypeERKNS\_9DataSpaceES7\_RKNS\_19DSetMemXferPropListE  
+ 1286

The problem does not occur in a standalone unit test I made (and there  
is no problem on linux or osx 10.6). This implies the problem could be  
somewhere else in the rest of my code, but unfortunately valgrind  
doesn't work on osx 10.7 yet (and no problems have been detected on  
other machines). However, I can make the problem go away if I  
initialize the std::string in my code before calling DataSet::read:

&nbsp;&nbsp;&nbsp;H5::StrType st(H5::PredType::C\_S1, H5T\_VARIABLE);  
&nbsp;&nbsp;&nbsp;H5::DataSet dataset;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Vector\_string conf(dims[0]);  
#if \_\_ENVIRONMENT\_MAC\_OS\_X\_VERSION\_MIN\_REQUIRED\_\_ \>= 1070  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;conf[j] = "hack to avoid crash";  
#endif  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dataset.read(conf[j],st,mem\_space,file\_space);

Doing a google search on the error message itself along with a few  
keywords revealed this:

> <https://stackoverflow.com/questions/1962685/xcode-stl-c-debug-compile-error>

and other similar posts, problems which I am able to replicate, and  
sets a precedent for the problem being with the compiler itself. OSX  
10.7 in general has seemed somewhat buggy too...

Amos.

> **···**
>
> On Wed, Sep 28, 2011 at 3:48 AM, Bojan Nikolic \<bojan@bnikolic.co.uk\> wrote:
> 
> > I haven't had the time to test this hypothesis but looking at the HDF5  
> > C++ wrapping code it looks like it may not be terminating the string  
> > before converting to C++ std::string if the H5Dread doesn't do that by  
> > itself for some reason. Maybe worth trying this patch?
> > 
> > \*\*\* hdf5-1.8.7/c++/src/H5DataSet-fix.cpp 2011-09-28 11:44:09.000000000 +0100  
> > --- hdf5-1.8.7/c++/src/H5DataSet.cpp 2011-04-20 22:23:08.000000000 +0100  
> > \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> > \*\*\* 721,729 \*\*\*\*  
> > throw DataSetIException("DataSet::read", "H5Dread failed for fixed length string");  
> > }
> > 
> > - // Terminate the string  
> > - strg\_C[attr\_size]=0;  
> > -  
> > // Get string from the C char\* and release resource allocated locally  
> > strg = strg\_C;  
> > delete strg\_C;  
> > --- 721,726 ----
> > 
> > --  
> > Bojan Nikolic || [http://www.bnikolic.co.uk](http://www.bnikolic.co.uk)
> > 
> > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> > Hdf-forum is for HDF software users discussion.  
> > Hdf-forum@hdfgroup.org  
> > [http://mail.hdfgroup.org/mailman/listinfo/hdf-forum\_hdfgroup.org](http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org)
> 
> --  
> ~\<\>~\<\>~\<\>~\<\>~\<\>~\<\>~\<\>~\<\>~  
> Amos G. Anderson  
> +1-626-399-8958 (cell)

---

<div class="post-metadata">

**Author:** ![mike.jackson](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/mike.jackson/32/1734_2.png) [@mike.jackson](https://forum.hdfgroup.org/u/mike.jackson)\
**Post date:** [September 28, 2011, 5:41pm UTC](https://forum.hdfgroup.org/t/my-code-crashes-upon-upgrade-to-osx-10-7-lion/2293/7 "2011-09-28T17:41:56Z")

</div>

If you are running on OS X 10.6 where is conf[j] created/initialized? maybe the compiler is getting more picky in OS X 10.7?

> **···**
>
> \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> Mike Jackson [www.bluequartz.net](http://www.bluequartz.net)  
> Principal Software Engineer mike.jackson@bluequartz.net  
> BlueQuartz Software Dayton, Ohio
> 
> On Sep 28, 2011, at 1:28 PM, Amos Anderson wrote:
> 
> > Hi Bojan --
> > 
> > The crash is not happening in DataSet::p\_read\_fixed\_len. I tried a  
> > bunch of things with Binh-Minh Ribler, but we were unable to resolve  
> > it, but here's a summary. The crash is in DataSet::p\_read\_variable\_len  
> > on the line with:
> > 
> > strg = strg\_C;
> > 
> > The error is a double free on strg:
> > 
> > Python(10981) malloc: \*\*\* error for object 0x104010820: pointer being  
> > freed was not allocated  
> > \*\*\* set a breakpoint in malloc\_error\_break to debug  
> > [amosa:10981] \*\*\* Process received signal \*\*\*  
> > [amosa:10981] Signal: Abort trap: 6 (6)  
> > [amosa:10981] Signal code: (0)  
> > [amosa:10981] [0] 2 libsystem\_c.dylib  
> > 0x00007fff8ce3bcfa \_sigtramp + 26  
> > [amosa:10981] [1] 3 libhdf5.7.dylib  
> > 0x00000001042ec3f1 H5S\_select\_hyperslab + 1393  
> > [amosa:10981] [2] 4 libsystem\_c.dylib  
> > 0x00007fff8ce3984c free + 389  
> > [amosa:10981] [3] 5 libstdc++.6.dylib  
> > 0x00007fff8c8f3702 \_ZNSs4\_Rep10\_M\_disposeERKSaIcE + 60  
> > [amosa:10981] [4] 6 libstdc++.6.dylib  
> > 0x00007fff8c8f4aab \_ZNSs9\_M\_mutateEmmm + 281  
> > [amosa:10981] [5] 7 libstdc++.6.dylib  
> > 0x00007fff8c8f4b2d \_ZNSs15\_M\_replace\_safeEmmPKcm + 37  
> > [amosa:10981] [6] 8 libhdf5\_cpp.7.dylib  
> > 0x000000010414af90 \_ZNK2H57DataSet19p\_read\_variable\_lenEiiiiRSs + 1316  
> > [amosa:10981] [7] 9 libhdf5\_cpp.7.dylib  
> > 0x000000010414d5ea  
> > \_ZNK2H57DataSet4readERSsRKNS\_8DataTypeERKNS\_9DataSpaceES7\_RKNS\_19DSetMemXferPropListE  
> > + 1286
> > 
> > The problem does not occur in a standalone unit test I made (and there  
> > is no problem on linux or osx 10.6). This implies the problem could be  
> > somewhere else in the rest of my code, but unfortunately valgrind  
> > doesn't work on osx 10.7 yet (and no problems have been detected on  
> > other machines). However, I can make the problem go away if I  
> > initialize the std::string in my code before calling DataSet::read:
> > 
> > &nbsp;&nbsp;H5::StrType st(H5::PredType::C\_S1, H5T\_VARIABLE);  
> > &nbsp;&nbsp;H5::DataSet dataset;  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Vector\_string conf(dims[0]);  
> > #if \_\_ENVIRONMENT\_MAC\_OS\_X\_VERSION\_MIN\_REQUIRED\_\_ \>= 1070  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;conf[j] = "hack to avoid crash";  
> > #endif  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dataset.read(conf[j],st,mem\_space,file\_space);
> > 
> > Doing a google search on the error message itself along with a few  
> > keywords revealed this:  
> > [Xcode STL C++ Debug compile error - Stack Overflow](http://stackoverflow.com/questions/1962685/xcode-stl-c-debug-compile-error)  
> > and other similar posts, problems which I am able to replicate, and  
> > sets a precedent for the problem being with the compiler itself. OSX  
> > 10.7 in general has seemed somewhat buggy too...
> > 
> > Amos.
> > 
> > On Wed, Sep 28, 2011 at 3:48 AM, Bojan Nikolic \<bojan@bnikolic.co.uk\> wrote:
> > 
> > > I haven't had the time to test this hypothesis but looking at the HDF5  
> > > C++ wrapping code it looks like it may not be terminating the string  
> > > before converting to C++ std::string if the H5Dread doesn't do that by  
> > > itself for some reason. Maybe worth trying this patch?
> > > 
> > > \*\*\* hdf5-1.8.7/c++/src/H5DataSet-fix.cpp 2011-09-28 11:44:09.000000000 +0100  
> > > --- hdf5-1.8.7/c++/src/H5DataSet.cpp 2011-04-20 22:23:08.000000000 +0100  
> > > \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> > > \*\*\* 721,729 \*\*\*\*  
> > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;throw DataSetIException("DataSet::read", "H5Dread failed for fixed length string");  
> > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
> > > 
> > > - // Terminate the string  
> > > - strg\_C[attr\_size]=0;  
> > > -  
> > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Get string from the C char\* and release resource allocated locally  
> > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;strg = strg\_C;  
> > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;delete strg\_C;  
> > > --- 721,726 ----
> > > 
> > > --  
> > > Bojan Nikolic || [http://www.bnikolic.co.uk](http://www.bnikolic.co.uk)
> > > 
> > > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> > > Hdf-forum is for HDF software users discussion.  
> > > Hdf-forum@hdfgroup.org  
> > > [http://mail.hdfgroup.org/mailman/listinfo/hdf-forum\_hdfgroup.org](http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org)
> > 
> > --  
> > ~\<\>~\<\>~\<\>~\<\>~\<\>~\<\>~\<\>~\<\>~  
> > Amos G. Anderson  
> > +1-626-399-8958 (cell)
> > 
> > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> > Hdf-forum is for HDF software users discussion.  
> > Hdf-forum@hdfgroup.org  
> > [http://mail.hdfgroup.org/mailman/listinfo/hdf-forum\_hdfgroup.org](http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org)

---

<div class="post-metadata">

**Author:** ![sean](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/s/f0a364/32.png) [@sean](https://forum.hdfgroup.org/u/sean)\
**Post date:** [September 28, 2011, 5:54pm UTC](https://forum.hdfgroup.org/t/my-code-crashes-upon-upgrade-to-osx-10-7-lion/2293/8 "2011-09-28T17:54:10Z")

</div>

If you build valgrind from svn trunk, it now kinda works on 10.7.

Apple's dev tools have similar memory debugging tools. There are env vars that affect malloc, see 'man malloc' and there is guard malloc, see 'man libgmalloc'.

Either of those might help you track it down.

> **···**
>
> On Wed, 28 Sep 2011 10:28:52 -0700, Amos Anderson said:
> 
> > Python(10981) malloc: \*\*\* error for object 0x104010820: pointer being  
> > freed was not allocated
> > 
> > \*SNIP\*
> > 
> > The problem does not occur in a standalone unit test I made (and there  
> > is no problem on linux or osx 10.6). This implies the problem could be  
> > somewhere else in the rest of my code, but unfortunately valgrind  
> > doesn't work on osx 10.7 yet
> 
> --  
> \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> Sean McBride, B. Eng sean@rogue-research.com  
> Rogue Research [www.rogue-research.com](http://www.rogue-research.com)  
> Mac Software Developer Montréal, Québec, Canada
