opencv/modules/dnn
Oliver Kuckertz a3d7811f24
Merge pull request #20725 from mologie:fix-dnn-tf-on-arm
* dnn: fix unaligned memory access crash on armv7

The getTensorContent function would return a Mat pointing to some
member of a Protobuf-encoded message. Protobuf does not make any
alignment guarantees, which results in a crash on armv7 when loading
models while bit 2 is set in /proc/cpu/alignment (or the relevant
kernel feature for alignment compatibility is disabled). Any read
attempt from the previously unaligned data member would send SIGBUS.

As workaround, this commit makes an aligned copy via existing clone
functionality in getTensorContent. The unsafe copy=false option is
removed. Unfortunately, a rather crude hack in PReLUSubgraph in fact
writes(!) to the Protobuf message. We limit ourselves to fixing the
alignment issues in this commit, and add getTensorContentRefUnaligned
to cover the write case with a safe memcpy. A FIXME marks the issue.

* dnn: reduce amount of .clone() calls

* dnn: update FIXME comment

Co-authored-by: Alexander Alekhin <alexander.a.alekhin@gmail.com>
2021-10-06 16:41:05 +00:00
..
cmake/hooks dnn: make OpenCL DNN code optional 2018-03-01 12:12:40 +03:00
include/opencv2 pre: OpenCV 3.4.16 (version++) 2021-10-04 20:47:07 +00:00
misc dnn(pytest/test_input_3d): reload model between switching targets 2021-10-05 23:23:08 +00:00
perf dnn(perf): update convolution tests 2021-09-10 13:11:02 +00:00
src Merge pull request #20725 from mologie:fix-dnn-tf-on-arm 2021-10-06 16:41:05 +00:00
test fix for unsqueeze opset version 13 2021-09-17 17:40:57 +05:30
CMakeLists.txt Update CMakeLists.txt 2021-04-26 22:43:04 +03:00