raisimTech / raisimLib

Visit www.raisim.com
http://www.raisim.com
Other
341 stars 92 forks source link

Segmentation Fault Upon Collision - auto impulseB = contact.getImpulse(); #496

Open Kukhokuhle opened 1 year ago

Kukhokuhle commented 1 year ago

Hi all,

I asked a question recently about getting a seg. fault upon collision (https://github.com/raisimTech/raisimLib/issues/486). It turned out that I was having index out of range/bounds problems with accessing elements of some Eigen matrix. I have now fixed this and now getting the following error and backtrace:

Thread 3 "testExe" received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7ffff1650700 (LWP 55334)] 0x00005555555e19c5 in raisim::RaisimServer::update (this=0x7ffffffa4e30) at /home/kukhokuhle/raisim_workspace/raisimLib/raisim/linux/include/raisim/RaisimServer.hpp:1427 1427 auto impulseB = contact.getImpulse(); (gdb) bt

0 0x00005555555e19c5 in raisim::RaisimServer::update (this=0x7ffffffa4e30)

at /home/kukhokuhle/raisim_workspace/raisimLib/raisim/linux/include/raisim/RaisimServer.hpp:1427

1 0x00005555555de0fb in raisim::RaisimServer::processRequests (this=0x7ffffffa4e30)

at /home/kukhokuhle/raisim_workspace/raisimLib/raisim/linux/include/raisim/RaisimServer.hpp:1001

2 0x00005555555dbc31 in raisim::RaisimServer::loop (this=0x7ffffffa4e30)

at /home/kukhokuhle/raisim_workspace/raisimLib/raisim/linux/include/raisim/RaisimServer.hpp:263

3 0x0000555555634ee4 in std::__invoke_impl<void, void (raisim::RaisimServer::)(), raisim::RaisimServer> (

__f=@0x7fffe4000b70: (void (raisim::RaisimServer::*)(raisim::RaisimServer * const)) 0x5555555dbbc0 <raisim::RaisimServer::loop()>, __t=@0x7fffe4000b68: 0x7ffffffa4e30) at /usr/include/c++/9/bits/invoke.h:73

4 0x0000555555634dbb in std::__invoke<void (raisim::RaisimServer::)(), raisim::RaisimServer> (

__fn=@0x7fffe4000b70: (void (raisim::RaisimServer::*)(raisim::RaisimServer * const)) 0x5555555dbbc0 <raisim::RaisimServer::loop()>) at /usr/include/c++/9/bits/invoke.h:95

5 0x0000555555634cbb in std::thread::_Invoker<std::tuple<void (raisim::RaisimServer::)(), raisim::RaisimServer> >::_M_invoke<0ul, 1ul> (this=0x7fffe4000b68) at /usr/include/c++/9/thread:244

6 0x0000555555634bb8 in std::thread::_Invoker<std::tuple<void (raisim::RaisimServer::)(), raisim::RaisimServer> >::operator() (this=0x7fffe4000b68) at /usr/include/c++/9/thread:251

7 0x0000555555634ac8 in std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (raisim::RaisimServer::)(), raisim::RaisimServer> > >::_M_run (this=0x7fffe4000b60) at /usr/include/c++/9/thread:195

8 0x00007ffff3fcda93 in std::execute_native_thread_routine (__p=)

at ../../../../../libstdc++-v3/src/c++11/thread.cc:82

9 0x00007ffff7aee609 in start_thread (arg=) at pthread_create.c:477

10 0x00007ffff3c03133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

I'd really appreciate any insight into what may be the problem.

jhwangbo commented 1 year ago

did you update raisim to the latest? I thought this issue is already addressed

Kukhokuhle commented 1 year ago

I have just updated my raisim installation. The error persists.

The error does not seem to be related to Eigen anymore, or my networks_minimal package (as was the case before).

jhwangbo commented 1 year ago

Can you share your code so that I can reproduce the result??

Kukhokuhle commented 1 year ago

