Assert in debug for dyntopo sculpt #111574

Closed
opened 2023-08-27 02:39:32 +02:00 by Iliya Katushenock · 7 comments

System Information
Operating system: Windows-10-10.0.19045-SP0 64 Bits
Graphics card: NVIDIA GeForce GTX 1060 6GB/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 527.56

Blender Version
Broken: Today main.
Worked: (newest version of Blender that worked as expected)

Short description of error
See attached stack trace file.

Exact steps for others to reproduce the error
In debug:

  1. Sculp mode.
  2. Enable Dyntopo option.
  3. Do something.
    See the crash.
**System Information** Operating system: Windows-10-10.0.19045-SP0 64 Bits Graphics card: NVIDIA GeForce GTX 1060 6GB/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 527.56 **Blender Version** Broken: Today main. Worked: (newest version of Blender that worked as expected) **Short description of error** See attached stack trace file. **Exact steps for others to reproduce the error** In debug: 1. Sculp mode. 2. Enable Dyntopo option. 3. Do something. See the crash.
Iliya Katushenock added the
Type
Report
Priority
Normal
Status
Needs Triage
labels 2023-08-27 02:39:33 +02:00
Author
Member

Can you take a look at this @HooglyBoogly /

Can you take a look at this @HooglyBoogly /
Hans Goudey self-assigned this 2023-08-27 15:15:12 +02:00
Member

I can confirm the assert hit.

I can confirm the assert hit.
Evan Wilson changed title from Regression: Asser in debug for dyntopo sculpt to Regression: Assert in debug for dyntopo sculpt 2023-08-28 06:35:50 +02:00
Member

I tested main from 1 month ago and the assert still triggered. I don't understand what the assert is supposed to test for, so not sure there's much I can do here.

I tested main from 1 month ago and the assert still triggered. I don't understand what the assert is supposed to test for, so not sure there's much I can do here.
Hans Goudey removed their assignment 2023-08-29 03:17:29 +02:00
Member

I'll lower the priority then.
(Also unclear to us whether this is a regression or not)

I'll lower the priority then. (Also unclear to us whether this is a regression or not)
Pratik Borhade added
Priority
Normal
and removed
Priority
High
labels 2023-08-29 05:47:27 +02:00
Hans Goudey changed title from Regression: Assert in debug for dyntopo sculpt to Assert in debug for dyntopo sculpt 2023-08-29 05:47:57 +02:00
Member

Started looking into this because I'm doing a bit of work on dyntopo related features.

The commit that added a lot of the relevant code is here: 7f133b7a38

I'll do a build of this older commit to see if this assert has failed since this was added, but I'm confused as to how this codepath doesn't cause a segfault with dereferencing a nullptr when the assert is disabled.

  BLI_assert(entry);
  BLI_assert(BLI_ghash_haskey(entry->modified_verts, key));
  lv = static_cast<const BMLogVert *>(BLI_ghash_lookup(entry->modified_verts, key));
  return lv->co;

If BLI_ghash_haskey is returning false, then BLI_ghash_lookup should return NULL which I assume would cause lv->co to then crash blender.

Started looking into this because I'm doing a bit of work on dyntopo related features. The commit that added a lot of the relevant code is here: https://projects.blender.org/blender/blender/commit/7f133b7a38341a245ff4cfab0e18a271c021bd94 I'll do a build of this older commit to see if this assert has failed since this was added, but I'm confused as to how this codepath doesn't cause a segfault with dereferencing a nullptr when the assert is disabled. ``` BLI_assert(entry); BLI_assert(BLI_ghash_haskey(entry->modified_verts, key)); lv = static_cast<const BMLogVert *>(BLI_ghash_lookup(entry->modified_verts, key)); return lv->co; ``` If `BLI_ghash_haskey` is returning false, then `BLI_ghash_lookup` should return `NULL` which I assume would cause `lv->co` to then crash blender.
Member

Yeah, this assert has been here since I started dealing with dyntopo code last year or the year before.

It doesn't segfault because offsetof(BMVert::co) == 0, and the caller has a null check on the returned float pointer.

But I still can't make any sense of this area, so I don't really have a suggestion besides "remove the assert, add some more null checks"

Yeah, this assert has been here since I started dealing with dyntopo code last year or the year before. It doesn't segfault because `offsetof(BMVert::co) == 0`, and the caller has a null check on the returned float pointer. But I still can't make any sense of this area, so I don't really have a suggestion besides "remove the assert, add some more null checks"
Member

Building the code has it crash to an entirely different assert well before it even gets to the topology update. I don't think further digging is going to be particularly useful.

The original assert according to the git history has been around since this file was made back in 2012 - my current understanding of the code added that's calling BM_log_original_vert_co is that it was used for some transitionary code for a deprecated attribute of the PBVH.

It seems like an oversight of the calling code in the end - BM_log_original_vert_co doesn't have a "safe" variant and just assumes that if you're requesting a vertex it has to be in the BMesh Log.

I can see a few options:

  1. Adjust the conditional before calling BM_log_original_vert_co so that it checks for use_original before even attempting to access the log, since the sculpt codepath that is triggering this assert doesnt even want this information.
  2. Add a BM_log_has_vert method and do something similar to 1 so the solution is slightly more robust.
  3. Dig really far into the bm_orco usage and see if it can be safely removed and this update step entirely removed.
Building the code has it crash to an entirely different assert well before it even gets to the topology update. I don't think further digging is going to be particularly useful. The original assert according to the git history has been around since this file was made back in 2012 - my current understanding of the code added that's calling `BM_log_original_vert_co` is that it was used for some transitionary code for a deprecated attribute of the PBVH. It seems like an oversight of the calling code in the end - `BM_log_original_vert_co` doesn't have a "safe" variant and just assumes that if you're requesting a vertex it has to be in the BMesh Log. I can see a few options: 1. Adjust the conditional before calling `BM_log_original_vert_co` so that it checks for `use_original` before even attempting to access the log, since the sculpt codepath that is triggering this assert doesnt even want this information. 2. Add a `BM_log_has_vert` method and do something similar to 1 so the solution is slightly more robust. 3. Dig really far into the `bm_orco` usage and see if it can be safely removed and this update step entirely removed.
Blender Bot added
Status
Resolved
and removed
Status
Confirmed
labels 2024-02-27 17:19:01 +01:00
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
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
4 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#111574
No description provided.