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

Fix issue with old version of Boost and eigenpy >= 2.9.0 #1851

Merged
merged 3 commits into from Jan 30, 2023

Conversation

jcarpent
Copy link
Contributor

No description provided.

@jcarpent
Copy link
Contributor Author

Related to #1851

@jcarpent jcarpent closed this Jan 30, 2023
@jcarpent jcarpent reopened this Jan 30, 2023
@jcarpent jcarpent merged commit 6f42a91 into stack-of-tasks:devel Jan 30, 2023
@duburcqa
Copy link
Contributor

duburcqa commented Jan 31, 2023

I don't know what you mean by "old", but for the record, it was still crashing (although not systematically) when compiling from source on Ubuntu 18 using Boost 1.78.

@jcarpent
Copy link
Contributor Author

1.71 shoudl work. At least, it works well on my side with Gcc from Ubuntu 18.04 and Boost 1.71 and more. Could you try on your side @duburcqa?

@jcarpent jcarpent deleted the topic/python branch January 31, 2023 10:20
@duburcqa
Copy link
Contributor

You mean before of after the patch ? I can double check, but for me it was not working before your patch on Ubuntu 18.0, Python 3.6, Boost 1.78. I did the check in a docker container to avoid side-effects.

@jcarpent
Copy link
Contributor Author

My patch only makes a difference for Boost < 1.71. How do you install Boost on the docker image ?
Could you share the docker image?

@duburcqa
Copy link
Contributor

I'm trying to write a self contained reproduction script.

@duburcqa
Copy link
Contributor

I can confirm that I have a setup where calling pin.Force.Zero() leads to segfault systematically on Ubuntu 18, Python 3.6, Boost 1.76. I'm trying to clean up the reproduction script.

@jcarpent
Copy link
Contributor Author

A docker image will be perfect on my side.
What is weird is the fact you rely on Boost 1.76, while the default one is 1.65.1 on Ubuntu 18.

@duburcqa
Copy link
Contributor

A docker image will be perfect on my side.

I'm just running a bunch of commands on a bare metal official ubuntu:18.04 image.

What is weird is the fact you rely on Boost 1.76, while the default one is 1.65.1 on Ubuntu 18.

Maybe it is. I'm just building everything from source.

@duburcqa
Copy link
Contributor

duburcqa commented Jan 31, 2023

Here it is !

docker run -it ubuntu:18.04
apt update
apt install -y git cmake python3-pip
python3 -m pip install --upgrade pip numpy sphinx setuptools

###################################################

git clone https://github.com/boostorg/boost.git "/boost"
cd "/boost"
git checkout --force "boost-1.76.0"
git submodule --quiet update --init --recursive --jobs 8

git clone https://gitlab.com/libeigen/eigen.git "/eigen3"
cd "/eigen3"
git checkout --force "3.4.0"

git clone https://github.com/stack-of-tasks/eigenpy.git "/eigenpy"
cd "/eigenpy"
git checkout --force "v2.9.0"
git submodule update --init

git clone https://github.com/robotology-dependencies/tinyxml.git "/tinyxml"
cd "/tinyxml"
git checkout --force "master"

git clone https://github.com/ros/console_bridge.git "/console_bridge"
cd "/console_bridge"
git checkout --force "0.3.2"

git clone https://github.com/ros/urdfdom_headers.git "/urdfdom_headers"
cd "/urdfdom_headers"
git checkout --force "1.0.4"

git clone https://github.com/ros/urdfdom.git "/urdfdom"
cd "/urdfdom"
git checkout --force "1.0.3"

git clone https://github.com/stack-of-tasks/pinocchio.git "/pinocchio"
cd "/pinocchio"
git checkout --force "v2.6.15"
git submodule update --init

###################################################

CMAKE_CXX_FLAGS="-fPIC -O3 -DNDEBUG"
PYTHON_EXECUTABLE="/usr/bin/python3"

mkdir -p "/install"

unset Boost_ROOT

cd "/boost"
./bootstrap.sh --prefix="//install" --with-python="${PYTHON_EXECUTABLE}"