Unfortunately, I cannot share the code as it is part of a research project for a degree.

For what its worth, the robot is colliding with an obstacle added into the simulation environment as a height map from a png file.

jhwangbo commented 1 year ago

I pushed an untested fix. Can you pull and try it again?

Kukhokuhle commented 1 year ago

Hi Jemin,

Thanks for your patience and help.

I have pulled and tested again. The error persists. However, it is no longer as above. It seems you have been able to fix the cause of the issue I have raised here. The issue now looks very similar to the previous one I raised (https://github.com/raisimTech/raisimLib/issues/486) but of course, without the networks_minimal package stuff. It seems to be related to Eigen.

Please see the backtrace below (received in Debug mode):

Thread 1 "testExe" received signal SIGSEGV, Segmentation fault. 0x00005555555d7e5d in _mm_loadu_pd (P=0x0) at /usr/lib/gcc/x86_64-linux-gnu/9/include/emmintrin.h:131 131 return (__m128d_u )P; (gdb) bt

0 0x00005555555d7e5d in _mm_loadu_pd (__P=0x0) at /usr/lib/gcc/x86_64-linux-gnu/9/include/emmintrin.h:131

1 Eigen::internal::ploadu<double __vector(2)>(Eigen::internal::unpacket_traits<double __vector(2)>::type const*) (from=0x0)

at /home/kukhokuhle/anaconda3/envs/cbf_oa/include/eigen3/Eigen/src/Core/arch/SSE/PacketMath.h:746

2 0x000055555562ab6b in Eigen::internal::ploadt<double __vector(2), 0>(Eigen::internal::unpacket_traits<double __vector(2)>::type const*) (from=0x0)

at /home/kukhokuhle/anaconda3/envs/cbf_oa/include/eigen3/Eigen/src/Core/GenericPacketMath.h:969

3 Eigen::internal::mapbase_evaluator<Eigen::Map<Eigen::Matrix<double, 3, 1, 0, 3, 1> const, 0, Eigen::Stride<0, 0> >, Eigen::Matrix<double, 3, 1, 0, 3, 1> const>::packet<0, double __vector(2)>(long, long) const (this=0x7ffffff9f6c0, row=0, col=0)

at /home/kukhokuhle/anaconda3/envs/cbf_oa/include/eigen3/Eigen/src/Core/CoreEvaluators.h:937

4 0x0000555555627ff6 in Eigen::internal::generic_dense_assignment_kernel<Eigen::internal::evaluator<Eigen::Matrix<double, 3, 1, 0, 3, 1> >, Eigen::internal::evaluator<Eigen::Map<Eigen::Matrix<double, 3, 1, 0, 3, 1> const, 0, Eigen::Stride<0, 0> > >, Eigen::internal::assign_op<double, double>, 0>::assignPacket<0, 0, double __vector(2)>(long, long) (this=0x7ffffff9f6d0, row=0, col=0)

at /home/kukhokuhle/anaconda3/envs/cbf_oa/include/eigen3/Eigen/src/Core/AssignEvaluator.h:675

5 0x000055555562513d in Eigen::internal::generic_dense_assignment_kernel<Eigen::internal::evaluator<Eigen::Matrix<double, 3, 1, 0, 3, 1> >, Eigen::internal::evaluator<Eigen::Map<Eigen::Matrix<double, 3, 1, 0, 3, 1> const, 0, Eigen::Stride<0, 0> > >, Eigen::internal::assign_op<double, double>, 0>::assignPacketByOuterInner<0, 0, double __vector(2)>(long, long) (this=0x7ffffff9f6d0, outer=0, inner=0)

at /home/kukhokuhle/anaconda3/envs/cbf_oa/include/eigen3/Eigen/src/Core/AssignEvaluator.h:689

6 0x0000555555621df3 in Eigen::internal::copy_using_evaluator_innervec_CompleteUnrolling<Eigen::internal::generic_dense_assignment_kernel<Eigen::internal::evaluator<Eigen::Matrix<double, 3, 1, 0, 3, 1> >, Eigen::internal::evaluator<Eigen::Map<Eigen::Matrix<double, 3, 1, 0, 3, 1> const, 0, Eigen::Stride<0, 0> > >, Eigen::internal::assign_op<double, double>, 0>, 0, 2>::run (kernel=...)

at /home/kukhokuhle/anaconda3/envs/cbf_oa/include/eigen3/Eigen/src/Core/AssignEvaluator.h:279

7 0x000055555561dc60 in Eigen::internal::dense_assignment_loop<Eigen::internal::generic_dense_assignment_kernel<Eigen::internal::evaluator<Eigen::Matrix<double, 3, 1, 0, 3, 1> >, Eigen::internal::evaluator<Eigen::Map<Eigen::Matrix<double, 3, 1, 0, 3, 1> const, 0, Eigen::Stride<0, 0> > >, Eigen::internal::assign_op<double, double>, 0>, 3, 2>::run (kernel=...)

at /home/kukhokuhle/anaconda3/envs/cbf_oa/include/eigen3/Eigen/src/Core/AssignEvaluator.h:455

8 0x0000555555619b26 in Eigen::internal::call_dense_assignment_loop<Eigen::Matrix<double, 3, 1, 0, 3, 1>, Eigen::Map<Eigen::Matrix<double, 3, 1, 0, 3, 1> const, 0, Eigen::Stride<0, 0> >, Eigen::internal::assign_op<double, double> > (dst=..., src=..., func=...)

at /home/kukhokuhle/anaconda3/envs/cbf_oa/include/eigen3/Eigen/src/Core/AssignEvaluator.h:785

9 0x00005555556153bf in Eigen::internal::Assignment<Eigen::Matrix<double, 3, 1, 0, 3, 1>, Eigen::Map<Eigen::Matrix<double, 3, 1, 0, 3, 1> const, 0, Eigen::Stride<0, 0> >, Eigen::internal::assign_op<double, double>, Eigen::internal::Dense2Dense, void>::run (dst=..., src=..., func=...)

at /home/kukhokuhle/anaconda3/envs/cbf_oa/include/eigen3/Eigen/src/Core/AssignEvaluator.h:954

10 0x000055555560e366 in Eigen::internal::call_assignment_no_alias<Eigen::Matrix<double, 3, 1, 0, 3, 1>, Eigen::Map<Eigen::Matrix<double, 3, 1, 0, 3, 1> const, 0, Eigen::Stride<0, 0> >, Eigen::internal::assign_op<double, double> > (dst=..., src=..., func=...)

at /home/kukhokuhle/anaconda3/envs/cbf_oa/include/eigen3/Eigen/src/Core/AssignEvaluator.h:890

11 0x00005555556032c0 in Eigen::PlainObjectBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >::_set_noalias<Eigen::Map<Eigen::Matrix<double, 3, 1, 0, 3, 1> const, 0, Eigen::Stride<0, 0> > > (this=0x7ffffff9f850, other=...)

at /home/kukhokuhle/anaconda3/envs/cbf_oa/include/eigen3/Eigen/src/Core/PlainObjectBase.h:797
jhwangbo commented 1 year ago

Yes, this seems like the same as #486. If you switch to C++-17, then the issue will be gone.

Kukhokuhle commented 1 year ago

I suppose you mean I include the line: SET(CMAKE_CXX_FLAGS "-std=c++17") in my CMakeLists.txt file? I already have this.

Kukhokuhle commented 1 year ago

Hi Jemin. Do you have any thoughts on this? Unfortunately I'm still stuck on it.

Kukhokuhle commented 1 year ago

It seems to me like contact.getImpulse().e() is broken?

jhwangbo commented 1 year ago

Sorry for late response. Have you tried this -- https://eigen.tuxfamily.org/dox/group__TopicStructHavingEigenMembers.html? Why is getImpulse broken? You can also check if the contact exists by getImpulsePtr. If it returns nullptr, it means that the impulse is not defined.