bvhtree.fromObject - error ( returned NULL without setting an error) in blender 2.8 #58734

Closed
opened 4 years ago by JoseConseco · 19 comments

x = bvhtree.BVHTree.FromObject(C.active_object, C.scene)
Is broken in blender 2.8 builds for some time now. I also tested on latest build from 4 December.

Error message:
raceback (most recent call last):

File "<blender_console>", line 1, in <module>

SystemError: <built-in method FromObject of type object at 0x0444CA30> returned NULL without setting an error
image.png

x = bvhtree.BVHTree.FromObject(C.active_object, C.scene) Is broken in blender 2.8 builds for some time now. I also tested on latest build from 4 December. Error message: raceback (most recent call last): ``` File "<blender_console>", line 1, in <module> ``` SystemError: <built-in method FromObject of type object at 0x0444CA30> returned NULL without setting an error ![image.png](https://archive.blender.org/developer/F5817161/image.png)
Poster

Added subscriber: @JoseConseco

Added subscriber: @JoseConseco
Collaborator

blender/blender#59869 was marked as duplicate of this issue

blender/blender#59869 was marked as duplicate of this issue
Collaborator

blender/blender#59889 was marked as duplicate of this issue

blender/blender#59889 was marked as duplicate of this issue
Collaborator

#59710 was marked as duplicate of this issue

#59710 was marked as duplicate of this issue
dfelinto was assigned by mont29 4 years ago
mont29 commented 4 years ago
Owner

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
mont29 closed this issue 4 years ago
Owner

For the record, the API changed, see e7c3f7ba6f1385a2138862de8568e571fa97b5b4.

For the record, the API changed, see e7c3f7ba6f1385a2138862de8568e571fa97b5b4.
Poster

Changed status from 'Resolved' to: 'Open'

Changed status from 'Resolved' to: 'Open'
JoseConseco reopened this issue 4 years ago
Poster

Thanks for the fix. The operation bvhtree .fromObject now works when executed once. But it crashes on second run of operation each time:
Steps to reproduce:
run in console:

from mathutils.bvhtree import BVHTree
BVHTree.FromObject(C.active_object, C.depsgraph) 
BVHTree.FromObject(C.active_object, C.depsgraph)  #it will crash here (no error)

In addon I developed I have operator with some F6 props, and if I edit any F6 operator props, BVHTree.FromObject will crash blender. Simple operator example (run it 2x to to crash blender):

import bpy
from mathutils.bvhtree import BVHTree

class SimpleOperator(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "object.simple_operator"
    bl_label = "Simple Object Operator"
    

    def execute(self, context):
        sourceSurface_BVHT = BVHTree.FromObject(context.active_object, context.depsgraph) #crash on second run from F6 props
        print('Crash on second run')
        return {'FINISHED'}


def register():
    bpy.utils.register_class(SimpleOperator)


def unregister():
    bpy.utils.unregister_class(SimpleOperator)


if __name__ == "__main__":
    register()


Thanks for the fix. The operation bvhtree .fromObject now works when executed once. But it crashes on second run of operation each time: Steps to reproduce: run in console: ``` from mathutils.bvhtree import BVHTree BVHTree.FromObject(C.active_object, C.depsgraph) BVHTree.FromObject(C.active_object, C.depsgraph) #it will crash here (no error) ``` In addon I developed I have operator with some F6 props, and if I edit any F6 operator props, BVHTree.FromObject will crash blender. Simple operator example (run it 2x to to crash blender): ``` import bpy from mathutils.bvhtree import BVHTree class SimpleOperator(bpy.types.Operator): """Tooltip""" bl_idname = "object.simple_operator" bl_label = "Simple Object Operator" def execute(self, context): sourceSurface_BVHT = BVHTree.FromObject(context.active_object, context.depsgraph) #crash on second run from F6 props print('Crash on second run') return {'FINISHED'} def register(): bpy.utils.register_class(SimpleOperator) def unregister(): bpy.utils.unregister_class(SimpleOperator) if __name__ == "__main__": register() ```
Owner

It actually crashes immediatelly with:
BLI_assert failed: //source/blender/blenkernel/intern/DerivedMesh.c:2192, mesh_get_eval_final(), at 'ob->id.tag & LIB_TAG_COPIED_ON_WRITE'

It actually crashes immediatelly with: `BLI_assert failed: //source/blender/blenkernel/intern/DerivedMesh.c:2192, mesh_get_eval_final(), at 'ob->id.tag & LIB_TAG_COPIED_ON_WRITE'`
Owner

Added subscriber: @Sergey

Added subscriber: @Sergey
Owner

For the records, I can "fix" the initial crash with P872, however when I call it the second time I indeed get a crash:

SUMMARY: AddressSanitizer: heap-use-after-free //source/blender/blenkernel/intern/DerivedMesh.c:2208 in mesh_get_eval_final
Full backtrace: P871

@Sergey suggestions?

For the records, I can "fix" the initial crash with [P872](https://archive.blender.org/developer/P872.txt), however when I call it the second time I indeed get a crash: `SUMMARY: AddressSanitizer: heap-use-after-free //source/blender/blenkernel/intern/DerivedMesh.c:2208 in mesh_get_eval_final` Full backtrace: [P871](https://archive.blender.org/developer/P871.txt) @Sergey suggestions?
Sergey commented 4 years ago
Owner

Think your assert is a side effect. Surely, should be fixed, but don't think it will crash.

The P872 is wrong. Is ok to mock around with evaluated objects which you control and own (as in the baking), but you must not do such trickery for objects which are only "leased" to you ;) Doing such stuff will confuse regular evaluation routines.

The fact that crash is only happening on redo makes me believe that it's same type of errors where operator wants to know evaluated state of the scene an unless special flag is set for an operator, dependency graph is not guaranteed to be evaluated.

Think your assert is a side effect. Surely, should be fixed, but don't think it will crash. The [P872](https://archive.blender.org/developer/P872.txt) is wrong. Is ok to mock around with evaluated objects which you control and own (as in the baking), but you must not do such trickery for objects which are only "leased" to you ;) Doing such stuff will confuse regular evaluation routines. The fact that crash is only happening on redo makes me believe that it's same type of errors where operator wants to know evaluated state of the scene an unless special flag is set for an operator, dependency graph is not guaranteed to be evaluated.
ZedDB commented 4 years ago
Collaborator

Added subscribers: @gumby1325, @ZedDB

Added subscribers: @gumby1325, @ZedDB
Collaborator

Added subscriber: @MichelAnders

Added subscriber: @MichelAnders
Collaborator

This issue was referenced by blender/blender@b3e68a83f3

This issue was referenced by blender/blender@b3e68a83f30f7f9948a384d756aaf43eb055ab46
mont29 commented 4 years ago
Owner

Added subscribers: @dfelinto, @mont29

Added subscribers: @dfelinto, @mont29
dfelinto was unassigned by mont29 4 years ago
mont29 self-assigned this 4 years ago
mont29 commented 4 years ago
Owner

Issue is actually dead simple: C_BVHTree_FromObject() unconditionally frees its mesh, when bvh_get_mesh() actually may return direct data from evaluated object, not always creating its own mesh...

As for the asserts, one just have to pass eval object to mesh_get_eval_xxx() functions, not orig one.

Issue is actually dead simple: `C_BVHTree_FromObject()` unconditionally frees its mesh, when `bvh_get_mesh()` actually may return direct data from evaluated object, not always creating its own mesh... As for the asserts, one just have to pass eval object to `mesh_get_eval_xxx()` functions, not orig one.
mont29 commented 4 years ago
Owner

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
mont29 closed this issue 4 years ago
Collaborator

great! works like a charm now :-) (tested on linux 64bit)

great! works like a charm now :-) (tested on linux 64bit)
Sign in to join this conversation.
No Label
good first issue
legacy module/Animation & Rigging
legacy module/Core
legacy module/Eevee & Viewport
legacy module/Grease Pencil
legacy module/Modeling
legacy module/Nodes & Physics
legacy module/Pipeline, Assets & IO
legacy module/Platforms, Builds, Tests & Devices
legacy module/Python API
legacy module/Rendering & Cycles
legacy module/Sculpt, Paint & Texture
legacy module/User Interface
legacy module/VFX & Video
legacy project/2.81
legacy project/2.82
legacy project/2.83
legacy project/2.90
legacy project/2.92
legacy project/2.93
legacy project/3.0
legacy project/3.1
legacy project/3.2
legacy project/3.4
legacy project/Add-ons (BF-Blender)
legacy project/Add-ons (Community)
legacy project/Alembic
legacy project/Animation & Rigging
legacy project/Asset Browser
legacy project/Automated Testing
legacy project/BF Blender: 2.8
legacy project/BF Blender: After Release
legacy project/BF Blender: Next
legacy project/BF Blender: Regressions
legacy project/BF Blender: Unconfirmed
legacy project/Blender 2.70
legacy project/Blender Cloud
legacy project/Code Quest
legacy project/Collada
legacy project/Compositing
legacy project/Core
legacy project/Cycles
legacy project/Datablocks and Libraries
legacy project/Dependency Graph
legacy project/Documentation
legacy project/EEVEE & Viewport
legacy project/Freestyle
legacy project/Game Data Conversion
legacy project/Game Engine
legacy project/Game Physics
legacy project/Game Python
legacy project/Game UI
legacy project/Geometry Nodes
legacy project/Good First Issue
legacy project/Grease Pencil
legacy project/Images & Movies
legacy project/Import/Export
legacy project/Infrastructure: Blender Buildbot
legacy project/Infrastructure: Blender Web Assets
legacy project/Infrastructure: Websites
legacy project/Modeling
legacy project/Modifiers
legacy project/Motion Tracking
legacy project/Nodes
legacy project/Nodes & Physics
legacy project/OpenGL Error
legacy project/Overrides
legacy project/Papercut
legacy project/Physics
legacy project/Pillar
legacy project/Pipeline, Assets & I/O
legacy project/Platform: Linux
legacy project/Platform: macOS
legacy project/Platforms, Builds, Tests & Devices
legacy project/Platform: Windows
legacy project/Python API
legacy project/Render & Cycles
legacy project/Render Pipeline
legacy project/Sculpt, Paint & Texture
legacy project/Straightforward Issue
legacy project/Text Editor
legacy project/Tracker Curfew
legacy project/Translations
legacy project/USD
legacy project/User Interface
legacy project/UV Editing
legacy project/VFX & Video
legacy project/Video Sequencer
legacy project/Virtual Reality
papercut
Priority › High
Priority › Low
Priority › Normal
Priority › Unbreak Now!
Status › Archived
Status › Confirmed
Status › Duplicate
Status › Needs Information from Developers
Status › Needs Information from User
Status › Needs Triage
Status › Resolved
straightforward issue
Type › Bug
Type › Design
Type › Known Issue
Type › Patch
Type › Report
Type › To Do
No Milestone
No project
No Assignees
7 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#58734
Loading…
There is no content yet.