← Back to team overview

yade-dev team mailing list archive

[Bug 1380103] Re: polyhedral code, segmentation fault & memory leak

 

Hello Jan and Bruno,

A good news is that the bug seems to be fixed. I think the bug derives
from the dual polyhedron. In the present polyhedral code, once we find a
point in the intersection, we move the origin to the point. The problem
is that there may be a plane which is very closed to the new origin, so
the dual point of this plane will be far away from  the new origin. This
dual point is not a good input of convex_hull_3. A available workaround,
I think, is scaling the potential intersection manually. We can scale
the real intersection back to its real size after getting the
intersection. So I added several lines as follows:

//after translating the polyhedra to the new coordinate system
Transformation scale(CGAL::SCALING, 10);//scale 10 times
Transformation scale_back(CGAL::SCALING,0.1);

//scaling A,B
std::transforms(..., scale);
...
std::transforms(...,scale_back);//before translate the new origin to the old origin.

-----------------------------------------------------------------------------------
This method can avoid the crash for me even if I adopt a high stiffness like 1e16.

Thanks!
Best,
Sway

-- 
You received this bug notification because you are a member of Yade
developers, which is subscribed to Yade.
https://bugs.launchpad.net/bugs/1380103

Title:
  polyhedral code, segmentation fault & memory leak

Status in Yet Another Dynamic Engine:
  New

