summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVailin Choi <vchoi@hdfgroup.org>2017-06-30 07:55:45 (GMT)
committerVailin Choi <vchoi@hdfgroup.org>2017-06-30 07:55:45 (GMT)
commit5262b98b34067c1aad30cb25f8e935711638f2c1 (patch)
tree2c3a723df5ab9ec5eecd2c5dfb195e680adc883f
parentdba4a60413f5e7350b02bfe18aecab2d1b0e2b7a (diff)
parent804a88fafdca3d6a76312ab01ac4d6d5b103e9dc (diff)
downloadhdf5-5262b98b34067c1aad30cb25f8e935711638f2c1.zip
hdf5-5262b98b34067c1aad30cb25f8e935711638f2c1.tar.gz
hdf5-5262b98b34067c1aad30cb25f8e935711638f2c1.tar.bz2
Merge pull request #586 in HDFFV/hdf5 from ~VCHOI/my_hdf5_fork:develop to develop
* commit '804a88fafdca3d6a76312ab01ac4d6d5b103e9dc': Fix for HDFFV-10160 Modifications to fix the assertion/abort failure when the application does not close the file.
-rw-r--r--MANIFEST2
-rw-r--r--configure.ac1
-rw-r--r--src/H5.c7
-rw-r--r--src/H5FSint.c26
-rw-r--r--src/H5FSprivate.h3
-rw-r--r--test/CMakeLists.txt1
-rw-r--r--test/CMakeTests.cmake17
-rw-r--r--test/Makefile.am12
-rw-r--r--test/filenotclosed.c128
-rw-r--r--test/test_filenotclosed.sh.in40
10 files changed, 232 insertions, 5 deletions
diff --git a/MANIFEST b/MANIFEST
index b890352..475b674 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -956,6 +956,7 @@
./test/filespace_1_8.h5
./test/filespace_1_6.h5
./test/freespace.c
+./test/filenotclosed.c
./test/file_image.c
./test/file_image_core_test.h5
./test/fill_old.h5
@@ -1057,6 +1058,7 @@
./test/testcheck_version.sh.in
./test/testerror.sh.in
./test/testlinks_env.sh.in
+./test/test_filenotclosed.sh.in
./test/testflushrefresh.sh.in
./test/testframe.c
./test/testhdf5.c
diff --git a/configure.ac b/configure.ac
index 4595655..163f6d3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3353,6 +3353,7 @@ AC_CONFIG_FILES([src/libhdf5.settings
test/H5srcdir_str.h
test/testlibinfo.sh
test/testlinks_env.sh
+ test/test_filenotclosed.sh
test/testswmr.sh
test/test_plugin.sh
test/test_usecases.sh
diff --git a/src/H5.c b/src/H5.c
index 1068fc6..59984dc 100644
--- a/src/H5.c
+++ b/src/H5.c
@@ -29,6 +29,7 @@
#include "H5Pprivate.h" /* Property lists */
#include "H5SLprivate.h" /* Skip lists */
#include "H5Tprivate.h" /* Datatypes */
+#include "H5FSprivate.h" /* File free space */
/****************/
/* Local Macros */
@@ -204,6 +205,10 @@ H5_init_library(void)
* property classes.
* The link interface needs to be initialized so that link property lists
* have their properties registered.
+ * The FS module needs to be initialized as a result of the fix for HDFFV-10160:
+ * It might not be initialized during normal file open.
+ * When the application does not close the file, routines in the module might
+ * be called via H5_term_library() when shutting down the file.
*/
if(H5E_init() < 0)
HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize error interface")
@@ -217,6 +222,8 @@ H5_init_library(void)
HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize metadata caching interface")
if(H5L_init() < 0)
HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize link interface")
+ if(H5FS_init() < 0)
+ HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize FS interface")
/* Debugging? */
H5_debug_mask("-all");
diff --git a/src/H5FSint.c b/src/H5FSint.c
index 1a41172..4297291 100644
--- a/src/H5FSint.c
+++ b/src/H5FSint.c
@@ -77,6 +77,32 @@
/*******************/
+/*-------------------------------------------------------------------------
+ * Function: H5FS_init
+ *
+ * Purpose: Initialize the interface in case it is unable to initialize
+ * itself soon enough.
+ *
+ * Return: Success: non-negative
+ * Failure: negative
+ *
+ * Programmer: Quincey Koziol
+ * Saturday, March 4, 2000
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5FS_init(void)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+ /* FUNC_ENTER() does all the work */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5FS_init() */
+
/*-------------------------------------------------------------------------
* Function: H5FS__create_flush_depend
diff --git a/src/H5FSprivate.h b/src/H5FSprivate.h
index c0467a6..247d75c 100644
--- a/src/H5FSprivate.h
+++ b/src/H5FSprivate.h
@@ -175,6 +175,9 @@ H5FL_SEQ_EXTERN(H5FS_section_class_t);
/* Library-private Function Prototypes */
/***************************************/
+/* Package initialization routine */
+H5_DLL herr_t H5FS_init(void);
+
/* Free space manager routines */
H5_DLL H5FS_t *H5FS_create(H5F_t *f, hid_t dxpl_id, haddr_t *fs_addr,
const H5FS_create_t *fs_create, uint16_t nclasses,
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index d7965cb..8522c1d 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -373,6 +373,7 @@ set (H5_CHECK_TESTS
atomic_reader
links_env
flushrefresh
+ filenotclosed
)
foreach (test ${H5_CHECK_TESTS})
diff --git a/test/CMakeTests.cmake b/test/CMakeTests.cmake
index fe8f261..5f0d386 100644
--- a/test/CMakeTests.cmake
+++ b/test/CMakeTests.cmake
@@ -570,6 +570,7 @@ set (test_CLEANFILES
flushrefresh_VERIFICATION_CHECKPOINT1
flushrefresh_VERIFICATION_CHECKPOINT2
flushrefresh_VERIFICATION_DONE
+ filenotclosed.h5
atomic_data
accum_swmr_big.h5
ohdr_swmr.h5
@@ -783,6 +784,22 @@ set_tests_properties (H5TEST-cache_image PROPERTIES
WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST
)
+#-- Adding test for filenotclosed
+add_test (
+ NAME H5TEST-clear-filenotclosed-objects
+ COMMAND ${CMAKE_COMMAND}
+ -E remove
+ filenotclosed.h5
+ WORKING_DIRECTORY
+ ${HDF5_TEST_BINARY_DIR}/H5TEST
+)
+add_test (NAME H5TEST-filenotclosed COMMAND $<TARGET_FILE:filenotclosed>)
+set_tests_properties (H5TEST-filenotclosed PROPERTIES
+ DEPENDS H5TEST-clear-filenotclosed-objects
+ ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST"
+ WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST
+)
+
#-- Adding test for err_compat
if (HDF5_ENABLE_DEPRECATED_SYMBOLS)
add_test (NAME H5TEST-clear-err_compat-objects
diff --git a/test/Makefile.am b/test/Makefile.am
index 20b63f6..f64b6d8 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -25,14 +25,15 @@ AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_builddir)/src
# testerror.sh: err_compat, error_test
# testlibinfo.sh:
# testcheck_version.sh: tcheck_version
-# tetlinks_env.sh: links_env
+# testlinks_env.sh: links_env
+# test_filenotclosed.sh: filenotclosed.c
# testflushrefresh.sh: flushrefresh
# test_usecases.sh: use_append_chunk, use_append_mchunks, use_disable_mdc_flushes
# testswmr.sh: swmr*
# testvdsswmr.sh: vds_swmr*
-TEST_SCRIPT = testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh \
+TEST_SCRIPT = testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh test_filenotclosed.sh\
testswmr.sh testvdsswmr.sh testflushrefresh.sh test_usecases.sh
-SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT) links_env$(EXEEXT) \
+SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT) links_env$(EXEEXT) test_filenotclosed$(EXEEXT) \
flushrefresh$(EXEEXT) use_append_chunk$(EXEEXT) use_append_mchunks$(EXEEXT) use_disable_mdc_flushes$(EXEEXT) \
swmr_generator$(EXEEXT) swmr_reader$(EXEEXT) swmr_writer$(EXEEXT) \
swmr_remove_reader$(EXEEXT) swmr_remove_writer$(EXEEXT) swmr_addrem_writer$(EXEEXT) \
@@ -65,6 +66,7 @@ TEST_PROG= testhdf5 \
# accum_swmr_reader is used by accum.c.
# atomic_writer and atomic_reader are standalone programs.
# links_env is used by testlinks_env.sh
+# filenotclosed is used by test_filenotclosed.sh
# flushrefresh is used by testflushrefresh.sh.
# use_append_chunk, use_append_mchunks and use_disable_mdc_flushes are used by test_usecases.sh
# swmr_* files (besides swmr.c) are used by testswmr.sh.
@@ -74,7 +76,7 @@ TEST_PROG= testhdf5 \
# and this lets automake keep all its test programs in one place.
check_PROGRAMS=$(TEST_PROG) error_test err_compat tcheck_version \
testmeta accum_swmr_reader atomic_writer atomic_reader \
- links_env flushrefresh use_append_chunk use_append_mchunks use_disable_mdc_flushes \
+ links_env filenotclosed flushrefresh use_append_chunk use_append_mchunks use_disable_mdc_flushes \
swmr_generator swmr_start_write swmr_reader swmr_writer swmr_remove_reader \
swmr_remove_writer swmr_addrem_writer swmr_sparse_reader swmr_sparse_writer \
swmr_check_compat_vfd vds_swmr_gen vds_swmr_reader vds_swmr_writer
@@ -216,6 +218,6 @@ use_disable_mdc_flushes_SOURCES=use_disable_mdc_flushes.c
# Temporary files.
DISTCLEANFILES=testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh test_plugin.sh \
- testswmr.sh testvdsswmr.sh test_usecases.sh testflushrefresh.sh
+ testswmr.sh testvdsswmr.sh test_usecases.sh testflushrefresh.sh test_filenotclosed.sh
include $(top_srcdir)/config/conclude.am
diff --git a/test/filenotclosed.c b/test/filenotclosed.c
new file mode 100644
index 0000000..f91f4bc
--- /dev/null
+++ b/test/filenotclosed.c
@@ -0,0 +1,128 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * Purpose: Test to verify that the assertion/abort failure is fixed when the
+ * application does not close the file. (See HDFFV-10160)
+ */
+
+
+#include "h5test.h"
+
+#define FILENAME "filenotclosed"
+#define DATASET "dset"
+
+/*-------------------------------------------------------------------------
+ * Function: catch_signal
+ *
+ * Purpose: The signal handler to catch the SIGABRT signal.
+ *
+ * Return: No return
+ *
+ * Programmer: Vailin Choi
+ *
+ *-------------------------------------------------------------------------
+ */
+static void catch_signal(int H5_ATTR_UNUSED signo)
+{
+ HDexit(1);
+} /* catch_signal() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: main
+ *
+ * Purpose: Test to verify the following problem described in HDFFV-10160 is fixed:
+ * "a.out: H5Fint.c:1679: H5F_close: Assertion `f->file_id > 0' failed."
+ *
+ * Return: Success: exit(EXIT_SUCCESS)
+ * Failure: exit(EXIT_FAILURE)
+ *
+ * Programmer: Vailin Choi; June 2017
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+main(void)
+{
+ hid_t fapl = -1; /* File access property lists */
+ hid_t fid = -1; /* File ID */
+ hid_t did = -1; /* Dataset ID */
+ hid_t dcpl = -1; /* Dataset creation property list */
+ hid_t sid = -1; /* Dataspace ID */
+ hsize_t cur_dim[1] = {5}; /* Current dimension sizes */
+ hsize_t max_dim[1] = {H5S_UNLIMITED}; /* Maximum dimension sizes */
+ hsize_t chunk_dim[1] = {10}; /* Chunk dimension sizes */
+ int buf[5] = {1, 2, 3, 4, 5}; /* The data to be written to the dataset */
+ char filename[100]; /* File name */
+ const char *env_h5_drvr; /* File Driver value from environment */
+
+ h5_reset();
+
+ /* To exit from the file for SIGABRT signal */
+ if(HDsignal(SIGABRT, catch_signal) == SIG_ERR)
+ TEST_ERROR
+
+ fapl = h5_fileaccess();
+ h5_fixname(FILENAME, fapl, filename, sizeof(filename));
+
+ /* Set to latest format */
+ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ TEST_ERROR
+
+ /* Create the file */
+ if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ TEST_ERROR
+
+ /* Create the dcpl and set the chunk size */
+ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ TEST_ERROR
+
+ if(H5Pset_chunk(dcpl, 1, chunk_dim) < 0)
+ TEST_ERROR
+
+ /* Create the dataspace */
+ if((sid = H5Screate_simple(1, cur_dim, max_dim)) < 0)
+ TEST_ERROR
+
+ /* Create the dataset */
+ if((did = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* Write to the dataset */
+ if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
+ TEST_ERROR
+
+ /* Close the dataset */
+ if(H5Dclose(did) < 0)
+ TEST_ERROR
+
+ /* Close the dataspace */
+ if(H5Sclose(sid) < 0)
+ TEST_ERROR
+
+ /* Close the property lists */
+ if(H5Pclose(dcpl) < 0)
+ TEST_ERROR
+ if(H5Pclose(fapl) < 0)
+ TEST_ERROR
+
+ /* The file is not closed. */
+ /* The library will call H5_term_library to shut down the library. */
+
+ HDexit(EXIT_SUCCESS);
+
+error:
+ HDputs("*** TEST FAILED ***");
+ HDexit(EXIT_FAILURE);
+}
diff --git a/test/test_filenotclosed.sh.in b/test/test_filenotclosed.sh.in
new file mode 100644
index 0000000..09129c5
--- /dev/null
+++ b/test/test_filenotclosed.sh.in
@@ -0,0 +1,40 @@
+#! /bin/sh
+#
+# Copyright by The HDF Group.
+# Copyright by the Board of Trustees of the University of Illinois.
+# All rights reserved.
+#
+# This file is part of HDF5. The full HDF5 copyright notice, including
+# terms governing use, modification, and redistribution, is contained in
+# the COPYING file, which can be found at the root of the source code
+# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.
+# If you do not have access to either file, you may request a copy from
+# help@hdfgroup.org.
+#
+# Test to verify that the assertion/abort failure is fixed when the application
+# does not close the file. (See HDFFV-10160)
+
+srcdir=@srcdir@
+
+nerrors=0
+
+##############################################################################
+##############################################################################
+### T H E T E S T ###
+##############################################################################
+##############################################################################
+
+echo "Testing file not closed assertion/abort failure"
+TEST_NAME=filenotclosed # The test name
+TEST_BIN=`pwd`/$TEST_NAME # The path of the test binary
+#
+# Run the test
+$RUNSERIAL $TEST_BIN >/dev/null 2>&1
+exitcode=$?
+if [ $exitcode -eq 0 ]; then
+ echo "Test PASSED"
+else
+ nerrors="`expr $nerrors + 1`"
+ echo "***Error encountered***"
+fi
+exit $nerrors