Perf_imgproc.cpp:47. Segfault during build

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

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

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} \
  ..

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), but there are 12.x and 13.x versions too

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

Some combination of:

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!