Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[compile error] clang compiler segfaults compiling sac_model_ellipse3d.cpp #5787

Open
themightyoarfish opened this issue Aug 10, 2023 · 6 comments

Comments

@themightyoarfish
Copy link
Contributor

themightyoarfish commented Aug 10, 2023

I see more and more recently Intel macbooks not being able to build PCL with a problem like this:

[  9%] Building CXX object sample_consensus/CMakeFiles/pcl_sample_consensus.dir/src/sac_model_ellipse3d.cpp.o
cd /var/folders/bv/h12kffzx11d76t2ntqpd0c5h0000gn/T/project-deps.XXX.yhjQ3Kra/pcl-6c23c854389ee891847d1219387ba5639ae6c65f/build/sample_consensus && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -DPCLAPI_EXPORTS -I/var/folders/bv/h12kffzx11d76t2ntqpd0c5h0000gn/T/project-deps.XXX.yhjQ3Kra/pcl-6c23c854389ee891847d1219387ba5639ae6c65f/build/include -I/var/folders/bv/h12kffzx11d76t2ntqpd0c5h0000gn/T/project-deps.XXX.yhjQ3Kra/pcl-6c23c854389ee891847d1219387ba5639ae6c65f/common/include -I/var/folders/bv/h12kffzx11d76t2ntqpd0c5h0000gn/T/project-deps.XXX.yhjQ3Kra/pcl-6c23c854389ee891847d1219387ba5639ae6c65f/search/include -I/var/folders/bv/h12kffzx11d76t2ntqpd0c5h0000gn/T/project-deps.XXX.yhjQ3Kra/pcl-6c23c854389ee891847d1219387ba5639ae6c65f/sample_consensus/include -isystem /Users/hendrik/repos/project-core/deps/include/eigen3 -isystem /var/folders/bv/h12kffzx11d76t2ntqpd0c5h0000gn/T/project-deps.XXX.yhjQ3Kra/pcl-6c23c854389ee891847d1219387ba5639ae6c65f/recognition/include/pcl/recognition/3rdparty -isystem /usr/local/include -isystem /usr/local/opt/libomp/include -isystem /Users/hendrik/repos/project-core/deps/include -ftemplate-depth=1024 -Qunused-arguments -Wno-invalid-offsetof -msse4.2 -mfpmath=sse -march=native -mavx2 -Xclang -fopenmp -O3 -DNDEBUG -std=c++20 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -fPIC -Xclang -fopenmp -MD -MT sample_consensus/CMakeFiles/pcl_sample_consensus.dir/src/sac_model_ellipse3d.cpp.o -MF CMakeFiles/pcl_sample_consensus.dir/src/sac_model_ellipse3d.cpp.o.d -o CMakeFiles/pcl_sample_consensus.dir/src/sac_model_ellipse3d.cpp.o -c /var/folders/bv/h12kffzx11d76t2ntqpd0c5h0000gn/T/project-deps.XXX.yhjQ3Kra/pcl-6c23c854389ee891847d1219387ba5639ae6c65f/sample_consensus/src/sac_model_ellipse3d.cpp
clang: error: unable to execute command: Segmentation fault: 11
clang: error: clang frontend command failed due to signal (use -v to see invocation)
Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: x86_64-apple-darwin22.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
clang: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /var/folders/bv/h12kffzx11d76t2ntqpd0c5h0000gn/T/sac_model_ellipse3d-5e7c10.cpp
clang: note: diagnostic msg: /var/folders/bv/h12kffzx11d76t2ntqpd0c5h0000gn/T/sac_model_ellipse3d-5e7c10.sh
clang: note: diagnostic msg: Crash backtrace is located in
clang: note: diagnostic msg: /Users/hendrik/Library/Logs/DiagnosticReports/clang_<YYYY-MM-DD-HHMMSS>_<hostname>.crash
clang: note: diagnostic msg: (choose the .crash file that corresponds to your crash)
clang: note: diagnostic msg:

********************
make[2]: *** [sample_consensus/CMakeFiles/pcl_sample_consensus.dir/src/sac_model_ellipse3d.cpp.o] Error 254
make[1]: *** [sample_consensus/CMakeFiles/pcl_sample_consensus.dir/all] Error 2
make: *** [all] Error 2

And several times (unsure if all) the hiccup is this one file. This issue was resolved in one case by downgrading XCode/command line tools. This trace above is XCode 14.3.1 with commandline tools 14.0.3.

To Reproduce

Get an Intel macbook with XCode 14.3.1 and commandline tools 14.0.3.

cmake PCL 6c23c854389ee891847d1219387ba5639ae6c65f with these flags:

            cmake -DCMAKE_CXX_STANDARD=20 .. \
                -DBUILD_CUDA=OFF \
                -DBUILD_GPU=OFF \
                -DBUILD_apps=ON \
                -DBUILD_apps_3d_rec_framework=OFF \
                -DBUILD_apps_cloud_composer=OFF \
                -DBUILD_apps_in_hand_scanner=OFF \
                -DBUILD_apps_modeler=OFF \
                -DBUILD_apps_point_cloud_editor=ON \
                -DBUILD_examples=OFF \
                -DBUILD_features=ON \
                -DBUILD_filters=ON \
                -DBUILD_io=ON \
                -DBUILD_kdtree=ON \
                -DBUILD_keypoints=ON \
                -DBUILD_ml=ON \
                -DBUILD_octree=ON \
                -DBUILD_outofcore=OFF \
                -DBUILD_people=OFF \
                -DBUILD_recognition=ON \
                -DBUILD_registration=ON \
                -DBUILD_segmentation=ON \
                -DBUILD_stereo=ON \
                -DBUILD_surface=ON \
                -DBUILD_tools=ON \
                -DBUILD_tracking=ON \
                -DBUILD_visualization=ON \
                -DBoost_USE_DEBUG_RUNTIME=OFF \
                -DWITH_CUDA=OFF \
                -DWITH_VTK=${WITH_QT} \
                -DWITH_OPENMP=ON \
                -DPCL_ONLY_CORE_POINT_TYPES=ON \

