gazebosim / gz-math

General purpose math library for robot applications.
https://gazebosim.org/libs/math
Apache License 2.0
54 stars 67 forks source link

Illegal Instruction on UTM M2 Apple Silicon #598

Closed w3ichen closed 4 months ago

w3ichen commented 4 months ago

Environment

Description

Steps to reproduce

  1. Launching gazebo starts without error (ie. roslaunch husky_gazebo husky_playpen.launch)
  2. Launching ros navigation stack and sensors causes the gazebo to error out (ie. roslaunch husky_viz view_robot.launch)

Output

Illegal instruction (core dumped)
[gazebo-2] process has died [pid 13647, exit code 132, cmd /opt/ros/noetic/lib/gazebo_ros/gzserver -e ode /home/husky
name: =gazebo
ot/src/mobile_manipulator/worlds/env.world __name:=gazebo - 1og:=/home/.ros/log/8ba903b4-242b-11ef-bc74-bbef25f09167/gazebo-2.log].
log file: /home/.ros/log/8ba903b4-242b-11ef-bc74-bbef25f09167/gazebo-2*.

GDB backtrace is showing gazebo math function is failing: Error is coming from /lib/x86_64-linux-gnu/libignition-math6.so.6 with function generate_canonical

(gdb) bt

   #0  0x00007ffff60d6963 in double std::generate_canonical<double, 53ul, std::mersenne_twister_engine<unsigned long, 32ul, 624ul, 397ul, 31ul, 2567483615ul, 11ul, 4294967295ul, 7ul, 2636928640ul, 15ul, 4022730752ul, 18ul, 1812433253ul> >(std::mersenne_twister_engine<unsigned long, 32ul, 624ul, 397ul, 31ul, 2567483615ul, 11ul, 4294967295ul, 7ul, 2636928640ul, 15ul, 4022730752ul, 18ul, 1812433253ul>&)
    () at /lib/x86_64-linux-gnu/libignition-math6.so.6
#1  0x00007ffff60d6a04 in double std::normal_distribution<double>::operator()<std::mersenne_twister_engine<unsigned long, 32ul, 624ul, 397ul, 31ul, 2567483615ul, 11ul, 4294967295ul, 7ul, 2636928640ul, 15ul, 4022730752ul, 18ul, 1812433253ul> >(std::mersenne_twister_engine<unsigned long, 32ul, 624ul, 397ul, 31ul, 2567483615ul, 11ul, 4294967295ul, 7ul, 2636928640ul, 15ul, 4022730752ul, 18ul, 1812433253ul>&, std::normal_distribution<double>::param_type const&) ()
    at /lib/x86_64-linux-gnu/libignition-math6.so.6
#2  0x00007ffff60d6154 in ignition::math::v6::Rand::DblNormal(double, double)
    () at /lib/x86_64-linux-gnu/libignition-math6.so.6
#3  0x00007ffff72b16e7 in gazebo::sensors::GaussianNoiseModel::ApplyImpl(double, double) () at /lib/x86_64-linux-gnu/libgazebo_sensors.so.11
#4  0x00007ffff72cdf71 in gazebo::sensors::Noise::Apply(double, double) ()
    at /lib/x86_64-linux-gnu/libgazebo_sensors.so.11
#5  0x00007ffff72d1286 in gazebo::sensors::RaySensor::UpdateImpl(bool) ()
    at /lib/x86_64-linux-gnu/libgazebo_sensors.so.11
#6  0x00007ffff72d59a9 in gazebo::sensors::Sensor::Update(bool) ()
    at /lib/x86_64-linux-gnu/libgazebo_sensors.so.11
#7  0x00007ffff72e0f35 in gazebo::sensors::SensorManager::SensorContainer::Update(bool) () at /lib/x86_64-linux-gnu/libgazebo_sensors.so.11
#8  0x00007ffff72e0797 in gazebo::sensors::SensorManager::SensorContainer::RunLoop() () at /lib/x86_64-linux-gnu/libgazebo_sensors.so.11
#9  0x00007ffff59b543b in  ()
    at /lib/x86_64-linux-gnu/libboost_thread.so.1.71.0
#10 0x00007ffff6f28609 in start_thread (arg=<optimized out>)
    at pthread_create.c:477
#11 0x00007ffff7464353 in clone ()
    at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
w3ichen commented 4 months ago

I fixed this by building from source inside my UTM virtual machine, instead of using the binary from apt-get install.

  1. I built from source according to these instructions on the ign-math6 branch.
  2. Then replaced the .so file in /lib sudo cp at lib/x86_64-linux-gnu/libignition-math6.so.6 /lib/x86_64-linux-gnu/libignition-math6.so.6