bugGNU Octave - Bugs: bug #38789, segfault on exit after failing to...


bug #38789: segfault on exit after failing to load HDF5 file

Submitter:  Markus Appel <mappel>
Submitted:  Sat 20 Apr 2013 06:52:04 PM UTC
Category:  Libraries Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Segfault, Bus Error, etc.
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup

Jump to the original submission

Sat 12 Oct 2013 07:25:58 PM UTC, comment #8: 

Markus, I tested your patch against the example attached to this bug report and it worked for me.  I applied your changeset here (http://hg.savannah.gnu.org/hgweb/octave/rev/d0a197b9962a).  I amended the commit message to also include the file name and function that was modified and what was done.  Generally the first line of the commit message is generic ("fixed bug #####") and the rest of the commit message contains some small detail on a per function basis about what was done.

I'm closing the report and also marking it off the Bug Fix List for the 3.8 release.  Thanks for the patch.

Rik <rik5>
Group administrator
Sat 12 Oct 2013 07:15:29 PM UTC, comment #7: 

The segfault on exit (without this patch applied) only occurs for me when using HDF5 built with one of the MPI libraries, not with the ordinary non-MPI HDF5.

With the patch applied, load works and no segfault on exit with either MPI or non-MPI HDF5.

Mike Miller <mtmiller>
Group Member
Sat 12 Oct 2013 07:09:52 PM UTC, comment #6: 

Patch applies cleanly for me, and I can now load the attached file that used to cause octave to crash.

On the current tip, without this patch, it no longer crashes for me but does throw an error:

octave:1> load dmc02.h5
error: load: range error for insert

Mike Miller <mtmiller>
Group Member
Sat 12 Oct 2013 05:51:55 PM UTC, comment #5: 

I haven't tested it, but the patch looks OK to me.

John W. Eaton <jwe>
Group administrator
Sun 06 Oct 2013 01:30:19 AM UTC, comment #4: 

I attached a small patch for loading fixed length string arrays from (3rd party) hdf5 files, the space for \0 was missing. Also, the octave charMatrix gets initialized with blanks to accommodate shorter rows.

I am still not sure whether the segfault was caused by the wrong string length or incorrect error handling during the loading process.

(file #29302)

Markus Appel <mappel>
Mon 30 Sep 2013 01:22:43 AM UTC, comment #3: 

Confirming the crash, agree that we should address the crash on exit. Also agree that Octave is not expected to read all HDF files.

Mike Miller <mtmiller>
Group Member
Sun 21 Apr 2013 11:34:34 AM UTC, comment #2: 

The crash is mostly the reason why I posted the bug, reading the hdf file ... would be nice.

Anyway, how do you see a possible implementation of reading arbitrary hdf-files? An extension of the existing load function, or a set of new functions e.g. in a forge package?

All the solutions I found up to now (h5read from the h5utils ubuntu package, hdf5oct from github) somehow read either only slices of datasets (not the entire set) and/or no string variables.

Markus Appel <mappel>
Sun 21 Apr 2013 01:55:07 AM UTC, comment #1: 

The octave-core file is used to save the top-level workspace variables from your Octave session if Octave crashes.  It's not a system core dump file.

I agree that the crash should not happen and is definitely a bug, but I would not classify the failure to read the HDF file as a bug.  The HDF support in Octave's load function is only intended to be able to read HDF files produced by Octave's save command.  It was not designed to be able to read arbitrary HDF files.

John W. Eaton <jwe>
Group administrator
Sat 20 Apr 2013 06:52:04 PM UTC, original submission:  

Trying to load the attached (3rd party) hdf5 file results in an error. Octave remains functional, but closing the session ends in a segfault:

octave:1> a=load('-hdf5','dmc02.h5');
error: load: range error for insert
octave:1> exit

panic: Segmentation fault -- stopping myself...
attempting to save variables to 'octave-core'...
Segmentation fault (core dumped)

The resulting file octave-core has zero size.

Here is some complementary information of what I am trying to do, in case it helps:

I want to read NeXus files ( nexusformat.org ) which is a format specification built on top of HDF5. The attached file is a test data set also downloadable from:


It is a completely valid HDF5 file (at least h5check tells me so). I started to remove data sets and groups from the file to figure out what prevents octave from successfully reading it. My strong suspicion is that fields containing strings cause the error. If I remove all string fields, the file can be read without problems. It still works if I leave some string fields in the file, but it seems not to be a certain string field that causes the error.

Some strings which could be read are missing the last character, so it might be connected to #35227 . An error upon exit after reading hdf5 is also described in #37713 but I am not sure whether it is related to this bug.

octave was built from 3.6.4 source on Ubuntu 12.04 with libhdf5-serial-dev 1.8.4-patch1-3ubuntu2 installed

Markus Appel <mappel>


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

Attach Files:

Attached Files
file #29302:  hdf_string_arrays.diff added by mappel (2KiB - text/x-patch)
file #27913:  dmc02.h5 added by mappel (29KiB - application/x-hdf)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by rik5 (Updated the item)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by mappel (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.


    Follow 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-10-12 rik5 StatusPatch Submitted Fixed
        Open/ClosedOpen Closed
    2013-10-12 rik5 StatusConfirmed Patch Submitted
    2013-10-06 mappel Attached File- Added hdf_string_arrays.diff, #29302
    2013-09-30 mtmiller CategoryNone Libraries
        StatusNone Confirmed
        Release3.6.4 dev
    2013-04-20 mappel Attached File- Added dmc02.h5, #27913

    Back to the top

    Powered by Savane 3.12.
    Corresponding source code