bhuman/CompiledNN

Segmentation Fault in Tensor.h:225

Closed this issue · 1 comments

At HULKs, we are experiencing sporadic segmentation faults at:

inline T& operator[](const std::size_t index) { return *(dataOffset + index); }

In our code, we get a segmentation fault when we are using nn.input(0)[528]. The following assertions hold true in our use case:

assert(nn.input(0).size() == 1024);
assert(nn.input(0).dims().size() == 3);
assert(nn.input(0).dims()[0] == 32);
assert(nn.input(0).dims()[1] == 32);
assert(nn.input(0).dims()[2] == 1);
assert(nn.input(0).rank() == 3);
assert(nn.input(0).capacity() == 8195);

The internal Tensor::buffer has length 32795 and alignmentShift has an upper bound of 64. I then conclude that the buffer should be large enough for our nn.input(0)[528].

CompiledNN is used in a multithreaded program where we have separate loaded models and compiled nets per thread (should therefore be thread-safe).

It seems that some input data triggers the segmentation fault more often than other, but we don't know why.

Turns out, it was a bug in our code, not in CompiledNN. We are sampling 32x32 patches from original images and have not checked for a nullptr. Thanks @ahasselbring for your support.