Bug description:
  YADE version:1.11.1
  I simulated a packing with Polyhedra shape recently. When running about 50,000 (not constant ) steps, a bug occurred casting information as follow:
      Error in `/usr/bin/python': malloc(): memory corruption (fast): 0x00007fc6780762d8
  So give me some hints to find the reason, please.

  gdb:

  Program received signal SIGABRT, Aborted.
  [Switching to Thread 0x7f3257fff700 (LWP 3066)]
  0x00007f32b7760bb9 in __GI_raise (sig=sig@entry=6)
      at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
  56	../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
  (gdb) bt
  #0  0x00007f32b7760bb9 in __GI_raise (sig=sig@entry=6)
      at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
  #1  0x00007f32b7763fc8 in __GI_abort () at abort.c:89
  #2  0x00007f32b779de14 in __libc_message (do_abort=do_abort@entry=1,
      fmt=fmt@entry=0x7f32b78ac668 "*** Error in `%s': %s: 0x%s ***\n")
      at ../sysdeps/posix/libc_fatal.c:175
  #3  0x00007f32b77a8b77 in malloc_printerr (action=<optimized out>,
      str=0x7f32b78aca08 "malloc(): memory corruption (fast)",
      ptr=<optimized out>) at malloc.c:4996
  #4  0x00007f32b77ab884 in _int_malloc (av=0x7f3250000020, bytes=48)
      at malloc.c:3359
  #5  0x00007f32b77ad230 in __GI___libc_malloc (bytes=48) at malloc.c:2891
  #6  0x00007f32b1639f2d in operator new(unsigned long) ()
     from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
  #7  0x00007f32b441cb23 in void CGAL::In_place_list<CGAL::HalfedgeDS_in_place_list_vertex<CGAL::I_Polyhedron_vertex<CGAL::HalfedgeDS_vertex_base<CGAL::HalfedgeDS_list_types<CGAL::Epick, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Point_3<CGAL::Epick> > > >, false, std::allocator<CGAL::HalfedgeDS_in_place_list_vertex<CGAL::I_Polyhedron_vertex<CGAL::HalfedgeDS_vertex_base<CGAL::HalfedgeDS_list_types<CGAL::Epick, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Point_3<CGAL::Epick> > > > > >::insert<CGAL::internal::In_place_list_const_iterator<CGAL::HalfedgeDS_in_place_list_vert---Type <return> to continue, or q <return> to quit---
  ex<CGAL::I_Polyhedron_vertex<CGAL::HalfedgeDS_vertex_base<CGAL::HalfedgeDS_list_types<CGAL::Epick, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Point_3<CGAL::Epick> > > >, std::allocator<CGAL::HalfedgeDS_in_place_list_vertex<CGAL::I_Polyhedron_vertex<CGAL::HalfedgeDS_vertex_base<CGAL::HalfedgeDS_list_types<CGAL::Epick, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Point_3<CGAL::Epick> > > > > > >(CGAL::internal::In_place_list_iterator<CGAL::HalfedgeDS_in_place_list_vertex<CGAL::I_Polyhedron_vertex<CGAL::HalfedgeDS_vertex_base<CGAL::HalfedgeDS_list_types<CGAL::Epick, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Point_3<CGAL::Epick> > > >, std::allocator<CGAL::HalfedgeDS_in_place_list_vertex<CGAL::I_Polyhedron_vertex<CGAL::HalfedgeDS_vertex_base<CGAL::HalfedgeDS_list_types<CGAL::Epick, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Point_3<CGAL::Epick> > > > > >, CGAL::internal::In_place_list_const_iterator<CGAL::HalfedgeDS_in_place_list_vertex<CGAL::I_Polyhedron_vertex<CGAL::HalfedgeDS_vertex_base<CGAL::HalfedgeDS_list_types<CGAL::Epick, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Point_3<CGAL::Epick> > > >, std::allocator<CGAL::HalfedgeDS_in_place_list_vertex<CGAL::I_Polyhedron_vertex<CGAL::HalfedgeDS_vertex_base<CGAL::HalfedgeDS_list_types<CGAL::Epick, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Point_3<CGAL::Epick> > > > > >, CGAL::internal::In_place_list_const_iterator<CGAL::HalfedgeDS_in_---Type <return> to continue, or q <return> to quit---
  place_list_vertex<CGAL::I_Polyhedron_vertex<CGAL::HalfedgeDS_vertex_base<CGAL::HalfedgeDS_list_types<CGAL::Epick, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Point_3<CGAL::Epick> > > >, std::allocator<CGAL::HalfedgeDS_in_place_list_vertex<CGAL::I_Polyhedron_vertex<CGAL::HalfedgeDS_vertex_base<CGAL::HalfedgeDS_list_types<CGAL::Epick, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Point_3<CGAL::Epick> > > > > >) ()
     from .../temp-install/lib/x86_64-linux-gnu/yade-1.11.1/libyade.so
  #8  0x00007f32b442abc4 in CGAL::HalfedgeDS_list<CGAL::Epick, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::allocator<int> >::HalfedgeDS_list(CGAL::HalfedgeDS_list<CGAL::Epick, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::allocator<int> > const&) ()
     from .../temp-install/lib/x86_64-linux-gnu/yade-1.11.1/libyade.so
  #9  0x00007f32b49118e2 in Simplify(CGAL::Polyhedron_3<CGAL::Epick, CGAL::Polyhedron_items_3, CGAL::HalfedgeDS_default, std::allocator<int> >, double) ()
     from .../temp-install/lib/x86_64-linux-gnu/yade-1.11.1/libyade.so
  #10 0x00007f32b4915e21 in Polyhedron_Plane_intersection(CGAL::Polyhedron_3<CGAL::Epick, CGAL::Polyhedron_items_3, CGAL::HalfedgeDS_default, std::allocator<int> >, CGAL::Plane_3<CGAL::Epick>, CGAL::Point_3<CGAL::Epick>, CGAL::Point_3<CGAL::Epick>) ()
     from .../temp-install/lib/x86_64-linux-gnu/yade-1.11.1/libyade.so
  #11 0x00007f32b48ea0f8 in Ig2_Wall_Polyhedra_PolyhedraGeom::go(boost::shared_ptr<Shape> const&, boost::shared_ptr<Shape> const&, State const&, State const&, Eigen::Matrix<double, 3, 1, 0, 3, 1> const&, bool const&, boost::shared_ptr<Interaction> const&) ()

  Something wrong in function "Simplify" within Polyhedra_support.cpp:

  Polyhedron Simplify(Polyhedron P, double limit){
   bool elimination = true;
   while(elimination){
    elimination = false;
    for (Polyhedron::Edge_iterator hei = P.edges_begin(); hei!=P.edges_end(); ++hei){
     if (PlaneDifference(hei->facet()->plane(),hei->opposite()->facet()->plane()) < limit){
      if (hei->vertex()->vertex_degree() < 3) hei = P.erase_center_vertex(hei);
      else if(hei->opposite()->vertex()->vertex_degree() < 3) hei = P.erase_center_vertex(hei->opposite());
      else hei = P.join_facet(hei);
      elimination = true;
      break;
     }
    }
   }
   if (P.size_of_facets() < 4) P.clear();
   return P;
  }

To manage notifications about this bug go to:
https://bugs.launchpad.net/yade/+bug/1380103/+subscriptions


References