# Perf\_imgproc.cpp:47. Segfault during build

**URL:** <https://forum.opencv.org/t/perf-imgproc-cpp-47-segfault-during-build/13312>\
**Category:** Python\
**Tags:** build, gcc\
**Created:** [May 25, 2023, 8:00pm UTC](https://forum.opencv.org/t/perf-imgproc-cpp-47-segfault-during-build/13312 "2023-05-25T20:00:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stuart\_Reynolds](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/stuart_reynolds/32/4079_2.png) [@Stuart\_Reynolds](https://forum.opencv.org/u/Stuart_Reynolds)\
**Post date:** [May 25, 2023, 8:00pm UTC](https://forum.opencv.org/t/perf-imgproc-cpp-47-segfault-during-build/13312/1 "2023-05-25T20:00:47Z")

</div>

Ran across this while building opencv for python. Any idea on the cause?

```auto
In file included from /home/stu/opencv-4.x/modules/ts/include/opencv2/ts.hpp:128,
                 from /home/stu/opencv-4.x/modules/imgproc/perf/opencl/../perf_precomp.hpp:7,
                 from /home/stu/opencv-4.x/modules/imgproc/perf/opencl/perf_imgproc.cpp:47:
Segmentation fault
   90 | #define OCL_TEST_SIZES ::testing::Values(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3, OCL_SIZE_4)
      | ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
in definition of macro ‘INSTANTIATE_TEST_CASE_P’
19023 | gtest_##prefix##test_case_name##_EvalGenerator_() { return generator; } \
      | ^ ~~~~~~~~
in expansion of macro ‘SIMPLE_PERF_TEST_P’
   58 | #define OCL_PERF_TEST_P(fixture, name, params) SIMPLE_PERF_TEST_P(fixture, name, params)
      | ^ ~~~~~~~~~~~~~~~~~
in expansion of macro ‘OCL_PERF_TEST_P’
  313 | OCL_PERF_TEST_P(CannyFixture, Canny, ::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(3, 5), Bool()))
      | ^ ~~~~~~~~~~~~~~
in expansion of macro ‘OCL_TEST_SIZES’
  313 | OCL_PERF_TEST_P(CannyFixture, Canny, ::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(3, 5), Bool()))
      | ^ ~~~~~~~~~~~~~
0x7fdb41e4251f ???
	./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0x7fdb41e29d8f __libc_start_call_main
	../sysdeps/nptl/libc_start_call_main.h:58
0x7fdb41e29e3f __libc_start_main_impl
	../csu/libc-start.c:392
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-11/README.Bugs> for instructions.
make[2]: *** [modules/imgproc/CMakeFiles/opencv_perf_imgproc.dir/build.make:174: modules/imgproc/CMakeFiles/opencv_perf_imgproc.dir/perf/opencl/perf_imgproc.cpp.o] Error 1

```

cmake 3.26.4  
gcc (Ubuntu 11.3.0-1ubuntu1~22.04.1) 11.3.0

```auto
cmake \
  -D CMAKE_BUILD_TYPE=RELEASE \
  -D CMAKE_INSTALL_PREFIX=/usr/local \
  -D OPENCV_EXTRA_MODULES_PATH=${BASE}opencv_contrib/modules \
  -D OPENCV_GENERATE_PKGCONFIG=ON \
  -D BUILD_NEW_PYTHON_SUPPORT=ON \
  -D PYTHON3_EXECUTABLE=`which ${PYTHON_NAME}` \
  -D PYTHON3_LIBRARY=/usr/lib/x86_64-linux-gnu/lib${PYTHON_NAME}.so \
  -D PYTHON3_LIBRARIES=/usr/lib/x86_64-linux-gnu/lib${PYTHON_NAME}.so \
  -D PYTHON3_NUMPY_INCLUDE_DIRS=${NUMPY_INCLUDE} \
  -D PYTHON3_INCLUDE_DIR=/usr/include/${PYTHON_NAME} \
  -D PYTHON3_INCLUDE_PATH=/usr/include/${PYTHON_NAME} \
  -D OPENCV_PYTHON_INSTALL_PATH_SETUPVARS=${SITE_PACKAGES} \
  -D WITH_GSTREAMER=ON \
  -D INSTALL_PYTHON_EXAMPLES=OFF \
  -D INSTALL_C_EXAMPLES=OFF \
  -D BUILD_EXAMPLES=OFF \
  ${GUI_FLAGS} \
  ..
```

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [May 25, 2023, 8:29pm UTC](https://forum.opencv.org/t/perf-imgproc-cpp-47-segfault-during-build/13312/2 "2023-05-25T20:29:20Z")

</div>

possibly out of some resource (ram, swap)? curious error.

you could try updating, or downgrading, your compiler.

GCC 11.3 is the latest 11.x ([April 2022](https://gcc.gnu.org/releases.html)), but there are 12.x and 13.x versions too

---

<div class="post-metadata">

**Author:** ![Stuart\_Reynolds](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/stuart_reynolds/32/4079_2.png) [@Stuart\_Reynolds](https://forum.opencv.org/u/Stuart_Reynolds)\
**Post date:** [May 25, 2023, 8:32pm UTC](https://forum.opencv.org/t/perf-imgproc-cpp-47-segfault-during-build/13312/3 "2023-05-25T20:32:45Z")

</div>

Its builds 32gb RAM, but with 24 CPUS (is what `python -c "import multiprocessing ; print(multiprocessing.cpu_count())"` reports . Maybe. Will try less.

---

<div class="post-metadata">

**Author:** ![Stuart\_Reynolds](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/stuart_reynolds/32/4079_2.png) [@Stuart\_Reynolds](https://forum.opencv.org/u/Stuart_Reynolds)\
**Post date:** [May 25, 2023, 8:45pm UTC](https://forum.opencv.org/t/perf-imgproc-cpp-47-segfault-during-build/13312/4 "2023-05-25T20:45:13Z")

</div>

Some combination of:

```auto
export BUILD=${BASE}opencv-4.x/build/
rm -rf ${BUILD}
mkdir -p ${BUILD}
cd ${BUILD}

export NCPU=8

# Removed
# export GUI_FLAGS=" -D WITH_QT=ON -DWITH_GTK=ON"

```

fixed it. Thanks!
