G-Node / G-Node/nix

Problem during batch operations

Open
#564 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C++
Stars
72
Forks
36
PR merge metrics
No merged PRs in 30d

Description

This is the same bug as in nixpy (https://github.com/G-Node/nixpy/issues/138), and probably the source of it.

The following code fails as soon as entity variables that were used in further assignments like `da.unit("mV")` are reused. As in nixpy, explicitely setting them to `nix::none` solves the problem.

``` C++
#include "nix.hpp"

void create_files(int count) {
nix::File f;
nix::Block b;
nix::DataArray da;
std::vector data;
for(int i = 0; i < 1000; i ++) {
data.push_back(i * 3.14);
}

for (int i = 0; i < count; i++) {
f = nix::File::open("test_file_" + nix::util::numToStr(i) + ".h5", nix::FileMode::Overwrite);
b = f.createBlock("block", "test");
da = b.createDataArray("array", "test", data);
da.unit("mV"); // comment to have it running
f.close();
}
}

void reopen_files(int count) {
nix::File f;
nix::Block b;
nix::DataArray da;
std::vector data;

for (int i = 0; i < count; i++) {
f = nix::File::open("test_file_" + nix::util::numToStr(i) + ".h5", nix::FileMode::ReadOnly);
b = f.getBlock("block");
da = b.getDataArray("array");
std::cerr << da.id() << std::endl;
da = nix::none; // comment to have it crashing
b = nix::none; // do
f.close();
}
}

int main(int argc, char* argv[]) {
create_files(10);
reopen_files(10);
return 0;
}
```

btw., the issue does not arise in the file-backend..,

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.