← Back to team overview

yade-dev team mailing list archive

[Bug 1380103] Re: memory leak?

 

Hi,
There is a script to reproduce the bug. And the attachment file 2.dat includes vertices of particles. To reproduce the bug quickly, I have set the time step to 1e-5s. 

Here is the script:

from yade._polyhedra_utils import *
from yade.wrapper import *
from yade import plot, polyhedra_utils
#from packingutils import *
import numpy as np

import os

gravel = PolyhedraMat()
gravel.density = 2600 #kg/m^3 
gravel.Ks = 1.0e9
gravel.Kn = 5.0e10 #Pa
gravel.frictionAngle = 0.0 #rad

wall = PolyhedraMat()
wall.density = 2600 #kg/m^3 
wall.Ks = 1.0e7
wall.Kn = 1.0e16 #Pa
wall.frictionAngle = 0.0 #rad
####input data
mn,mx=Vector3(0,0,0),Vector3(0.1,0.075,0.05) # corners of the initial packing

## create materials for spheres and plates
##O.materials.append(PolyhedraMat(frictionAngle=0.0,density=2600,Kn=5.0e10,Ks=1.0e9,label='gravel'))
##O.materials.append(PolyhedraMat(frictionAngle=0.0,density=2600,Kn=1e16,Ks=1e7,label='walls'))
 
###some functions###
def gettop(b):##maximum of y direction
	vv=[b.state.se3[1].toRotationMatrix()*v+b.state.se3[0] for v in b.shape.v]
	vvy=[i[1] for i in vv] ##y
	return max(vvy)

def loading():	
	#O.bodies.append(utils.wall(max([b.state.pos[2]+b.shape.radius for b in O.bodies if isinstance(b.shape,Sphere)]),axis=2))
	global plate1,plate2
	# without this line, the plate variable would only exist inside this function
	plate1=O.bodies[3]# the last particles is the plate
	#plate1.state.pos=(0,max([gettop(b) for b in O.bodies if isinstance(b.shape,Polyhedra)]),0)
	plate1.state.vel=(0,-0.1,0)
	#if plate1.state.pos[1]<0.05:
		#packing.dead=True
		#O.stopAtIter=O.iter+1
	 
def outputPos(filename):
	fobj=open(filename,'a+')
	for b in O.bodies:
		if isinstance(b.shape,Polyhedra):
			vv=[b.state.se3[1].toRotationMatrix()*v+b.state.se3[0] for v in b.shape.v]
			vvv=[[v[0],v[1],v[2]] for v in vv]
			print>>fobj,vvv
        fobj.close()

def readData(filename):
    if os.path.isfile(filename):
	fobj=open(filename)
		
	vv=list()
	while 1:
            line=fobj.readline()
            if not line:break
	    line=line[2:-3]
	    temp_v=list()
	    s=line.split('], [')
	    for i in s:
		sv=i.split(", ")
		temp_v.append([float(j) for j in sv])
	    vv.append(temp_v)	
	fobj.close()
	return vv
    else:
	print "Error:The file is not found!"
	return False

def addBodies(vv):
	for v in vv:
		obj1=polyhedra_utils.polyhedra(gravel,v=v,color=np.random.rand(3))
		O.bodies.append(obj1)

## create walls around the packing
O.bodies.append(utils.wall(0,axis=0,sense=1, material = wall))#left x
O.bodies.append(utils.wall(mx[0],axis=0,sense=-1, material = wall))#right x
O.bodies.append(utils.wall(0,axis=1,sense=1, material = wall))#bottom y
O.bodies.append(utils.wall(mx[1],axis=1,sense=-1, material = wall))#top y
O.bodies.append(utils.wall(0,axis=2,sense=1, material = wall))#back z
O.bodies.append(utils.wall(mx[2],axis=2,sense=-1, material = wall))#front z
##fill particles
vv=readData("2.dat")
addBodies(vv)
#polyhedra_utils.fillBox(mn, mx,gravel,sizemin=[0.003,0.003,0.003],sizemax=[0.008,0.008,0.008],seed=10002)


def checkUnbalancedI():   
    print "iter %d, time elapsed %f,  time step %.5e, unbalanced forces = %.5f"%(O.iter, O.realtime, O.dt, utils.unbalancedForce())		


O.engines=[
   ForceResetter(),
   InsertionSortCollider([Bo1_Polyhedra_Aabb(),Bo1_Wall_Aabb(),Bo1_Facet_Aabb()], verletDist=0.0001),
   InteractionLoop(
      [Ig2_Wall_Polyhedra_PolyhedraGeom(), Ig2_Polyhedra_Polyhedra_PolyhedraGeom(), Ig2_Facet_Polyhedra_PolyhedraGeom()], 
      [Ip2_PolyhedraMat_PolyhedraMat_PolyhedraPhys()], 
      [PolyhedraVolumetricLaw()]  
   ),
   #GravityEngine(gravity=(0,0,-9.81)),
   NewtonIntegrator(damping=0.5,gravity=(0,-9.8,0)),
   PyRunner(realPeriod=5,command='loading()',label='packing',dead=False),
   PyRunner(command='checkUnbalancedI()',realPeriod=5,label='checker')
]


** Attachment added: "2.dat"
   https://bugs.launchpad.net/yade/+bug/1380103/+attachment/4234219/+files/2.dat

-- 
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:
  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