Crash with Viewport measurements turned on #77195
Labels
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
Interest: X11
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
No Assignees
8 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#77195
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
System Information
Operating system: Windows-10-10.0.19041-SP0 64 Bits
Graphics card: GeForce RTX 2080 SUPER/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 446.14
Blender Version
Broken: version: 2.90.0 Alpha, branch: master, commit date: 2020-05-29 18:08, hash:
2ee94c954d
Worked: deaff945d0b965d1^ (caused by
deaff945d0
)Short description of error
Blender crashes when using build new faces from edges.
Stack trace:
Exact steps for others to reproduce the error
Added subscriber: @dgsantana
Crash with Viewport measurements turn onto Crash with Viewport measurements turned onChanged status from 'Needs Triage' to: 'Confirmed'
Added subscribers: @fclem, @Jeroen-Bakker, @rjg
@fclem @Jeroen-Bakker This is likely related to the recent work on the overlay and viewport drawing.
Is the crash happening only in master or also in 2.83?
@fclem Only in master branch.
Added subscribers: @ideasman42, @grosgood
@rjg:
This particular run of code near the crash point, line 400 and following in ##draw_manager_text.c##, comes into being with
9516921c05
by @fclem. @ideasman42 introduced the ##use_coords## logic in6526c3ced8
, but I do not think that has bearing on the matter.You know you are in the weeds when ##poly_to_tri_count()## returns negative counts. When using a debug image, an assert in [poly_to_tri_count()]] catches impending silliness. The particular silliness I'm seeing are corner counts of -1. Polygons that I'm familiar with generally have a positive number of corners. That numeric, I believe, is straight from the mesh face (##f##, below) being queried in the loop beginning at [ https:*developer.blender.org/diffusion/B/browse/master/source/blender/draw/intern/draw_manager_text.c$400|draw_manager_text.c:400 .
The question on the table is how the ##index## field in the ##BMLoop## buffer (##BMFace->l_first##) is being set up. Stay tuned...
T77195_gitbisect.txt
A ##git bisect## exercise leads me to
deaff945d0
by @ideasman42 as the commit along the master branch where this bug is first manifest. Confirm thatec26260132
, blender-v2.83-release does not exhibit this bug. I have not established any causality chains between the files changed by the good Mr. Barton's commit and the bug. That his commit involves edit-mesh -> mesh is suggestive - and that's all for now. See the attached for bisect details.My apologies. Omitted methodology. Designation of 'good' and 'bad' for purposes of ##git bisect## was to open the attached blend file: the default cube with its top face, Fn = {0.0, 0.0, 1.0}, removed and the four edges to form a new top face already selected.
T77195_bug.blend
Few notes:
This leads me to suspect that, "somehow", the new approach of deferring ##edit_mesh -> mesh## is leaving these ##index## members uninitialized - that they are eventually initialized, downstream, so that selecting the face later and asking for area annotation creates no difficulty. I put "somehow" in quotes because all of this is conjecture on my part, not an established causality chain. Stay tuned...
Added subscriber: @lichtwerk
@lichtwerk
Thank you for the update of the task description. Slight correction: commit "deaff94...." (campbell) is the first version that goes into the `loo, not the last version that worked. The last version that worked was (one of ) your May 25 commits:
df8cbdc696
. See the git bisect log I attached: T77195_gitbisect.txt on my 01-June post. I'd fix it myself but I don't have the right Magickal Powers, it seems.@grosgood : in git terms,
deaff945d0b965d1^
is the same asdf8cbdc69645589b
(^
means the last commit before)Ah! Thank you! I stand corrected.
Added subscriber: @zeauro
Same crash on Ubuntu 18.04.
blender.crash.txt
TL;DR
Longish comment. If you must know, It appears to me that a reordering of processing stemming from the commit has put the reindexing of certain BM elements (##BMLoops##) rather late in the pipeline -- too late for the liking of the overlay drawing engine, which is tripping over un-indexed ##BMLoop## elements: the gist of this bug.
A reordering of processing seems to be in order, but hopefully not at the expense of optimization. I'm not decided yet on how to unwrap that wicket. Opinions, observations, tirades welcome...
Immediate cause
See #77195#941825 for background. See also Boundary Mesh Structures.
BM elements ##BMFace##, ##BMEdge##, ##BMVert## and ##BMLoop## all have identical ##BMHeader## structures. Of interest here is ##BMHeader.index## See struct BMHeader .
After pressing {key F}, BM_face_create() gets the nod for generating a new ##BMFace##. This initiates a processing pipeline where a lot of stages have to complete before the overlay drawing engine - where the bug appears - gets to render things, including face-area annotations.
One of those stages entail re-indexing BM elements. Depsgraph evaluation orchestrates that in the context of updating mesh objects. Pseudo-code-ishly, ##BMLoop## re-indexing looks roughly like this:
Macros BM_elem_index_get(elem) and BM_elem_index_set(elem, index) furnish low-level getter/setter interfaces to ##BMHeader## indices. One should not assign to or read from the indices directly.
The assignment of unique non-negative indices to ##BMLoops## and other BM elements occur periodically to ensure uniqueness. Apt choices of BM iterator macros determine what BM element type gets re-indexed. When valid, indices are unique to the mesh and BM element type. The index doesn't "mean" anything beyond the rule that a negative index means "not indexed."
Regarding this, the tripwire for the bug exhibits a certain touching innocence:
Here, ##BM_elem_index_get()## retrieves the ##BMLoop## index; the index is passed, unchecked, to [poly_to_tri_count() ]], fully trusting that ##f->l_first## points to a ##BMLoop## element with a non-negative element index. This innocence is natural across tightly coupled interfaces. Innocence is not the issue. The issue is that at this late processing stage - we're now in the midsts of rendering with the overlay engine - BM elements are still not indexed. That is the immediate cause of the bug: ##poly_to_tri_count()## assumes that the ##BMLoop## index is non-negative, but it is - so the function returns a negative value which causes an out-of-bounds access into the tesselation buffer. That, in [https:*en.wikipedia.org/wiki/Damon_Runyon|Runyonesque terms is the ballgame.
Causality
Mesh management, of which re-indexing BM elements is just one facet, is processing intensive. The commit which triggers this bug strives to minimize processing by taking a 'lazy' or just-in-time approach to (re-)generating mesh representations. One might think that deferring BM element re-indexing may be a part of that, but that does not seem to be the case, given the importance of properly indexed elements. But striving toward a just-in-time approach to processing invariably affects the order in which stages occur, and mistakes can creep in on their proper ordering. That seems to be the case here.
Prior to the commit, BM element re-indexing occurred in the context of depsgraph evaluation, orchestrated by ##BKE_object_handle_data_update()##. Part of the parcel of generating a ##Mesh## for modifier evaluation involved BM_mesh_bm_to_me_for_eval() , where iteration blocks similar to those in Initializing_BMLoops can be found. The back trace during the call ##BM_mesh_bm_to_me_for_eval()## looked like this:
It was in this context that new BM elements with ##-1##-flagged invalid indices obtained valid ones.
Post commit finds a different back trace, with ##editbmesh_calc_modifiers()## calling newly minted functions that operate in the lazy world of just-in-time service. Both [BKE_mesh_from_editmesh_with_coords_thin_wrap() ]] and ##BKE_mesh_from_bmesh_for_eval_nomain()## have been retired, with [ https:*developer.blender.org/rBdeaff945d0b965d1e588cdecd084080b07db2e1f#change-YT3z01K889pL | BKE_mesh_wrapper_from_editmesh_with_coords() the replacement for both. The back trace now looks like:
Here, ##BM_mesh_bm_to_me_for_eval()## has not been retired, but is no longer called in the context of depsgraph evaluation. So the question arises: "At what point does BM element indexing take place in this new scheme of things"?
Watch points on memory locations to detect changes in values is a common technique for pin-pointing where assignments take place, such as the assignment of valid indices to newly minted BM elements. The usual caution against watching memory locations in de-allocated chunks apply, but such events are infrequent in performant code where expensive allocations and de-allocations are frowned upon. Dropping debug watches on all the ##f->l_first[...].head.index## memory blocks very early in the new face processing pipeline - say ##BM_face_create()## - help establish where hitherto invalidated indices are set valid. Prior to the commit, this watch point exercise yielded ##BM_mesh_bm_to_me_for_eval()## as the point in processing where re-indexing occurred, well before the overlay engine comes into play.
In the new scheme, BM element re-indexing appears to take place for all manner of elements - except ##BMLoops## - even up to the point - late in the processing pipeline - when the overlay engine is generating display lists. The watch points placed on ##f->l_first[...].head.index## memory blocks remain untouched by assignments right up to ##draw_manager_text.c:408##, which trips the bug.
As noted in #77195#942808, eventually the ##BMLoop## elements on the new face's ##f->l_first## list are indexed - just too late. Assignment takes place in drawing code, but after the generation of display lists:
As its name implies, BM_mesh_elem_index_ensure() sanitizes BM element indexing. Can it be guaranteed to run before the overlay rendering engine gets to work? That is the question of the day, and, methinks, the road to closing this bug.
Apologies for the wall of words, but I, for one, hanker for bug analysis and investigation. I suppose anyone with opinions on that could take it up with me on DevTalk . Perhaps a terse TL;DR here and the extended commentary over there. I'm inclined to keep Things In One Place, however, not that I'm actually that organized.
References
BMesh Design
BMesh Structures
This issue was referenced by
48ca66cfe7
Changed status from 'Confirmed' to: 'Resolved'