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

 
 

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

Submitter:  Dmitry Messerman <mdmitry>
Submitted:  Sun 14 Jun 2015 06:28:02 AM UTC
   
 
Category:  Libraries Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Segfault, Bus Error, etc.
Status:  None Assigned to:  None
Originator Name:  Dmitry Messerman Open/Closed:  * Closed
Release:  * 3.8.2 Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

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>
Group 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 Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-06-15 rik5 Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code