and then make it. The number of threads makes no difference, but maybe the template depth is related? I did find some time ago that some of the SAC model files cause extremely long compile times, presumably because of template instantiations.

Your Environment (please complete the following information):

  • OS: macos Ventura 13.5
  • Compiler: apple clang 14.03
  • PCL Version 6c23c85
  • PCL Type: Compiled from source

If PCL was compiled from source or failure in compiling PCL itself:

  • GPU, Kinfu, CUDA enabled? No
  • List and Version of dependencies used: Vtk9.1, Qt5 5.15.9 I think,
  • Compilation flags are used: see above

Additional context

As this is a compiler segfault this is probably more an LLVM/Apple issue, but I'm posting this to raise awareness in the hope someone else has also seen this and might have a solution.

@themightyoarfish themightyoarfish added kind: compile error Type of issue status: triage Labels incomplete labels Aug 10, 2023
@mvieth
Copy link
Member

mvieth commented Aug 10, 2023

I don't have a macbook, so I unfortunately can't test this. On our two macos CIs we haven't noticed this so far.
I can confirm that some sac models, and especially sac_model_ellipse3d.cpp, take a long time to compile, and have a high RAM consumption. This is at least partially because of the Eigen classes that are instantiated (eigenvector solver, LM optimizer, ...). The first thing I would check is whether there is always enough RAM available while building PCL, or whether the compile process might be killed because it takes up too much RAM.
It is not clear to me yet whether this happens every time, or whether the build is sometimes successful and sometimes not? (with the same compiler/tools)
Other than that, you could try to narrow down what causes the problem by disabling parts of the code in sac_model_ellipse3d.hpp, e.g. replacing some functions with dummy functions.

@mvieth mvieth added module: sample_consensus and removed status: triage Labels incomplete labels Aug 10, 2023
@themightyoarfish
Copy link
Contributor Author

I also generally suspect memory issues, as that is the only source of compiler segfaults I have ever seen. That's why we are compiling with just one thread here, but of course 1 file alone could also bust the RAM. Maybe the size of -ftemplate-depth=1024 would make a difference there.

@themightyoarfish
Copy link
Contributor Author

I have been told though that memory is not running out in this case here, but changing the xcode environment seems to help.

@zakgi
Copy link

zakgi commented Aug 14, 2023

I have the same issue. Reverted to 14.0.0 and it works fine. It's not a memory issue, looks like a compiler bug. Clang 15 works fine too.

@annyhou
Copy link

annyhou commented Sep 8, 2023

compilation command:cmake -D CMAKE_INSTALL_PREFIX=/Users/intel/software/3rd/pcl-1.13.1/ -DCMAKE_CXX_STANDARD=20 -DBUILD_CUDA=OFF -DBUILD_GPU=OFF -DBUILD_apps=ON -DBUILD_apps_3d_rec_framework=OFF -DBUILD_apps_cloud_composer=OFF -DBUILD_apps_in_hand_scanner=OFF -DBUILD_apps_modeler=OFF -DBUILD_apps_point_cloud_editor=ON -DBUILD_examples=OFF -DBUILD_features=ON -DBUILD_filters=ON -DBUILD_io=ON -DBUILD_kdtree=ON -DBUILD_keypoints=ON -DBUILD_ml=ON -DBUILD_octree=ON -DBUILD_outofcore=OFF -DBUILD_people=OFF -DBUILD_recognition=ON -DBUILD_registration=ON -DBUILD_segmentation=ON -DBUILD_stereo=ON -DBUILD_surface=ON -DBUILD_tools=ON -DBUILD_tracking=ON -DBUILD_visualization=ON -DBoost_USE_DEBUG_RUNTIME=OFF -DWITH_CUDA=OFF -DWITH_OPENMP=ON -DPCL_ONLY_CORE_POINT_TYPES=ON -DQt5_DIR=/usr/local/Cellar/qt@5/5.15.10_1/lib/cmake/Qt5 -DVTK_DIR=/Users/intel/software/3rd/vtk-9.1.0/lib/cmake/vtk-9.1 -DClangFormat_EXECUTABLE=/usr/local/Cellar/clang-format/16.0.6/bin/clang-format ..

Env:macos Ventura 13.5 clang14.0.3

error infos:
image

@mvieth
Copy link
Member

mvieth commented Sep 9, 2023

@annyhou

  • have you made sure that there is always enough free RAM while building PCL, for example with a task manager/system monitor? If this is the problem, using fewer build jobs should solve it
  • Otherwise, have you tried the solution from the previous comment: switching to Clang 14.0.0 or Clang 15?
  • If there indeed is a compiler bug in Apple Clang 14.0.3, please file a bug report for the Apple Clang developers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants