celerity / celerity/celerity-runtime

Out-of-bounds error message often omits or shows incorrect bounds for negative indices.

Open
#280 0 comments 0 reactions 0 assignees View on GitHub
good first issue
Dominant language
C++
Stars
156
Forks
19
PR merge metrics
No merged PRs in 30d

Description

The out-of-bounds (OOB) error message displays incorrect information when the bounds start at [0,0,0] and the access is off by one. For example, I encountered the following error:
```
[2024-09-04 16:41:12.700] [0] [error] Out-of-bounds access detected in device kernel T4: accessor 1 attempted to access buffer B3 indices between [0,0,0] - [12,41,1] and outside the declared range [0,0,0] - [12,41,1].
```

While creating a minimal example, I found that the OOB message is sometimes omitted entirely. Here's a sample code snippet that reproduces this issue:
```c++
#include

int main(void) {
celerity::distr_queue q;

constexpr size_t size = 256;
celerity::buffer matrix{{size, size}};

q.submit([&](celerity::handler& cgh) {
celerity::accessor matrix_acc{matrix, cgh, celerity::access::one_to_one{}, celerity::write_only, celerity::no_init};
cgh.parallel_for(celerity::range<2>(size, size), [=](celerity::item<2> item) {
matrix_acc[{item.get_id(0) - 1, item.get_id(1)}] = 0;
});
});

return EXIT_SUCCESS;
}
```

When only one index of a 2D accessor is out-of-bounds (specifically when the index is -1), the error message is completely omitted. However, when both indices are out-of-bounds (both set to -1), the following error message appears:

```
[2024-09-04 17:33:57.485] [0] [error] Out-of-bounds access detected in device kernel T1: accessor 0 attempted to access buffer B0 indicies between [0,0,0] - [255,255,1] and outside the declared range [0,0,0] - [256,256,1].
```

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.