[2.8 Crash] Program crash when extruding+face snap #56167

Closed
opened 2018-07-31 05:48:44 +02:00 by Nahuel Belich · 16 comments

System Information
win 7 x64
Nvidia 1070 (Gigabyte G1) Drivers: 398.36

Blender Version
Broken: Hash: 66a00b64c5 (date: 2018-07-29 02:12)

Short description of error
Crashes when extruding.
The windows console prints this error after crash
image.png

Exact steps for others to reproduce the error
1-Open crash3.blend
2- Select an edge of the "RETOPO" object
3- use E to extrude.
4-if doesn't crash try a few times.

[Demo Video]
I know that video its not the way to report bugs but i wasn't able to get an example to properly crash first try, the crashes in the video are lucky first try crashes.
https://www.youtube.com/watch?v=lyjg734Tg2o

**System Information** win 7 x64 Nvidia 1070 (Gigabyte G1) Drivers: 398.36 **Blender Version** Broken: Hash: 66a00b64c5c (date: 2018-07-29 02:12) **Short description of error** Crashes when extruding. The windows console prints this error after crash ![image.png](https://archive.blender.org/developer/F4090136/image.png) **Exact steps for others to reproduce the error** 1-Open [crash3.blend](https://archive.blender.org/developer/F4090150/crash3.blend) 2- Select an edge of the "RETOPO" object 3- use E to extrude. 4-if doesn't crash try a few times. [Demo Video] I know that video its not the way to report bugs but i wasn't able to get an example to properly crash first try, the crashes in the video are lucky first try crashes. https://www.youtube.com/watch?v=lyjg734Tg2o
Author

Added subscriber: @NahuelBelich

Added subscriber: @NahuelBelich

#56471 was marked as duplicate of this issue

#56471 was marked as duplicate of this issue

Added subscriber: @mont29

Added subscriber: @mont29

Hmmm… Tried like 20 times, could not get a single crash…

Please:

  • Try the latest build from our buildbot.
  • Try to start Blender in factory settings (--factory-startup commandline option) (this will ensure whether this is a userpref or addon issue or not).
  • Launch Blender from the command line with -t 1 option (single thread mode).
  • Launch Blender from the command line with -d option and attach as text file here any error printed out in the console (do not paste it directly in comment).
  • Launch Blender from the command line with --debug-gpu option and attach as text file here any error printed out in the console (do not paste it directly in comment).
Hmmm… Tried like 20 times, could not get a single crash… Please: * Try the latest build from [our buildbot](https://builder.blender.org/download). * Try to start Blender in factory settings (`--factory-startup` commandline option) (this will ensure whether this is a userpref or addon issue or not). * Launch Blender from the command line with `-t 1` option (single thread mode). * Launch Blender from the command line with `-d` option and **attach as text file** here any error printed out in the console (**do not** paste it directly in comment). * Launch Blender from the command line with `--debug-gpu` option and **attach as text file** here any error printed out in the console (**do not** paste it directly in comment).

Added subscriber: @s12a

Added subscriber: @s12a

After extruding an edge 3 times with E, I could reproduce the issue on 5300ba0ba5 and:
Windows 10 Pro 64 bit (1803)
AMD Radeon RX480 4GB with Radeon Software 18.7.1

I used a debug build, here's the backtrace.
crash3.crash.txt
output.txt

After extruding an edge 3 times with E, I could reproduce the issue on 5300ba0ba50 and: Windows 10 Pro 64 bit (1803) AMD Radeon RX480 4GB with Radeon Software 18.7.1 I used a debug build, here's the backtrace. [crash3.crash.txt](https://archive.blender.org/developer/F4091511/crash3.crash.txt) [output.txt](https://archive.blender.org/developer/F4091525/output.txt)
Germano Cavalcante was assigned by Bastien Montagne 2018-07-31 15:50:17 +02:00

Added subscriber: @mano-wii

Added subscriber: @mano-wii

@mano-wii looks like crash happens in raycasting code, maybe you are interested in investigating that one? Especially since it seems to only be reproducible on windows. :/

@mano-wii looks like crash happens in raycasting code, maybe you are interested in investigating that one? Especially since it seems to only be reproducible on windows. :/

In summary the problem is in the update_mesh_edit_mode_pointers and discard_mesh_edit_mode_pointers functions of the deg_eval_copy_on_write.cc file.

A copy of the edit_btmesh from mesh_orig is done in the mesh_cow. So the same looptris pointer is used on both meshes.

But when doing an extrusion, the number of looptris changes and the looptris are reallocated in the original mesh causing the mesh_cow pointer to be invalid.

The looptris are reallocated in the BKE_editmesh_tessface_calc function.

In summary the problem is in the `update_mesh_edit_mode_pointers` and `discard_mesh_edit_mode_pointers` functions of the `deg_eval_copy_on_write.cc` file. A copy of the `edit_btmesh` from `mesh_orig` is done in the `mesh_cow`. So the same `looptris` pointer is used on both meshes. But when doing an extrusion, the number of looptris changes and the looptris are reallocated in the original mesh causing the `mesh_cow` pointer to be invalid. The looptris are reallocated in the `BKE_editmesh_tessface_calc` function.

Added subscribers: @Andruxa696, @CharlieJolly

Added subscribers: @Andruxa696, @CharlieJolly

Added subscriber: @ideasman42

Added subscriber: @ideasman42

Issue is in fact exact same one as with undo/redo: in macros, when next operator needs access to evaluated data, we have to ensure depsgraph is properly evaluated before calling that next operator:

diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c
index 1d66616a038..4ff98ced9e5 100644
--- a/source/blender/editors/transform/transform_ops.c
+++ b/source/blender/editors/transform/transform_ops.c
@@ -640,7 +640,7 @@ static void TRANSFORM_OT_translate(struct wmOperatorType *ot)
 	ot->name   = "Move";
 	ot->description = "Move selected items";
 	ot->idname = OP_TRANSLATION;
-	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
+	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_USE_EVAL_DATA;
 
 	/* api callbacks */
 	ot->invoke = transform_invoke;
diff --git a/source/blender/windowmanager/intern/wm_operator_type.c b/source/blender/windowmanager/intern/wm_operator_type.c
index 89421ac0ab0..9f468825ae6 100644
--- a/source/blender/windowmanager/intern/wm_operator_type.c
+++ b/source/blender/windowmanager/intern/wm_operator_type.c
@@ -43,6 +43,8 @@
 - include "BKE_context.h"
 - include "BKE_idprop.h"
 #include "BKE_library.h"
+#include "BKE_main.h"
+#include "BKE_scene.h"
 
 - include "RNA_access.h"
 - include "RNA_define.h"
@@ -357,7 +359,7 @@ static int wm_macro_invoke_internal(bContext *C, wmOperator *op, const wmEvent *
 	int retval = OPERATOR_FINISHED;
 
 	/* start from operator received as argument */
-	for (; opm; opm = opm->next) {
+	while (opm) {
 		if (opm->type->invoke)
 			retval = opm->type->invoke(C, opm, event);
 		else if (opm->type->exec)
@@ -374,6 +376,16 @@ static int wm_macro_invoke_internal(bContext *C, wmOperator *op, const wmEvent *
 		else {
 			break; /* operator didn't finish, end macro */
 		}
+
+		opm = opm->next;
+		if (opm != NULL && opm->type->flag & OPTYPE_USE_EVAL_DATA) {
+			/* We need to force refresh of depsgraph after first operator,
+			 * since next one *may* rely on some valid evaluated data. */
+			Main *bmain = CTX_data_main(C);
+			Scene *scene = CTX_data_scene(C);
+			ViewLayer *view_layer = CTX_data_view_layer(C);
+			BKE_scene_view_layer_graph_evaluated_ensure(bmain, scene, view_layer);
+		}
 	}
 
 	return wm_macro_end(op, retval);

@ideasman42 issue with patch above is that it needs to set whole transform operator as 'needing evaluated data', which is not a good idea in redo context (when tweaking a transform value in redo panel e.g.). I think we'll actually need to add a new 'flag_poll' callback to operatortype? That way, we could (optionally) return flags finely tuned to actual needs… E.g. in that case, only set OPTYPE_USE_EVAL_DATA when we actually do snapping on geometry, etc.

Issue is in fact exact same one as with undo/redo: in macros, when next operator needs access to evaluated data, we have to ensure depsgraph is properly evaluated before calling that next operator: ```lines=20 diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 1d66616a038..4ff98ced9e5 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -640,7 +640,7 @@ static void TRANSFORM_OT_translate(struct wmOperatorType *ot) ot->name = "Move"; ot->description = "Move selected items"; ot->idname = OP_TRANSLATION; - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_USE_EVAL_DATA; /* api callbacks */ ot->invoke = transform_invoke; diff --git a/source/blender/windowmanager/intern/wm_operator_type.c b/source/blender/windowmanager/intern/wm_operator_type.c index 89421ac0ab0..9f468825ae6 100644 --- a/source/blender/windowmanager/intern/wm_operator_type.c +++ b/source/blender/windowmanager/intern/wm_operator_type.c @@ -43,6 +43,8 @@ - include "BKE_context.h" - include "BKE_idprop.h" #include "BKE_library.h" +#include "BKE_main.h" +#include "BKE_scene.h" - include "RNA_access.h" - include "RNA_define.h" @@ -357,7 +359,7 @@ static int wm_macro_invoke_internal(bContext *C, wmOperator *op, const wmEvent * int retval = OPERATOR_FINISHED; /* start from operator received as argument */ - for (; opm; opm = opm->next) { + while (opm) { if (opm->type->invoke) retval = opm->type->invoke(C, opm, event); else if (opm->type->exec) @@ -374,6 +376,16 @@ static int wm_macro_invoke_internal(bContext *C, wmOperator *op, const wmEvent * else { break; /* operator didn't finish, end macro */ } + + opm = opm->next; + if (opm != NULL && opm->type->flag & OPTYPE_USE_EVAL_DATA) { + /* We need to force refresh of depsgraph after first operator, + * since next one *may* rely on some valid evaluated data. */ + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + BKE_scene_view_layer_graph_evaluated_ensure(bmain, scene, view_layer); + } } return wm_macro_end(op, retval); ``` @ideasman42 issue with patch above is that it needs to set whole transform operator as 'needing evaluated data', which is not a good idea in redo context (when tweaking a transform value in redo panel e.g.). I think we'll actually need to add a new 'flag_poll' callback to operatortype? That way, we could (optionally) return flags finely tuned to actual needs… E.g. in that case, only set `OPTYPE_USE_EVAL_DATA` when we actually do snapping on geometry, etc.

I don't really like the idea of keeping a looptris pointer for each object evaluated.
Since the bmesh does not change, these looptris would be exact copies and it would be necessary to make sure to recalculate the looptris in each access.

This is one of the reasons for the reported inefficiency of the transform operator in edit mode.
Since it is not easy to determine when the looptris pointer has been deallocated, the BKE_editmesh_tessface_calc function is always called to do a render_data with looptris in the draw_manager: draw_cache_impl_mesh.c 414 .

Therefore the looptris are recalculated at least 3 times at each interaction. One in the operator transform to the original mesh, another in DRW_mesh_batch_cache_get_surface_shaded and one in DRW_mesh_batch_cache_get_overlay_triangles.

Since bmesh does not change, the looptris are the same and should be recalculated only once.

I don't really like the idea of keeping a looptris pointer for each object evaluated. Since the bmesh does not change, these looptris would be exact copies and it would be necessary to make sure to recalculate the looptris in each access. This is one of the reasons for the reported inefficiency of the transform operator in edit mode. Since it is not easy to determine when the looptris pointer has been deallocated, the `BKE_editmesh_tessface_calc` function is always called to do a `render_data` with looptris in the draw_manager: [draw_cache_impl_mesh.c 414 ](https://developer.blender.org/diffusion/B/browse/blender2.8/source/blender/draw/intern/draw_cache_impl_mesh.c;629c6a87693a8aebb87e74c5c782bddce6b613ef$414). Therefore the looptris are recalculated at least 3 times at each interaction. One in the `operator transform` to the original mesh, another in `DRW_mesh_batch_cache_get_surface_shaded` and one in `DRW_mesh_batch_cache_get_overlay_triangles`. Since bmesh does not change, the looptris are the same and should be recalculated only once.

@mano-wii that is kind of separated issue, not directly related to that bug imho.

@mano-wii that is kind of separated issue, not directly related to that bug imho.

This issue was referenced by 36429a5bc9

This issue was referenced by 36429a5bc99aec3d178fb7c9e0350c82b47bb37a

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#56167
No description provided.