Page MenuHome

Assert crash when mouse over vertex in Knife tool
Closed, ResolvedPublicBUG

Description

System Information
Operating system: Darwin-19.6.0-x86_64-i386-64bit 64 Bits
Graphics card: AMD Radeon Pro 5300M OpenGL Engine ATI Technologies Inc. 4.1 ATI-3.10.15

Blender Version
Broken: version: 2.91.0 Alpha, branch: nonselfbug (modified), commit date: 2020-09-05 20:01, hash: rB5faf72bb719b
Worked: (newest version of Blender that worked as expected)

Short description of error
In a debug build of, an assert crash happens if move mouse over a vertex when using Knife tool

Exact steps for others to reproduce the error
In a debug build, load factory defaults and enter edit mode (.blend file attached does this),
Type k to enter knife mode.
Move mouse cursor over any vertex.

The assert assert(verts->vertex_alloc != v_len); in GPU_vertbuf_data_resize trips.

Event Timeline

Germano Cavalcante (mano-wii) changed the task status from Needs Triage to Confirmed.Sep 9 2020, 6:45 PM
Germano Cavalcante (mano-wii) changed the subtype of this task from "Report" to "Bug".

I confirm.
The problem may have been introduced in one of the recent refactors of the GPU code.
Apparently the correct value for resizing the vertex buffer is in imm->vertex_idx:

diff --git a/source/blender/gpu/intern/gpu_immediate.cc b/source/blender/gpu/intern/gpu_immediate.cc
index 0a488c0dfc0..9c3a88e30f0 100644
--- a/source/blender/gpu/intern/gpu_immediate.cc
+++ b/source/blender/gpu/intern/gpu_immediate.cc
@@ -186,7 +186,7 @@ void immEnd(void)
 
   if (imm->batch) {
     if (imm->vertex_idx < imm->vertex_len) {
-      GPU_vertbuf_data_resize(imm->batch->verts[0], imm->vertex_len);
+      GPU_vertbuf_data_resize(imm->batch->verts[0], imm->vertex_idx);
       /* TODO: resize only if vertex count is much smaller */
     }
     GPU_batch_set_shader(imm->batch, imm->shader);

This seems to be something for @Clément Foucault (fclem) to take a look at.