CMAKE_CXX_FLAGS_B2="-std=c++11"
mkdir -p "/boost/build"
./b2 --prefix="//install" --build-dir="//boost/build" \
     --with-chrono --with-timer --with-date_time --with-system --with-test \
     --with-filesystem --with-atomic --with-serialization --with-thread \
     --with-python \
     --build-type=minimal --layout=system --lto=off \
     architecture= address-model=64 \
     threading=single link=shared runtime-link=shared debug-symbols=off \
     cxxflags="${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_B2}" \
     linkflags="${CMAKE_CXX_FLAGS_B2}" \
     variant="release" install -q -d0 -j12

mkdir -p "/eigen3/build"
cd "/eigen3/build"
cmake "//eigen3" -Wno-dev -DCMAKE_CXX_STANDARD=11 -DCMAKE_INSTALL_PREFIX="//install" \
      -DBUILD_TESTING=OFF -DEIGEN_BUILD_PKGCONFIG=ON \
      -DCMAKE_BUILD_TYPE="Release"
make install -j12

mkdir -p "/eigenpy/build"
cd "/eigenpy/build"
cmake "//eigenpy" -Wno-dev -DCMAKE_CXX_STANDARD=11 -DCMAKE_INSTALL_PREFIX="//install" \
      -DCMAKE_PREFIX_PATH="//install" -DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" \
      -DPYTHON_STANDARD_LAYOUT=ON -DBoost_NO_SYSTEM_PATHS=TRUE -DBoost_NO_BOOST_CMAKE=TRUE \
      -DBOOST_ROOT="//install" -DBoost_INCLUDE_DIR="//install/include" \
      -DBUILD_TESTING=OFF -DINSTALL_DOCUMENTATION=OFF -DCMAKE_DISABLE_FIND_PACKAGE_Doxygen=ON \
      -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -Wno-strict-aliasing" -DCMAKE_BUILD_TYPE="Release"
make install -j12

mkdir -p "/tinyxml/build"
cd "/tinyxml/build"
cmake "//tinyxml" -Wno-dev -DCMAKE_CXX_STANDARD=11 -DCMAKE_INSTALL_PREFIX="//install" \
      -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -DTIXML_USE_STL" -DCMAKE_BUILD_TYPE="Release"
make install -j12

mkdir -p "/console_bridge/build"
cd "/console_bridge/build"
cmake "//console_bridge" -Wno-dev -DCMAKE_CXX_STANDARD=11 -DCMAKE_INSTALL_PREFIX="//install" \
      -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS}" -DCMAKE_BUILD_TYPE="Release"
make install -j12

mkdir -p "/urdfdom_headers/build"
cd "/urdfdom_headers/build"
cmake "//urdfdom_headers" -Wno-dev -DCMAKE_INSTALL_PREFIX="//install" -DCMAKE_BUILD_TYPE="Release"
make install -j12

mkdir -p "/urdfdom/build"
cd "/urdfdom/build"
cmake "//urdfdom" -Wno-dev -DCMAKE_CXX_STANDARD=11 -DCMAKE_INSTALL_PREFIX="//install" \
      -DCMAKE_PREFIX_PATH="//install" -DBUILD_TESTING=OFF \
      -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS}" -DCMAKE_BUILD_TYPE="Release"
make install -j12

mkdir -p "/pinocchio/build"
cd "/pinocchio/build"
cmake "//pinocchio" -Wno-dev -DCMAKE_CXX_STANDARD=11 -DCMAKE_INSTALL_PREFIX="//install" \
      -DCMAKE_PREFIX_PATH="//install" -DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" \
      -DPYTHON_STANDARD_LAYOUT=ON -DBoost_NO_SYSTEM_PATHS=TRUE -DBoost_NO_BOOST_CMAKE=TRUE \
      -DBOOST_ROOT="//install" -DBoost_INCLUDE_DIR="//install/include" \
      -DBUILD_WITH_URDF_SUPPORT=ON -DBUILD_WITH_COLLISION_SUPPORT=OFF -DBUILD_PYTHON_INTERFACE=ON \
      -DBUILD_WITH_AUTODIFF_SUPPORT=OFF -DBUILD_WITH_CASADI_SUPPORT=OFF -DBUILD_WITH_CODEGEN_SUPPORT=OFF \
      -DBUILD_TESTING=OFF -DINSTALL_DOCUMENTATION=OFF -DCMAKE_DISABLE_FIND_PACKAGE_Doxygen=ON \
      -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -DBOOST_BIND_GLOBAL_PLACEHOLDERS $(
      ) -Wno-unused-local-typedefs -Wno-uninitialized" -DCMAKE_BUILD_TYPE="Release"
