Page MenuHome

Object.to_mesh(preserve_all_data_layers=True, depsgraph=depsgraph) with no modifiers or shapekeys = crash
Closed, ResolvedPublic


Blender Version
Broken: blender-2.80.0-git.89207df7222a-windows64

Short description of error
I'm running a mesh export operator that uses the Object.to_mesh(preserve_all_data_layers=True, depsgraph=depsgraph) function with parameters so vertex groups carry over to the new mesh. And I always end with Object.to_mesh_clear().
But if I run the operator on an object with no modifiers or shapekeys, it crashes.
I've tried to chase down the exact point it crashes through a debugger, but it's random, it crashes at different lines of code which don't relate to the cause. No matter what though, it crashes before the operator finishes.
If I add a modifier or shape key to the object in question, it does not crash.
Or if I use Object.to_mesh() without parameters, no crash.
Or if I run a snippet of my operator's problmatic code in the script area, no crash.

I'm sorry I can't provide an example right now, I've tried to recreate it in a simple blend script but I can only trigger the crash in an addon that I'm working on.
Hopefully someone could look into the recently made changes and spot the bug that's causing Blender to become unstable after calling this function on simple objects.

Running Blender in debug mode prevents crashing, but I get the following error in the console during each operation:

Memoryblock CDMVert: double free
Memoryblock free: pointer not in memlist

Update 2:
I tried the latest release with the material bug fix (T65238), still no luck.
I also tried running blender_debug_log.cmd, when it crashes I get the following error:

Address : 0x00007FF68B0302D8
Module  : C:\Dev\Blender\blender-2.80.0\blender.exe

Event Timeline

Sergey Sharybin (sergey) triaged this task as Normal priority.

Unfortunately it's still crashing for me for objects without modifiers or shapekeys, and I'm building from the latest source.

"Memoryblock free: pointer not in memlist"

I've never tried debugging from source but I will give it a go and maybe see if I can pin point the issue further.

Sergey Sharybin (sergey) lowered the priority of this task from Normal to Needs Information from User.May 31 2019, 12:53 PM

Provide the simple .blend file and script which demonstrates the issue.

Here's the stack trace when it crashes:

blender.exe!issue_debug_notification(const wchar_t * const message) Line 28
	at minkernel\crts\ucrt\src\appcrt\internal\report_runtime_error.cpp(28)
blender.exe!__acrt_report_runtime_error(const wchar_t * message) Line 154
	at minkernel\crts\ucrt\src\appcrt\internal\report_runtime_error.cpp(154)
blender.exe!abort() Line 61
	at minkernel\crts\ucrt\src\appcrt\startup\abort.cpp(61)
blender.exe!bpy_bmesh_to_mesh(BPy_BMesh * self, _object * args) Line 1092
	at c:\dev\blender\blender\blender\source\blender\python\bmesh\bmesh_py_types.c(1092)
[External Code]
blender.exe!bpy_class_call(bContext * C, PointerRNA * ptr, FunctionRNA * func, ParameterList * parms) Line 8276
	at c:\dev\blender\blender\blender\source\blender\python\intern\bpy_rna.c(8276)
blender.exe!rna_operator_execute_cb(bContext * C, wmOperator * op) Line 1282
	at c:\dev\blender\blender\blender\source\blender\makesrna\intern\rna_wm.c(1282)
blender.exe!wm_handler_fileselect_do(bContext * C, ListBase * handlers, wmEventHandler_Op * handler, int val) Line 2394
	at c:\dev\blender\blender\blender\source\blender\windowmanager\intern\wm_event_system.c(2394)
blender.exe!wm_handler_fileselect_call(bContext * C, ListBase * handlers, wmEventHandler_Op * handler, const wmEvent * event) Line 2493
	at c:\dev\blender\blender\blender\source\blender\windowmanager\intern\wm_event_system.c(2493)
blender.exe!wm_handlers_do_intern(bContext * C, wmEvent * event, ListBase * handlers) Line 2807
	at c:\dev\blender\blender\blender\source\blender\windowmanager\intern\wm_event_system.c(2807)
blender.exe!wm_handlers_do(bContext * C, wmEvent * event, ListBase * handlers) Line 2859
	at c:\dev\blender\blender\blender\source\blender\windowmanager\intern\wm_event_system.c(2859)
blender.exe!wm_event_do_handlers(bContext * C) Line 3223
	at c:\dev\blender\blender\blender\source\blender\windowmanager\intern\wm_event_system.c(3223)
blender.exe!WM_main(bContext * C) Line 420
	at c:\dev\blender\blender\blender\source\blender\windowmanager\intern\wm.c(420)
blender.exe!main(int argc, const unsigned char * * UNUSED_argv_c) Line 502
	at c:\dev\blender\blender\blender\source\creator\creator.c(502)
[External Code]

It appears to be happening in the middle of BM_mesh_bm_to_me(), however in visual studio the current line is pointing to an BLI assertion above the call.

Provide the simple .blend file and script which demonstrates the issue.

I tried to simplify the script to the problematic to_mesh() call within the addon script, but it would never trigger the crash if run in isolation.

So I've included the addon directory, the blend file, and inside the blend file a script that will install the addon and run it, triggering the crash.

In order for the bug to be fixed we need to be able to reproduce it. Stack trace is not enough.

Oh, think i've replied at the same time a you've been writing a followup.
After some tinkering around managed to get everything installed. Not sure yet what;s going on. Seems like bpy_bmesh_to_mesh doesn't like meshes which are not in the main database. Need to understand reasoning behind that.

Sergey Sharybin (sergey) raised the priority of this task from Needs Information from User to Confirmed, Medium.May 31 2019, 2:01 PM
Sergey Sharybin (sergey) closed this task as Resolved.May 31 2019, 3:07 PM

Committed fix in rB72a563c.

if there are more issue please make a new report. Otherwise keeping track of the issues becomes tricky.