Blender crashes when modifiny mesh data on Depsgraph-Update-Pre

Hey everyone,

I’m currently working on expanding the Stop-Motion-OBJ Addon. Unfortunately I’m experiencing a crash when I modify mesh data in the Depsgraph-Update-Pre event. This is the code block in question:

        bmNew =

        if(len(next_mesh.materials) > 0):
            for material in next_mesh.materials:
                print("Appended next mesh mat")

The part where I’m copying data from one mesh to another works fine. But I’m experiencing a crash when I try to do any modification of the materials data (such as clear or append). The crash doesn’t occur when I use the Depsgraph-Update-Post, Frames_Change_pre or Frames_Change_Post event to call the same function, but unfortunately I need this function to work in the Depsgraph-Update-Pre call.

My question is, could this be a bug in blender, or am I doing something that I shouldn’t do in the Depsgraph-Pre event?

This is the crash-log:

Exception Record:

Exception Address : 0x00007FF7223963E3
Exception Module : blender.exe
Exception Flags : 0x00000000
Exception Parameters : 0x2
Parameters[0] : 0x0000000000000000
Parameters[1] : 0x0000000000000060

Stack trace:
blender.exe :0x00007FF7223961A0 library_foreach_ID_link
blender.exe :0x00007FF722395910 BKE_library_foreach_ID_link
blender.exe :0x00007FF722674490 blender::deg::DepsgraphNodeBuilder::end_build
blender.exe :0x00007FF722664300 blender::deg::AbstractBuilderPipeline::build
blender.exe :0x00007FF72264EBD0 DEG_graph_relations_update
blender.exe :0x00007FF72237CA50 scene_graph_update_tagged
blender.exe :0x00007FF722BC8B20 blender::io::alembic::export_startjob
blender.exe :0x00007FF722587860 do_job_thread
blender.exe :0x00007FF7277D39C0 _ptw32_threadStart
ucrtbase.dll :0x00007FFCA85A6BB0 recalloc
KERNEL32.DLL :0x00007FFCA8D854D0 BaseThreadInitThunk
ntdll.dll :0x00007FFCAA9A4830 RtlUserThreadStart

Hi. For bug reports it’s better to use the bug-tracker, because over here it will get ignored/forgotten.

If you can reliably trigger the crash , report it via ‘report a bug’ from the help menu inside blender. You’ll get sent to a page on (you’ll need an account there as well) where you can fill in all the details.

The devs need to be able to reproduce the problem, so you’ll need to find a way to either reproduce the crash from the default startup scene, or you’ll need to upload a .blend file (made as small as possible!, delete everything not needed to show it) which shows the crash.

Hi Baardaap,

thank you for the detailed answer! I just wasn’t sure if it was just my inexperience with Blender programming or a real bug in Blender, but I filed a bug report as you suggested! :slight_smile:

The post to the report is here, if anyone happens to stumble upon the same problem: ⚓ T95196 Crash when modifing materials after using BMesh in Depsgraph-Pre event

I must say I got slightly confused replying to you and replying to someone else who had an obvious bug. (Note to self: don’t reply to stuff when tired…) so this could be because of misuse of the API indeed and not actually be a bug.

You probably already tried that, but does the crash still happen if you move the to after all the other operations? Just guessing here, but that’s something I’d investigate.

Hey Baardaap, haha no problem!

Yes I already tried that, unfortunately with no success. While creating the bug report I also tried to condense the code as much as possible, so there are few variables left that I could try. The whole code works with depsgraph_update_post, so I think either I’m doing things that are not supposed to be done in the update_pre, or it is a bug in blender.