make install -j10

###################################################

PYTHON_VERSION="$(${PYTHON_EXECUTABLE} -c "import sysconfig; print(sysconfig.get_config_var('py_version_short'))")"
PYTHON_USER_SITELIB="$("${PYTHON_EXECUTABLE}" -m site --user-site)"
mkdir -p "${PYTHON_USER_SITELIB}"
echo "//install/lib/python${PYTHON_VERSION}/site-packages" \
> "${PYTHON_USER_SITELIB}/user_site.pth"

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/install/lib/"
import pinocchio as pin
pin.Force.Zero()

@jcarpent
Copy link
Contributor Author

jcarpent commented Jan 31, 2023

I see you use c++ 17. Which compiler do you use?
I made the fix for the standard configuration. In your case, the configuration is more tedious. It will be hard to debug it.
I wonder if the issue is not simply the default compiler on Ubuntu 18.04.
Could you try with another compiler? Could you use standard c++ 11 instead of c++ 17? Could you use boost 1.65.1?

@jcarpent
Copy link
Contributor Author

Why don't you use pinocchio v2.6.15, the latest release?

@duburcqa
Copy link
Contributor

duburcqa commented Jan 31, 2023

Could you try with another compiler? Could you use standard c++ 11 instead of c++ 17?

On it.

Why don't you use pinocchio v2.6.15, the latest release?

I thought you said it should be the same for Boost > 1.71. Will do.

@jcarpent
Copy link
Contributor Author

I've tested yesterday, and Pinocchio v2.6.15 was working well on Boost 1.71.
So, this explains the change I made in #1851.

I won't have the resources to generate the image as it is. Could you remove urdfdom and its dependencies?

@jcarpent
Copy link
Contributor Author

jcarpent commented Jan 31, 2023

Could you also generate a proper docker image, otherwise, we will need time to compile?

@duburcqa
Copy link
Contributor

duburcqa commented Jan 31, 2023

Could you remove urdfdom and its dependencies?

Once I'm done checking the other modifications you suggested. It takes some time since I'm wiping out the container after each trial to avoid side-effects.

Could you also generate a proper docker image, otherwise, we will need time to compile?

I will try. I'm not used to it.

@jcarpent
Copy link
Contributor Author

Please use the docker hub to share it, etc. I think using Dockerfile mechanism will help you yo save times ;)

@duburcqa
Copy link
Contributor

duburcqa commented Jan 31, 2023

I cleaned up the reproduction script following your recommendations. It is still crashing. However, compilation fails if I remove urdfdom and set -DBUILD_WITH_URDF_SUPPORT=OFF. I will check if it works when I keep urdfdom_headers.

@duburcqa
Copy link
Contributor

duburcqa commented Jan 31, 2023

