# Intro The text below is not related to official binary builds of Scilab (6.0.2 and latest from https://build.scilab.org/view/Scilab%20master/job/scilab-master-linux-64/ ). They are not affected by the problem as they continue to use HDF 1.8.14 (see `lib/thirdparty/libhdf5.settings` for confirmation). # Problem The rpm- and deb- packages in GNU/Linux distributions have broken `save` and `load` functionality. Currently many Linux distributions switched to HDF 1.10.x branch: | Distibution | Scilab | HDF5 | `save`/ `load` | | ------------------- | ------ | ------ | ------------------------ | | Debian 10 Buster | 6.0.1 | 1.10.4 | !!! bug !!! | | Ubuntu 18.04 LTS | 6.0.1 | 1.10.0 | !!! bug !!! (LP#1765503) | | Ubuntu 19.04 | 6.0.2 | 1.10.4 | !!! bug !!! (LP#1765503) | | Fedora RawHide | 6.0.2 | 1.10.5 | !!! bug !!! | | Mageia 7 | 6.0.2 | 1.10.5 | !!! bug !!! | | OpenSuSe Leap 15.1 | 6.0.2 | 1.10.4 | !!! bug !!! | | OpenSuSe Tumbleweed | 6.0.2 | 1.10.4 | !!! bug !!! | You can see Scilab packaged version in distributions on Repology - https://repology.org/project/scilab/packages . Below is a text output of `test_run('hdf5')` from Ubuntu 18.04.2 LTS without Details section as example: ``` --> test_run('hdf5') TMPDIR = /tmp/SCI_TMP_213_5dIgF3 Module 001/001 - [hdf5] : 001/046 - [hdf5] binary_bit-for-bit..........................failed: Slave Scilab exited with error code 1 002/046 - [hdf5] h5attr......................................failed: Slave Scilab exited with error code 1 003/046 - [hdf5] h5close.....................................failed: Slave Scilab exited with error code 1 004/046 - [hdf5] h5cp........................................failed: error_output not empty Use 'no_check_error_output' option to disable this check. 005/046 - [hdf5] h5dataset...................................failed: error_output not empty Use 'no_check_error_output' option to disable this check. 006/046 - [hdf5] h5exists....................................failed: Slave Scilab exited with error code 1 007/046 - [hdf5] h5flush.....................................failed: error_output not empty Use 'no_check_error_output' option to disable this check. 008/046 - [hdf5] h5group.....................................failed: error_output not empty Use 'no_check_error_output' option to disable this check. 009/046 - [hdf5] h5isAttr....................................failed: Slave Scilab exited with error code 1 010/046 - [hdf5] h5isFile....................................failed: Slave Scilab exited with error code 1 011/046 - [hdf5] h5isGroup...................................failed: Slave Scilab exited with error code 1 012/046 - [hdf5] h5isRef.....................................failed: Slave Scilab exited with error code 1 013/046 - [hdf5] h5isSet.....................................failed: Slave Scilab exited with error code 1 014/046 - [hdf5] h5isSpace...................................failed: Slave Scilab exited with error code 1 015/046 - [hdf5] h5isType....................................failed: Slave Scilab exited with error code 1 016/046 - [hdf5] h5label.....................................failed: error_output not empty Use 'no_check_error_output' option to disable this check. 017/046 - [hdf5] h5ln........................................failed: error_output not empty Use 'no_check_error_output' option to disable this check. 018/046 - [hdf5] h5ls........................................failed: Slave Scilab exited with error code 1 019/046 - [hdf5] h5mount.....................................failed: error_output not empty Use 'no_check_error_output' option to disable this check. 020/046 - [hdf5] h5mv........................................failed: error_output not empty Use 'no_check_error_output' option to disable this check. 021/046 - [hdf5] h5open......................................failed: Slave Scilab exited with error code 1 022/046 - [hdf5] h5read......................................failed: Slave Scilab exited with error code 1 023/046 - [hdf5] h5readattr..................................failed: Slave Scilab exited with error code 1 024/046 - [hdf5] h5rm........................................failed: error_output not empty Use 'no_check_error_output' option to disable this check. 025/046 - [hdf5] h5umount....................................failed: error_output not empty Use 'no_check_error_output' option to disable this check. 026/046 - [hdf5] h5write.....................................failed: Slave Scilab exited with error code 1 027/046 - [hdf5] loadhdf5data................................failed: Slave Scilab exited with error code 1 028/046 - [hdf5] loadhdf5data_v1.............................failed: Slave Scilab exited with error code 1 029/046 - [hdf5] saveloadHdf5................................failed: Slave Scilab exited with error code 1 030/046 - [hdf5] bug_11954...................................failed: Slave Scilab exited with error code 1 031/046 - [hdf5] bug_12285...................................failed: Slave Scilab exited with error code 1 032/046 - [hdf5] bug_13689...................................failed: error_output not empty Use 'no_check_error_output' option to disable this check. 033/046 - [hdf5] bug_13941...................................failed: Slave Scilab exited with error code 1 034/046 - [hdf5] bug_14149...................................failed: error_output not empty Use 'no_check_error_output' option to disable this check. 035/046 - [hdf5] bug_14446...................................failed: error_output not empty Use 'no_check_error_output' option to disable this check. 036/046 - [hdf5] bug_14775...................................failed: error_output not empty Use 'no_check_error_output' option to disable this check. 037/046 - [hdf5] bug_14886...................................failed: Slave Scilab exited with error code 1 038/046 - [hdf5] bug_15188...................................failed: Slave Scilab exited with error code 1 039/046 - [hdf5] bug_15302...................................failed: Slave Scilab exited with error code 1 040/046 - [hdf5] bug_5629....................................failed: error_output not empty Use 'no_check_error_output' option to disable this check. 041/046 - [hdf5] bug_6440....................................failed: error_output not empty Use 'no_check_error_output' option to disable this check. 042/046 - [hdf5] bug_7224....................................failed: Slave Scilab exited with error code 1 043/046 - [hdf5] bug_8170....................................failed: error_output not empty Use 'no_check_error_output' option to disable this check. 044/046 - [hdf5] bug_8383....................................failed: Slave Scilab exited with error code 1 045/046 - [hdf5] bug_9510....................................failed: error_output not empty Use 'no_check_error_output' option to disable this check. 046/046 - [hdf5] matrix_as_input.............................failed: error_output not empty Use 'no_check_error_output' option to disable this check. -------------------------------------------------------------------------- Summary tests 46 - 100 % passed 0 - 0 % failed 46 - 100 % skipped 0 length 14.40 sec -------------------------------------------------------------------------- ... ``` You can see how worse is the situation. The simple test with *loading* of existing file with variables produces the output below: ``` --> unix('file x.dat'); x.dat: Hierarchical Data Format (version 5) data --> load('x.dat') HDF5-DIAG: Error detected in HDF5 (1.10.0-patch1) thread 140409678010240: #000: ../../../src/H5F.c line 749 in H5Fclose(): not a file ID major: Invalid arguments to routine minor: Inappropriate type failed to close fileHDF5-DIAG: Error detected in HDF5 (1.10.0-patch1) thread 140409678010240: #000: ../../../src/H5G.c line 553 in H5Gget_info(): invalid argument major: Invalid arguments to routine minor: Bad value HDF5-DIAG: Error detected in HDF5 (1.10.0-patch1) thread 140409678010240: #000: ../../../src/H5F.c line 749 in H5Fclose(): not a file ID major: Invalid arguments to routine minor: Inappropriate type failed to close file --> ``` The simple test with *saving* file with variables produces the output below: ``` --> y=100; --> save('y.dat','y') HDF5-DIAG: Error detected in HDF5 (1.10.0-patch1) thread 140409678010240: #000: ../../../src/H5G.c line 553 in H5Gget_info(): invalid argument major: Invalid arguments to routine minor: Bad value HDF5-DIAG: Error detected in HDF5 (1.10.0-patch1) thread 140409678010240: #000: ../../../src/H5D.c line 121 in H5Dcreate2(): not a location ID major: Invalid arguments to routine minor: Inappropriate type #001: ../../../src/H5Gloc.c line 253 in H5G_loc(): invalid object ID major: Invalid arguments to routine minor: Bad value HDF5-DIAG: Error detected in HDF5 (1.10.0-patch1) thread 140409678010240: #000: ../../../src/H5F.c line 749 in H5Fclose(): not a file ID major: Invalid arguments to routine minor: Inappropriate type failed to close file save: Unable to export variable 'y' in file 'y.dat'. ``` And as a side-effect we can see that `atomsSystemUpdate()` is broken too (really caused by broken `save()`): ``` --> atomsSystemUpdate Scanning repository http://atoms.scilab.org/6.0 ... Done HDF5-DIAG: Error detected in HDF5 (1.10.0-patch1) thread 140626028816256: #000: ../../../src/H5G.c line 553 in H5Gget_info(): invalid argument major: Invalid arguments to routine minor: Bad value HDF5-DIAG: Error detected in HDF5 (1.10.0-patch1) thread 140626028816256: #000: ../../../src/H5G.c line 301 in H5Gcreate2(): not a location major: Invalid arguments to routine minor: Inappropriate type #001: ../../../src/H5Gloc.c line 253 in H5G_loc(): invalid object ID major: Invalid arguments to routine minor: Bad value HDF5-DIAG: Error detected in HDF5 (1.10.0-patch1) thread 140626028816256: #000: ../../../src/H5A.c line 265 in H5Acreate2(): not a location major: Invalid arguments to routine minor: Inappropriate type #001: ../../../src/H5Gloc.c line 253 in H5G_loc(): invalid object ID major: Invalid arguments to routine minor: Bad value HDF5-DIAG: Error detected in HDF5 (1.10.0-patch1) thread 140626028816256: #000: ../../../src/H5D.c line 121 in H5Dcreate2(): not a location ID major: Invalid arguments to routine minor: Inappropriate type #001: ../../../src/H5Gloc.c line 253 in H5G_loc(): invalid object ID major: Invalid arguments to routine minor: Bad value HDF5-DIAG: Error detected in HDF5 (1.10.0-patch1) thread 140626028816256: #000: ../../../src/H5F.c line 749 in H5Fclose(): not a file ID major: Invalid arguments to routine minor: Inappropriate type failed to close fileat line 265 of function atomsDESCRIPTIONget ( /usr/share/scilab/modules/atoms/macros/atoms_internals/atomsDESCRIPTIONget.sci line 284 ) at line 16 of function atomsSystemUpdate ( /usr/share/scilab/modules/atoms/macros/atomsSystemUpdate.sci line 33 ) atomsDESCRIPTIONget: save ('/usr/share/scilab//.atoms/packages') has failed. --> ``` # Brief analysis I believe that root cause of the problem is change of `hid_t` datatype in HDF library. It is not an `int` anymore, it is `int64_t`. But the scilab source code have many places with hardcoded `int`. See for example `openHDF5File` - http://cgit.scilab.org/scilab/tree/scilab/modules/hdf5/src/c/h5_fileManagement.c which calls `H5Fopen`: ``` int openHDF5File(const char *name, int _iAppendMode) { hid_t file; ... file = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT); ... return file; } ``` that is incorrect truncation of long integer. The same is related to Datasets and Groups - they are also `hid_t` (not `int`). # Conclusion I tried to patch this way locally, but it is difficult. I do not understand the whole `module/hdf5` structure. So I do not get success. Please take this comment into account seriously. Other users and I can't imagine Scilab usage without `save`, `load` and ATOMS... Using deb- and rpm-packages is more convenient than binary distribution, so bug should be fixed with joint efforts of Scilab Team (upstream for distributions) and maintainers.