Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HDF5 load Segfaults #5

Open
TKGgunter opened this issue Sep 21, 2017 · 2 comments
Open

HDF5 load Segfaults #5

TKGgunter opened this issue Sep 21, 2017 · 2 comments

Comments

@TKGgunter
Copy link

Hdf5 load Segmentation fault (core dumped). I've attempted to recreate the write and load hdf5 example and it produces the set fault error.

@gustavla
Copy link
Member

Do you have a code snippet that reproduces this?

@TKGgunter
Copy link
Author

TKGgunter commented Sep 21, 2017

This was taken pretty much from test in tests/io.rs

extern` crate numeric;
use std::path::PathBuf;
use numeric::{Tensor, io};
use std::env;
use std::fs;

fn main() {
    // We can't have multiple HDF5 tests, since these functions are not thread-safe! 
    // This is why we have to string all of this together in serial, since otherwise the tests
    // might run concurrently. This is in other words the only test that is allowed to interact
    // with libhdf5.

    let mut path = PathBuf::from("");//env::temp_dir();
    println!("{:?}", path);
    path.push("numeric.h5");
    if path.exists() {
        assert!(fs::remove_file(&path).is_ok());
    }

    {
        let t: Tensor<f64> = Tensor::range(10);

        let res = t.save_hdf5(&path);
        assert!(res.is_ok());
        assert!(path.exists());

        println!("Lets try to load..."); //This runs
        let t2 = io::load_hdf5_as_f64(&path, "/data").unwrap();

        println!("Loaded"); //This does not
        assert!(t == t2);
        println!("Loaded and loaded correctly.");

        assert!(fs::remove_file(&path).is_ok());
    }

    {
        let t: Tensor<i16> = Tensor::range(1000).reshape(&[50, 20]);

        let res = t.save_hdf5(&path);
        assert!(res.is_ok());
        assert!(path.exists());

        println!("Lets try to load...");
        let t2 = io::load_hdf5_as_i16(&path, "/data").unwrap();

        assert!(t == t2);
        println!("Loaded and loaded correctly.");
        //assert!(fs::remove_file(&path).is_ok());
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants