Page MenuHome

Crash in nvoglv64.dll entering edit mode on curve
Closed, ResolvedPublic

Description

System Information
Operating system: Windows-10-10.0.19043-SP0 64 Bits
Graphics card: NVIDIA GeForce RTX 3080/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 472.39

Blender Version
Broken: version: 3.1.0 Alpha, branch: master, commit date: 2021-12-26 20:08, hash: rB20b438d523c9
Worked: 2.93 LTS

Caused by rBeb0eb54d9644: Fix D12533: Simplify curve object to mesh conversion

Blender crashes with an access violation in nvoglv64.dll when entering edit mode on a curve with the following script running. This worked fine in Blender 2.93 et al, so something has changed with object.to_mesh() that nvoglv64.dll does not like.
See the attached blend file, and run the embedded minimum repro crash_script text file- which is a simple GL handler that should use blf to display the number of mesh polygons in a curve.

# Blender 3.1.0, Commit date: 2021-12-26 20:08, Hash 20b438d523c9
bpy.ops.object.editmode_toggle()  # Operator

# backtrace
Exception Record:

ExceptionCode         : EXCEPTION_ACCESS_VIOLATION
Exception Address     : 0x00007FF9798BBDD0
Exception Module      : nvoglv64.dll
Exception Flags       : 0x00000000
Exception Parameters  : 0x2
	Parameters[0] : 0x0000000000000000
	Parameters[1] : 0x0000000000000000


Stack trace:
nvoglv64.dll        :0x00007FF9798BBDD0  Symbols not available

# Python backtrace

the repro script, for posterity:

import bpy, blf

def draw_test():
    ui_scale = bpy.context.preferences.system.ui_scale
    blf.color(0, 1,1,0,1)
    blf.size(0, int(12 * ui_scale), 72)

    blf.position(0, int(20 * ui_scale), int(bpy.context.region.height) - int(200 * ui_scale), 0)
    blf.draw(0, f"With the curve selected, enter edit mode.")

    blf.position(0, int(20 * ui_scale), int(bpy.context.region.height) - int(220 * ui_scale), 0)
    blf.draw(0, f"If it doesn't crash immediately, try selecting a few points.")

    if bpy.context.mode != 'EDIT_CURVE':
        return

    obj = bpy.context.active_object
    value = 0
    if obj is not None and obj.type == 'CURVE':
        # NOTE: crash is caused by this:
        me = obj.to_mesh()
        value = len(me.polygons)
        obj.to_mesh_clear()
    
    blf.position(0, int(20 * ui_scale), int(bpy.context.region.height) - int(240 * ui_scale), 0)
    blf.draw(0, f"We'll never get to this point, but the curve has {value} polygons.")

handler = None
def register():
    global handler
    handler = bpy.types.SpaceView3D.draw_handler_add(draw_test, (), 'WINDOW', 'POST_PIXEL')
    
def unregister():
    global handler
    if handler is not None:
        bpy.types.SpaceView3D.draw_handler_remove(handler, 'WINDOW')
        handler = None
    
if __name__ == "__main__":
    register()

edit: apparently the blend file did not attach, here it is again

You can get around it passing the evaluated object to to_mesh, see:

Event Timeline

eldee smith (eldee) updated the task description. (Show Details)
Philipp Oeser (lichtwerk) changed the task status from Needs Triage to Confirmed.Dec 29 2021, 2:09 PM

Can confirm, will check

Philipp Oeser (lichtwerk) triaged this task as High priority.Dec 29 2021, 3:06 PM

Caused by rBeb0eb54d9644: Fix D12533: Simplify curve object to mesh conversion

You can get around it passing the evaluated object to to_mesh, see:

It is not totally obvious for me why this crashes (passing the non-evaluated curve) and the commit message would imply this is not generally a problem:

If the object isn't evaluated, it uses a temporary copy of the object
with modifiers removed to create the mesh in the same way.

So, I would still like @Hans Goudey (HooglyBoogly) to take a look (it is just not nice to have working [in 2.93] scripts resulting in a crash all of a sudden without explanation somewhere -- even if 3.0 is a compatibility breaking release)
It is also not mentioned in [if it would be an expected breaking change] https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Python_API

Unfortunately I can't reproduce this at the moment:


Maybe I'm missing something?

Unfortunately I can't reproduce this at the moment:
Maybe I'm missing something?

Is this crash.blend? or crash_corrected.blend?
Are you mouse-selecting points in editmode?
Have you done extrusion prior?

Oops! Apparently I was using crash_corrected.blend. I can reproduce it now. I'll look into this.

I've found the fix, it was a relatively simple mistake in rBeb0eb54d9644. However, based on the code there I would strongly recommend you use @Philipp Oeser (lichtwerk)'s corrected version that uses a depsgraph to get the actual evaluated mesh (or a copy of it anyway).