bugGNU Octave - Bugs: bug #45318, Unable to save HDF5 file using C++...

 
 

bug #45318: Unable to save HDF5 file using C++ API

Submitted by:  Dmitry Messerman <mdmitry>
Submitted on:  Sun 14 Jun 2015 06:28:02 AM UTC  
 
Category: LibrariesSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Segfault, Bus Error, etc.
Status: NoneAssigned to: None
Originator Name: Dmitry MessermanOpen/Closed: Closed
Release: 3.8.2Operating System: GNU/Linux

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Tue 16 Jun 2015 06:10:17 AM UTC, comment #3:

Sure - thanks!

Dmitry Messerman <mdmitry>
Mon 15 Jun 2015 06:59:20 PM UTC, comment #2:

I think you've figured out an acceptable workaround.

Rik <rik5>
Project Administrator
Sun 14 Jun 2015 12:23:49 PM UTC, comment #1:

Update:

I've succeeded solution myself.
Code, attached at the end of this message works.
Unless I'm missing something here, the issue is interface inconsistency.
Namely, opening file for consequent HDF5 write should be done differently.

Regards,
Dmitry

#include <fstream>
#include <string>
#include <octave/oct.h>
#include <octave/octave.h>
#include <octave/toplev.h>
#include <octave/load-save.h>
#include <octave/parse.h>
#include <octave/ls-hdf5.h>

using namespace std;

typedef symbol_table::symbol_record OctaveSymbolRecord;

int main (int argc, char** argv)
{

auto A = ComplexNDArray(dim_vector(10,20));

OctaveSymbolRecord a_record = OctaveSymbolRecord(0, string("A"), octave_value(A));

hdf5_ofstream ofs(argv[1]);
if( ofs.file_id > 0 ) {
load_save_format fmt = load_save_format(LS_HDF5);
write_header(ofs, fmt);
do_save(ofs, a_record, fmt, false);
} else {
cerr << "ERROR: failed to open " << argv[1] << " for writing" << endl;
}
ofs.close();

return 0;
}

Dmitry Messerman <mdmitry>
Sun 14 Jun 2015 06:28:02 AM UTC, original submission:

Hi,

The following code fails at runtime:
#include <fstream>
#include <string>
#include <octave/oct.h>
#include <octave/octave.h>
#include <octave/toplev.h>
#include <octave/load-save.h>
#include <octave/parse.h>

using namespace std;

typedef symbol_table::symbol_record OctaveSymbolRecord;

int main (int argc, char** argv)
{

auto A = ComplexNDArray(dim_vector(10,20));
OctaveSymbolRecord a_record = OctaveSymbolRecord(0, string("A"), octave_value(A));

ofstream ofs;
ofs.open("a.octave_bin",ofstream::out);
if( !ofs.good() ) {
cerr << "ERROR: failed to open " << argv[2] << " for writing" << endl;
return 1;
}
//load_save_format fmt = load_save_format(LS_BINARY);
load_save_format fmt = load_save_format(LS_HDF5);
write_header(ofs, fmt);
do_save(ofs, a_record, fmt, false);
ofs.close();

return 0;
}

Error message is:
terminate called after throwing an instance of 'std::bad_cast'
what(): std::bad_cast

My assumption is that problem is with HDF5 format support, as after changing format to LS_BINARY crash goes away.

Please, advise.

Thanks,
Dmitry

Dmitry Messerman <mdmitry>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by mdmitry (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follows 1 latest change.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 15 Jun 2015 06:59:20 PM UTCrik5Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1