I add to apply this patch to make it compile without error:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 076f1281..0ad2f223 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -214,9 +214,6 @@ FILE(GLOB_RECURSE HEADERS
 
 IF(NOT BUILD_WITH_URDF_SUPPORT)
   LIST(REMOVE_ITEM HEADERS
-    ${PROJECT_SOURCE_DIR}/src/parsers/urdf.hpp
-    ${PROJECT_SOURCE_DIR}/src/parsers/urdf/model.hxx
-    ${PROJECT_SOURCE_DIR}/src/parsers/urdf/geometry.hxx
     ${PROJECT_SOURCE_DIR}/src/parsers/urdf/utils.hpp
     ${PROJECT_SOURCE_DIR}/src/parsers/urdf/types.hpp
     )
diff --git a/bindings/python/pinocchio/deprecated.py b/bindings/python/pinocchio/deprecated.py
index df225b3c..1c4e5b41 100644
--- a/bindings/python/pinocchio/deprecated.py
+++ b/bindings/python/pinocchio/deprecated.py
@@ -125,9 +125,12 @@ def buildGeomFromUrdf(model, filename, *args, **kwargs):
   else:
     return pin.buildGeomFromUrdf(model, filename, *args, **kwargs)
 
-buildGeomFromUrdf.__doc__ = (
-  pin.buildGeomFromUrdf.__doc__
-)
+try:
+  buildGeomFromUrdf.__doc__ = (
+    pin.buildGeomFromUrdf.__doc__
+  )
+except AttributeError:
+  del buildGeomFromUrdf
 
 @deprecated("This function is now deprecated and will be removed in future releases of Pinocchio. "
             "Please change for the new function computePotentialEnergy.")

@duburcqa
Copy link
Contributor

duburcqa commented Jan 31, 2023

Here is the final version of the script:

apt update
apt install -y git cmake python3-pip
python3 -m pip install --upgrade pip numpy setuptools

###################################################

git clone https://github.com/boostorg/boost.git "/boost"
cd "/boost"
git checkout --force "boost-1.76.0"
git submodule --quiet update --init --recursive --jobs 8

git clone https://gitlab.com/libeigen/eigen.git "/eigen3"
cd "/eigen3"
git checkout --force "3.4.0"

git clone https://github.com/stack-of-tasks/eigenpy.git "/eigenpy"
cd "/eigenpy"
git checkout --force "v2.9.0"
git submodule update --init

git clone https://github.com/stack-of-tasks/pinocchio.git "/pinocchio"
cd "/pinocchio"
git checkout --force "v2.6.15"
git submodule update --init

###################################################

PYTHON_EXECUTABLE="/usr/bin/python3"

mkdir -p "/install"
cd "/boost"
./bootstrap.sh --prefix="/install" --with-python="${PYTHON_EXECUTABLE}"
mkdir -p "/boost/build"
./b2 --prefix="/install" --build-dir="/boost/build" \
     --with-chrono --with-timer --with-date_time --with-system --with-test \
     --with-filesystem --with-atomic --with-serialization --with-thread \
     --with-python --build-type=minimal --layout=system --lto=off \
     architecture= address-model=64 \
     threading=single link=shared runtime-link=shared debug-symbols=off \
     variant="release" install -q -d0 -j16

mkdir -p "/eigen3/build"
cd "/eigen3/build"
cmake "/eigen3" -DCMAKE_INSTALL_PREFIX="/install" -DBUILD_TESTING=OFF
make install -j16

mkdir -p "/eigenpy/build"
cd "/eigenpy/build"
cmake "//eigenpy" -DCMAKE_INSTALL_PREFIX="/install" \
      -DCMAKE_PREFIX_PATH="/install" -DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" \
      -DBUILD_TESTING=OFF -DINSTALL_DOCUMENTATION=OFF -DCMAKE_BUILD_TYPE="Release"
make install -j16

mkdir -p "/pinocchio/build"
cd "/pinocchio/build"
cmake "//pinocchio" -DCMAKE_INSTALL_PREFIX="/install" \
      -DCMAKE_PREFIX_PATH="/install" -DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" \
      -DBUILD_WITH_URDF_SUPPORT=OFF -DBUILD_WITH_COLLISION_SUPPORT=OFF -DBUILD_PYTHON_INTERFACE=ON \
      -DBUILD_WITH_AUTODIFF_SUPPORT=OFF -DBUILD_WITH_CASADI_SUPPORT=OFF \
      -DBUILD_WITH_CODEGEN_SUPPORT=OFF -DBUILD_TESTING=OFF -DINSTALL_DOCUMENTATION=OFF \
      -DCMAKE_BUILD_TYPE="Release"
make install -j16

###################################################

PYTHON_USER_SITELIB="$("${PYTHON_EXECUTABLE}" -m site --user-site)"
mkdir -p "${PYTHON_USER_SITELIB}"
echo "/install/lib/python3/dist-packages" > "${PYTHON_USER_SITELIB}/user_site.pth"

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/install/lib/"

I will try to share a docker image.

@duburcqa
Copy link
Contributor

duburcqa commented Jan 31, 2023

Here is the dockerfile:

FROM ubuntu:18.04

COPY patch.diff /

RUN \
  apt update; \
  apt install -y git cmake python3-pip

RUN \
  /usr/bin/python3 -m pip install --upgrade pip numpy setuptools

RUN \
  git clone https://github.com/boostorg/boost.git "/boost"; \
  cd "/boost"; \
  git checkout --force "boost-1.76.0"; \
  git submodule --quiet update --init --recursive --jobs 8; \
  \
  git clone https://gitlab.com/libeigen/eigen.git "/eigen3"; \
  cd "/eigen3"; \
  git checkout --force "3.4.0"; \
  \
  git clone https://github.com/stack-of-tasks/eigenpy.git "/eigenpy"; \
  cd "/eigenpy"; \
  git checkout --force "v2.9.0"; \
  git submodule update --init; \
  \
  git clone https://github.com/stack-of-tasks/pinocchio.git "/pinocchio"; \
  cd "/pinocchio"; \
  git checkout --force "v2.6.15"; \
  git submodule update --init; \
  git apply /patch.diff

RUN \
  mkdir -p "/install"; \
  cd "/boost"; \
  ./bootstrap.sh --prefix="/install" --with-python="/usr/bin/python3"; \
  mkdir -p "/boost/build"; \
  ./b2 --prefix="/install" --build-dir="/boost/build" \
       --with-chrono --with-timer --with-date_time --with-system --with-test \
       --with-filesystem --with-atomic --with-serialization --with-thread \
       --with-python --build-type=minimal --layout=system --lto=off \
       architecture= address-model=64 \
       threading=single link=shared runtime-link=shared debug-symbols=off \
       variant="release" install -q -d0 -j16; \
  \
  mkdir -p "/eigen3/build"; \
  cd "/eigen3/build"; \
  cmake "/eigen3" -DCMAKE_INSTALL_PREFIX="/install" -DBUILD_TESTING=OFF; \
  make install -j16; \
  \
  mkdir -p "/eigenpy/build"; \
  cd "/eigenpy/build"; \
  cmake "//eigenpy" -DCMAKE_INSTALL_PREFIX="/install" \
        -DCMAKE_PREFIX_PATH="/install" -DPYTHON_EXECUTABLE="/usr/bin/python3" \
        -DBUILD_TESTING=OFF -DINSTALL_DOCUMENTATION=OFF -DCMAKE_BUILD_TYPE="Release"; \
  make install -j16; \
  \
  mkdir -p "/pinocchio/build"; \
  cd "/pinocchio/build"; \
  cmake "//pinocchio" -DCMAKE_INSTALL_PREFIX="/install" \
        -DCMAKE_PREFIX_PATH="/install" -DPYTHON_EXECUTABLE="/usr/bin/python3" \
        -DBUILD_WITH_URDF_SUPPORT=OFF -DBUILD_WITH_COLLISION_SUPPORT=OFF -DBUILD_PYTHON_INTERFACE=ON \
        -DBUILD_WITH_AUTODIFF_SUPPORT=OFF -DBUILD_WITH_CASADI_SUPPORT=OFF \
        -DBUILD_WITH_CODEGEN_SUPPORT=OFF -DBUILD_TESTING=OFF -DINSTALL_DOCUMENTATION=OFF \
        -DCMAKE_BUILD_TYPE="Release"; \
  make install -j16

RUN \
  export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/install/lib/"; \
  \
  PYTHON_USER_SITELIB="$(/usr/bin/python3 -m site --user-site)"; \
  mkdir -p "${PYTHON_USER_SITELIB}"; \
  echo "/install/lib/python3/dist-packages" > "${PYTHON_USER_SITELIB}/user_site.pth"

I'm sharing the docker image on docker hub as requested ! docker pull duburcqa/pin_segfault

@jcarpent
Copy link
Contributor Author

jcarpent commented Feb 1, 2023

Thanks

@jcarpent
Copy link
Contributor Author

jcarpent commented Feb 1, 2023

What is the patch.diff file?

@duburcqa
Copy link
Contributor

duburcqa commented Feb 1, 2023

The patch here right above in the discussion. It is necessary to fix compilation failure with -DBUILD_WITH_URDF_SUPPORT=OFF.

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

Successfully merging this pull request may close these issues.

None yet

2 participants