{"action":"created","issue":{"url":"https://api.github.com/repos/mikedh/trimesh/issues/39","repository_url":"https://api.github.com/repos/mikedh/trimesh","labels_url":"https://api.github.com/repos/mikedh/trimesh/issues/39/labels{/name}","comments_url":"https://api.github.com/repos/mikedh/trimesh/issues/39/comments","events_url":"https://api.github.com/repos/mikedh/trimesh/issues/39/events","html_url":"https://github.com/mikedh/trimesh/issues/39","id":190181954,"number":39,"title":"mesh.copy() segfaults, can't deep copy rtree.index.Index??","user":{"login":"payne92","id":638998,"avatar_url":"https://avatars.githubusercontent.com/u/638998?v=3","gravatar_id":"","url":"https://api.github.com/users/payne92","html_url":"https://github.com/payne92","followers_url":"https://api.github.com/users/payne92/followers","following_url":"https://api.github.com/users/payne92/following{/other_user}","gists_url":"https://api.github.com/users/payne92/gists{/gist_id}","starred_url":"https://api.github.com/users/payne92/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/payne92/subscriptions","organizations_url":"https://api.github.com/users/payne92/orgs","repos_url":"https://api.github.com/users/payne92/repos","events_url":"https://api.github.com/users/payne92/events{/privacy}","received_events_url":"https://api.github.com/users/payne92/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-11-17T22:24:24Z","updated_at":"2016-11-18T05:22:50Z","closed_at":null,"body":"The following code segfaults for me after 15-20 iterations:\r\n\r\n```\r\nimport trimesh\r\nfrom copy import deepcopy\r\n\r\nmesh = trimesh.primitives.Sphere()\r\nmesh.triangles_tree()\r\n\r\nprint type(mesh._cache.cache['_triangles_tree'])\r\n\r\nfor i in range(0,30):\r\n    print i\r\n    deepcopy(mesh)\r\n\r\nprint \"done\"\r\n```\r\n\r\n(This was distilled for a much larger failing example that was originally calling mesh.copy(), which is implemented with deepcopy()).\r\n\r\nBecause mesh.copy() breaks, so do all of the functions that depend on it for their implementation.\r\n\r\nI suspect the problem is the rtree.index.Index object stored in the mesh cache in the slot '_triangles_tree' -- it doesn't look like it supports deepcopy.\r\n\r\nConsider:  clearing the cache before copying (seems to work in a simple example), OR, to implement __copy__ / __deepcopy__ in the util.Cache object to do the right thing.\r\n"},"comment":{"url":"https://api.github.com/repos/mikedh/trimesh/issues/comments/261451410","html_url":"https://github.com/mikedh/trimesh/issues/39#issuecomment-261451410","issue_url":"https://api.github.com/repos/mikedh/trimesh/issues/39","id":261451410,"user":{"login":"mikedh","id":1403074,"avatar_url":"https://avatars.githubusercontent.com/u/1403074?v=3","gravatar_id":"","url":"https://api.github.com/users/mikedh","html_url":"https://github.com/mikedh","followers_url":"https://api.github.com/users/mikedh/followers","following_url":"https://api.github.com/users/mikedh/following{/other_user}","gists_url":"https://api.github.com/users/mikedh/gists{/gist_id}","starred_url":"https://api.github.com/users/mikedh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikedh/subscriptions","organizations_url":"https://api.github.com/users/mikedh/orgs","repos_url":"https://api.github.com/users/mikedh/repos","events_url":"https://api.github.com/users/mikedh/events{/privacy}","received_events_url":"https://api.github.com/users/mikedh/received_events","type":"User","site_admin":false},"created_at":"2016-11-18T05:22:50Z","updated_at":"2016-11-18T05:22:50Z","body":"Wow, the multiple copy operations sure exposes all sorts of exciting segfaults. After I added a unit test which demonstrates this behavior, I noticed the hard faulting was pretty platform specific and intermittent. In addition to the rtree I noticed some instances where the cached convex hull crashed it as well.\r\n\r\nAnyway, I updated mesh.copy to only copy the mesh data and not the cache, and that appears to fix it (so maybe I *could* cache that freaking r-tree). \r\n\r\nThanks for the report!"}}
{"actor":{"display_login":"mikedh"}}