The root of the issue was caused by mesh which was a result of to_mesh() had the same edit_mesh pointer as the input object, causing double-free error. This fix makes it so result mesh does not have edit mesh pointer. Motivation part behind this is to make the result of to_mesh() to be somewhat independent from the input. Differential Revision: https://developer.blender.org/D7361