Skip to content

Segmentation fault: H5Pget_vol_cap_flags #57

@yzanhua

Description

@yzanhua

Summary

H5Pget_vol_cap_flags gives segmentation fault.

Details

This issue prevents us from running vol-tests. vol-tests will fail in the setup stage (before any actual tests are performed).

A test program to reproduce the problem is provided below.
However, running the test program with the Passthru VOL (provided by HDF5 group) gives the same segmentation error.
Therefore, it's possible that the root cause is outside our library.

Reproducing the issue

Click here to see a test program that reproduces the problem:
#include <stdlib.h>
#include <string.h>
#include "hdf5.h"

#define CHECK_ERR(A)                                             \
    {                                                            \
        if (A < 0) {                                             \
            printf ("Error at line %d: code %d\n", __LINE__, A); \
            goto err_out;                                        \
        }                                                        \
    }

hid_t get_vol_id (int argc, char **argv, int rank);

int main (int argc, char **argv) {
    herr_t err = 0;
    int rank;
    hid_t fapl_id, connector_id;
    uint64_t vol_cap_flags;

    MPI_Init (&argc, &argv);
    MPI_Comm_rank (MPI_COMM_WORLD, &rank);

    // get connector id, return one of the following:
    //      1) the id for Log VOL
    //      2) the id for the Passthru VOL (provided by HDF5 group)
    //      3) -1 (error case)
    connector_id = get_vol_id(argc, argv, rank);
    CHECK_ERR(connector_id);

    // create a file access property list
    fapl_id = H5Pcreate (H5P_FILE_ACCESS);
    CHECK_ERR (fapl_id);

    // set the underlying VOL of fapl_id
    err = H5Pset_vol(fapl_id, connector_id, NULL);
    CHECK_ERR(err);

    // get vol_cap_flags
    err = H5Pget_vol_cap_flags(fapl_id, &vol_cap_flags);  // seg fault happens inside this line

    // following codes not able to run due to the seg fault above


    CHECK_ERR (err);

err_out:;
    if (fapl_id > 0) H5Pclose (fapl_id);
    MPI_Finalize ();
    return err;
}

hid_t get_vol_id (int argc, char **argv, int rank) {
    hid_t connector_id = H5I_INVALID_HID;
    if (argc > 2) {
        if (!rank) printf ("Usage: %s [volname]\n", argv[0]);
        goto err_out;
    }
    
    // return the id for LOG VOL
    if (strcmp(argv[1], "LOG") == 0) {
        if (!rank) printf ("Using connetcor: %s\n", argv[1]);
        connector_id = H5VLregister_connector_by_name ("LOG", H5P_DEFAULT);
        CHECK_ERR (connector_id);
    } 
    
    // return the id for Passthru VOL
    else if (strcmp(argv[1], "pass_through") == 0) {
        if (!rank) printf ("Using connetcor: %s\n", argv[1]);
        connector_id = H5VL_pass_through_register();
        CHECK_ERR (connector_id);
    }

    // error case
    else {
        if (!rank) {
            printf("Not supported for this test program.");
            printf ("Using connetcor: %s\n", argv[1]);
        }
    }
err_out:;
    return connector_id;
}
Click here to see the makefile:
HDF5=/home/HDF5/1.14.0
LOGVOL=/home/Log-Vol/install

all:
	mpicc test.c -g -o test \
	-I${HDF5}/include \
	-L${HDF5}/lib -lhdf5 -lhdf5_hl

run:
	LD_LIBRARY_PATH=${LOGVOL}/lib:${HDF5}/lib:${LD_LIBRARY_PATH} \
	HDF5_PLUGIN_PATH="${LOGVOL}/lib" \
	mpirun -n 1 ./test LOG

passthru:
	LD_LIBRARY_PATH=${HDF5}/lib:${LD_LIBRARY_PATH} \
	HDF5_PLUGIN_PATH="${HDF5}/lib" \
	mpirun -n 1 ./test pass_through

clean:
	rm -rf *.h5 core.* test

make to compile.

make run to run the test program with Log VOL.

make passthru to run the test program with the Passthru VOL (provided by HDF5 group).

gdb output, using Log VOL

gdb output, using the Passthru VOL

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions