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

Segmentation fault on spawning model with collada mesh generated by assimp on ubuntu 18.04 #2682

Open
osrf-migration opened this issue Jan 9, 2020 · 0 comments · Fixed by #2825
Labels
all bug Something isn't working common major

Comments

@osrf-migration
Copy link

Original report (archived issue) by Naoki Hiraoka (Bitbucket: Naoki-Hiraoka).


related to ros/collada_urdf#34

When I spawned an urdf model with collada meshes into gazebo9 (ubuntu18.04), I got Segmentation fault (core dumped).

I generated the collada meshes with assimp v4.1.0.
I did not get this Segmentation fault on ubuntu 16.04 (gazebo7, assimp v3.2).

Thread 39 "gzserver" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fff1ffff700 (LWP 23344)]
0x00007ffff6a0aa76 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::find_first_not_of(char, unsigned long) const ()
   from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
(gdb) Segmentation fault (core dumped)
[gazebo_gui-3] process has died [pid 23197, exit code 139, cmd /opt/ros/melodic/lib/gazebo_ros/gzclient __name:=gazebo_gui __log:=/home/hiraoka/.ros/log/d975cdd0-31f4-11ea-99d9-5c514f34f247/gazebo_gui-3.log].
log file: /home/hiraoka/.ros/log/d975cdd0-31f4-11ea-99d9-5c514f34f247/gazebo_gui-3*.log

(gdb) bt
#0  0x00007ffff6a0aa76 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::find_first_not_of(char, unsigned long) const ()
    at /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#1  0x00007ffff6ec6acf in  ()
    at /usr/lib/x86_64-linux-gnu/libgazebo_common.so.9
#2  0x00007ffff6ed9a63 in gazebo::common::ColladaLoader::LoadPolylist(TiXmlElement*, ignition::math::v4::Matrix4<double> const&, gazebo::common::Mesh*) ()
    at /usr/lib/x86_64-linux-gnu/libgazebo_common.so.9
#3  0x00007ffff6edc859 in gazebo::common::ColladaLoader::LoadGeometry(TiXmlElement*, ignition::math::v4::Matrix4<double> const&, gazebo::common::Mesh*) ()
    at /usr/lib/x86_64-linux-gnu/libgazebo_common.so.9
#4  0x00007ffff6ede830 in gazebo::common::ColladaLoader::LoadNode(TiXmlElement*, gazebo::common::Mesh*, ignition::math::v4::Matrix4<double> const&) ()
    at /usr/lib/x86_64-linux-gnu/libgazebo_common.so.9
#5  0x00007ffff6edef89 in gazebo::common::ColladaLoader::LoadScene(gazebo::common::Mesh*) () at /usr/lib/x86_64-linux-gnu/libgazebo_common.so.9
#6  0x00007ffff6edf4b0 in gazebo::common::ColladaLoader::Load(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
    at /usr/lib/x86_64-linux-gnu/libgazebo_common.so.9
#7  0x00007ffff6efe89a in gazebo::common::MeshManager::Load(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
    at /usr/lib/x86_64-linux-gnu/libgazebo_common.so.9
#8  0x00007ffff5abee8b in gazebo::physics::MeshShape::Init() ()
    at /usr/lib/x86_64-linux-gnu/libgazebo_physics.so.9
#9  0x00007ffff59d54c4 in gazebo::physics::ODEMeshShape::Init() ()
    at /usr/lib/x86_64-linux-gnu/libgazebo_physics.so.9
#10 0x00007ffff5a65762 in gazebo::physics::Collision::Init() ()
    at /usr/lib/x86_64-linux-gnu/libgazebo_physics.so.9
#11 0x00007ffff5aac27e in gazebo::physics::Link::Init() ()
    at /usr/lib/x86_64-linux-gnu/libgazebo_physics.so.9
#12 0x00007ffff59d30ae in gazebo::physics::ODELink::Init() ()
    at /usr/lib/x86_64-linux-gnu/libgazebo_physics.so.9
#13 0x00007ffff5ac9a9e in gazebo::physics::Model::Init() ()
    at /usr/lib/x86_64-linux-gnu/libgazebo_physics.so.9
#14 0x00007ffff5b13727 in gazebo::physics::World::ProcessFactoryMsgs() ()
    at /usr/lib/x86_64-linux-gnu/libgazebo_physics.so.9
#15 0x00007ffff5b1945d in gazebo::physics::World::ProcessMessages() ()
    at /usr/lib/x86_64-linux-gnu/libgazebo_physics.so.9
#16 0x00007ffff5b1ad84 in gazebo::physics::World::Step() ()
    at /usr/lib/x86_64-linux-gnu/libgazebo_physics.so.9
#17 0x00007ffff5b1b1cd in gazebo::physics::World::RunLoop() ()
    at /usr/lib/x86_64-linux-gnu/libgazebo_physics.so.9
#18 0x00007ffff69a166f in  () at /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#19 0x00007ffff5dfd6db in start_thread (arg=0x7fff1ffff700)
    at pthread_create.c:463
#20 0x00007ffff63fc88f in clone ()
    at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

I think this is because of versions of assimp.
This commit of assimp assimp/assimp@36e53b7#diff-758737a587ca204dec82e47c452466d2
changed the output collada mesh
ftom

<mesh>
  ...
  <vertices id="meshId0-vertices">
    <input semantic="POSITION" source="#meshId0-positions" />
    <input semantic="NORMAL" source="#meshId0-normals" />
  </vertices>
  <polylist count="11" material="defaultMaterial">
    <input offset="0" semantic="VERTEX" source="#meshId0-vertices" />
    <vcount>3 3 3 3 3 3 3 3 3 3 3 </vcount>
    <p>0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 17 18 15 19 20 21 21 22 19 23 24 25 26 27 28 </p>
  </polylist>
</mesh>

to

<mesh>
  ...
  <vertices id="meshId0-vertices">                                                                                
    <input semantic="POSITION" source="#meshId0-positions" />                                                     
  </vertices>                                                                                                     
  <polylist count="11" material="defaultMaterial">                                                                
    <input offset="0" semantic="VERTEX" source="#meshId0-vertices" />                                             
    <input offset="0" semantic="NORMAL" source="#meshId0-normals" />                                              
    <vcount>3 3 3 3 3 3 3 3 3 3 3 </vcount>                                                                       
    <p>0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 17 18 15 19 20 21 21 22 19 23 24 25 26 27 28 </p>              
  </polylist>
</mesh>

This modification may cause index out of range at this line of gazebo.
https://github.com/osrf/gazebo/blob/f57e4e95988c14f99ee48f736253b76ef5309f10/gazebo/common/ColladaLoader.cc#L1548

@osrf-migration osrf-migration added major common bug Something isn't working all labels Apr 20, 2020
k-okada added a commit to k-okada/gazebo that referenced this issue Aug 4, 2020
…ORMAL) * vcount.size() * 3. If both VERTEX and NORMAL have offset 0, then the length of polylist <p> is vcount.size() * 3. So use length of set(offset) as inputSize. This fix for cases where VERTEX and NROMAL share same vcounts, see gazebosim#2682 (comment)
iche033 pushed a commit that referenced this issue Aug 11, 2020
…see #2682 (comment) (#2811)

* add test to check gazebo model generated by assimp4, see #2682

* Length of polylist <p> is not the number of inputs (i.e. VERTEX and NORMAL) * vcount.size() * 3. If both VERTEX and NORMAL have offset 0, then the length of polylist <p> is vcount.size() * 3. So use length of set(offset) as inputSize. This fix for cases where VERTEX and NROMAL share same vcounts, see #2682 (comment)

* fix typo, style, remove comments
k-okada added a commit to k-okada/gazebo that referenced this issue Aug 14, 2020
…ORMAL) * vcount.size() * 3. If both VERTEX and NORMAL have offset 0, then the length of polylist <p> is vcount.size() * 3. So use length of set(offset) as inputSize. This fix for cases where VERTEX and NROMAL share same vcounts, see gazebosim#2682 (comment)
scpeters added a commit that referenced this issue Aug 25, 2020
…<p> (#2825)

* add test to check gazebo model generated by assimp4, see #2682

* Length of polylist <p> is not the number of inputs
(i.e. VERTEX and NORMAL) * vcount.size() * 3.
If both VERTEX and NORMAL have offset 0, then the length of
polylist <p> is vcount.size() * 3.
So use length of set(offset) as inputSize.
This fix for cases where VERTEX and NORMAL share same vcounts, see #2682 (comment)

Signed-off-by: Steve Peters <scpeters@openrobotics.org>
Co-authored-by: Steve Peters <scpeters@openrobotics.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
all bug Something isn't working common major
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant