-
Notifications
You must be signed in to change notification settings - Fork 178
Description
The issue
I'm encountering an issue when I try to build my ROS2 Docker image including the px4_msgs repository. My host machine is x86 and runs Ubuntu 22.04.
Command line output
[+] Building 731.9s (15/15) FINISHED docker:default
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 1.80kB 0.0s
=> [internal] load metadata for docker.io/library/ros:humble-ros-base 1.3s
=> [auth] library/ros:pull token for registry-1.docker.io 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [ 1/10] FROM docker.io/library/ros:humble-ros-base@sha256:482ae18aa5d4813dd5c59aee9e4cd830eac94c60587f494e9ff343e6aaf3aba3 0.0s
=> [internal] load build context 0.1s
=> => transferring context: 1.07MB 0.1s
=> CACHED [ 2/10] RUN apt-get update && apt-get install -y build-essential python3-colcon-common-extensions python3-argcomplete bash-completion ros-humble-ament-cmake-clang-for 0.0s
=> CACHED [ 3/10] RUN groupadd --gid 1000 ats-devcontainer && useradd -s /bin/bash --uid 1000 --gid 1000 -m ats-devcontainer && mkdir /home/ats-devcontainer/ros2_ws && chown 1000:1000 0.0s
=> CACHED [ 4/10] COPY docker/entrypoint.sh /entrypoint.sh 0.0s
=> CACHED [ 5/10] COPY docker/bashrc /home/ats-devcontainer/.bashrc 0.0s
=> CACHED [ 6/10] WORKDIR /ros2_ws 0.0s
=> CACHED [ 7/10] RUN mkdir src 0.0s
=> [ 8/10] COPY src/px4_msgs /ros2_ws/src/px4_msgs 0.0s
=> [ 9/10] RUN rosdep update && rosdep install --from-paths src --ignore-src -r -y 36.7s
=> ERROR [10/10] RUN /bin/bash -c "source /opt/ros/humble/setup.bash && colcon build --cmake-args -DCMAKE_BUILD_TYPE=Debug" 693.7s
------
> [10/10] RUN /bin/bash -c "source /opt/ros/humble/setup.bash && colcon build --cmake-args -DCMAKE_BUILD_TYPE=Debug":
3.536 Starting >>> px4_msgs
693.5 --- stderr: px4_msgs
693.5 gmake[2]: *** [CMakeFiles/px4_msgs__rosidl_generator_c.dir/build.make:4635: CMakeFiles/px4_msgs__rosidl_generator_c.dir/rosidl_generator_c/px4_msgs/msg/detail/gimbal_controls__functions.c.o] Segmentation fault (core dumped)
693.5 gmake[2]: *** Waiting for unfinished jobs....
693.5 gmake[1]: *** [CMakeFiles/Makefile2:213: CMakeFiles/px4_msgs__rosidl_generator_c.dir/all] Error 2
693.5 gmake[1]: *** Waiting for unfinished jobs....
693.5 gmake[2]: *** [CMakeFiles/px4_msgs__rosidl_typesupport_cpp.dir/build.make:3726: CMakeFiles/px4_msgs__rosidl_typesupport_cpp.dir/rosidl_typesupport_cpp/px4_msgs/msg/vehicle_acceleration__type_support.cpp.o] Segmentation fault (core dumped)
693.5 gmake[2]: *** Waiting for unfinished jobs....
693.5 c++: internal compiler error: Segmentation fault signal terminated program cc1plus
693.5 Please submit a full bug report,
693.5 with preprocessed source if appropriate.
693.5 See <file:///usr/share/doc/gcc-11/README.Bugs> for instructions.
693.5 gmake[2]: *** [CMakeFiles/px4_msgs__rosidl_typesupport_introspection_cpp.dir/build.make:1766: CMakeFiles/px4_msgs__rosidl_typesupport_introspection_cpp.dir/rosidl_typesupport_introspection_cpp/px4_msgs/msg/detail/actuator_servos_trim__type_support.cpp.o] Error 4
693.5 gmake[2]: *** Waiting for unfinished jobs....
693.5 gmake[1]: *** [CMakeFiles/Makefile2:395: CMakeFiles/px4_msgs__rosidl_typesupport_cpp.dir/all] Error 2
693.5 gmake[1]: *** [CMakeFiles/Makefile2:369: CMakeFiles/px4_msgs__rosidl_typesupport_introspection_cpp.dir/all] Error 2
693.5 gmake[2]: *** [CMakeFiles/px4_msgs__rosidl_typesupport_fastrtps_cpp.dir/build.make:3306: CMakeFiles/px4_msgs__rosidl_typesupport_fastrtps_cpp.dir/rosidl_typesupport_fastrtps_cpp/px4_msgs/msg/detail/dds_fastrtps/open_drone_id_operator_id__type_support.cpp.o] Segmentation fault (core dumped)
693.5 gmake[2]: *** Waiting for unfinished jobs....
693.5 gmake[1]: *** [CMakeFiles/Makefile2:291: CMakeFiles/px4_msgs__rosidl_typesupport_fastrtps_cpp.dir/all] Error 2
693.5 gmake: *** [Makefile:146: all] Error 2
693.5 ---
693.5 Failed <<< px4_msgs [11min 30s, exited with code 2]
693.6 [Processing: px4_msgs]
693.6 [Processing: px4_msgs]
693.6 [Processing: px4_msgs]
693.6 [Processing: px4_msgs]
693.6 [Processing: px4_msgs]
693.6 [Processing: px4_msgs]
693.6 [Processing: px4_msgs]
693.6 [Processing: px4_msgs]
693.6 [Processing: px4_msgs]
693.6 [Processing: px4_msgs]
693.6 [Processing: px4_msgs]
693.6 [Processing: px4_msgs]
693.6 [Processing: px4_msgs]
693.6 [Processing: px4_msgs]
693.6 [Processing: px4_msgs]
693.6 [Processing: px4_msgs]
693.6 [Processing: px4_msgs]
693.6 [Processing: px4_msgs]
693.6 [Processing: px4_msgs]
693.6 [Processing: px4_msgs]
693.6 [Processing: px4_msgs]
693.6 [Processing: px4_msgs]
693.6
693.6 Summary: 0 packages finished [11min 31s]
693.6 1 package failed: px4_msgs
693.6 1 package had stderr output: px4_msgs
------
Dockerfile:62
--------------------
60 | && rosdep install --from-paths src --ignore-src -r -y
61 |
62 | >>> RUN /bin/bash -c "source /opt/ros/humble/setup.bash && colcon build --cmake-args -DCMAKE_BUILD_TYPE=Debug"
--------------------
ERROR: failed to solve: process "/bin/sh -c /bin/bash -c \"source /opt/ros/humble/setup.bash && colcon build --cmake-args -DCMAKE_BUILD_TYPE=Debug\"" did not complete successfully: exit code: 2
How to reproduce
First I installed Docker Engine according to the installation instructions.
Find my Dockerfile below:
Expand to read Dockerfile
# Use an official ROS 2 base image (e.g., Humble Hawksbill on Ubuntu 22.04)
# We use
FROM ros:humble-ros-base
# Set environment variables
ENV ROS_DISTRO=humble
# Update and install dependencies
RUN apt-get update && apt-get install -y \
build-essential \
python3-colcon-common-extensions \
python3-argcomplete \
bash-completion \
ros-humble-ament-cmake-clang-format \
git \
nano \
terminator \
python3-pip \
python3-rosdep \
python3-genmsg \
&& rm -rf /var/lib/apt/lists/*
# Configure user
ARG USERNAME=ats-devcontainer
ARG USER_UID=1000
ARG USER_GID=$USER_UID
# Create the user
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& mkdir /home/$USERNAME/ros2_ws \
&& chown $USER_UID:$USER_GID /home/$USERNAME/ros2_ws
# Switch user from root to $USERNAME
USER $USERNAME
# Change working directory to /ros2_ws
WORKDIR /ros2_ws
# Add src folder to /ros2_ws
RUN mkdir src
# Get the repository
ARG REPO_URL=https://github.com/PX4/px4_msgs.git
RUN git clone --depth 1 --recursive $REPO_URL /ros2_ws/src
# Install any ROS 2 package dependencies
RUN rosdep update \
&& rosdep install --from-paths src --ignore-src -r -y
RUN /bin/bash -c "source /opt/ros/humble/setup.bash && colcon build"
Then, enable QEMU for emulation during cross-compiling
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
And Docker build for arm64
docker buildx build --platform=linux/arm64 . # Build for ARM, throws error
docker buildx build --platform=linux/amd64 . # Build for x86, works
The final project folder structure is standard:
workspace
├── Dockerfile
├── src
│ └── px4_msgs
What I tried
At first I thought it might be an issue with building messages in a Docker image, but I successfully built the ROS2 msg srv tutorial, proving that custom messages can be built. To do this I recreated the src of this package and copied it into the container using COPY. I attempted this with the px4_msgs package as well but got the same error, leading me to believe this is not the issue. This is also the reason I'm posting here and not in Docker or ROS2 forums.
I also attempted to allocate more memory (up to 12GB and 16GB swap, which I believe should be enough)
docker buildx build --platform=linux/arm64 --memory=12g --memory-swap=16g .
Expected result
The image compiles with no errors so I can deploy on an ARM-based single board computer.
This is the first time I'm submitting an issue to a public project so if there is any feedback on my formulation I'm open to learn.
Thanks