Regression: QuadriFlow Remesh Crash #105953

Closed
opened 2023-03-21 13:50:12 +01:00 by Philipp Oeser · 9 comments
Member

System Information
Operating system: Linux-6.1.18-200.fc37.x86_64-x86_64-with-glibc2.36 64 Bits
Graphics card: AMD Radeon Graphics (renoir, LLVM 15.0.7, DRM 3.49, 6.1.18-200.fc37.x86_64) AMD 4.6 (Core Profile) Mesa 22.3.7

Blender Version
Broken: version: 3.6.0 Alpha, branch: main, commit date: 2023-03-20 00:12, hash: 7cda559d7c1b
Broken: 3.4
Worked: 3.3 LTS

Caused by 511ac66dab

Short description of error
QuadriFlow Remesh crashes with a somewhat large mesh
Spotted while investigating #105164 (which is related, but not a regression like the case presented here)

Exact steps for others to reproduce the error
I cleaned up the file from #105164 a bit (removed materials, attributes, UVMaps, nonmanifold parts etc.) to rule out other possible errors.

This now has 4 separate parts.

  • joining does not result in nonmanifold geo
  • if you join any three of them, a QuadriFlow Remesh afterwards to 40k faces works on my side
  • if you join all 4 of them, a QuadriFlow Remesh afterwards to 40k faces crashes

repro_cleanup.blend

OR, if you just want the file that was working before 511ac66dab (and is now crashing), use the already joined file

So
repro_cleanup_joined.blend

  • open the file
  • QuadriFlow Remesh operator set to 40k faces
  • crash
**System Information** Operating system: Linux-6.1.18-200.fc37.x86_64-x86_64-with-glibc2.36 64 Bits Graphics card: AMD Radeon Graphics (renoir, LLVM 15.0.7, DRM 3.49, 6.1.18-200.fc37.x86_64) AMD 4.6 (Core Profile) Mesa 22.3.7 **Blender Version** Broken: version: 3.6.0 Alpha, branch: main, commit date: 2023-03-20 00:12, hash: `7cda559d7c1b` Broken: 3.4 Worked: 3.3 LTS Caused by 511ac66dab **Short description of error** QuadriFlow Remesh crashes with a somewhat large mesh Spotted while investigating #105164 (which is related, but not a regression like the case presented here) **Exact steps for others to reproduce the error** I cleaned up the file from #105164 a bit (removed materials, attributes, UVMaps, nonmanifold parts etc.) to rule out other possible errors. This now has 4 separate parts. - joining does not result in nonmanifold geo - if you join any three of them, a QuadriFlow Remesh afterwards to 40k faces works on my side - if you join all 4 of them, a QuadriFlow Remesh afterwards to 40k faces crashes [repro_cleanup.blend](/attachments/f9eec6ed-a46e-4e66-a61a-99efcda0ed82) OR, if you just want the file that was working before 511ac66dab (and is now crashing), use the already joined file So [repro_cleanup_joined.blend](/attachments/ad09bd6e-3cab-4f34-8b01-13d6ff632db9) - open the file - QuadriFlow Remesh operator set to 40k faces - crash
Philipp Oeser added the
Type
Report
Status
Confirmed
Priority
High
Module
Modeling
labels 2023-03-21 13:50:48 +01:00
Author
Member
CC @HooglyBoogly CC @ZedDB
Hans Goudey added
Type
Bug
and removed
Type
Report
labels 2023-03-21 14:46:23 +01:00
Member

In a quest for more information I ran this in a debug build. 1 hour later it isn't finished with 40k verts, so I'll try something else. It does look like there's a bunch more mesh copying going on than necessary in this operator, but I didn't find that was the problem.

In a quest for more information I ran this in a debug build. 1 hour later it isn't finished with 40k verts, so I'll try something else. It does look like there's a bunch more mesh copying going on than necessary in this operator, but I didn't find that was the problem.
Member

Can someone confirm that this fixes it?

diff --git a/extern/quadriflow/src/hierarchy.cpp b/extern/quadriflow/src/hierarchy.cpp
index 8cc41da23d0..0bf2ba53b23 100644
--- a/extern/quadriflow/src/hierarchy.cpp
+++ b/extern/quadriflow/src/hierarchy.cpp
@@ -269,7 +269,7 @@ void Hierarchy::DownsampleGraph(const AdjacentMatrix adj, const MatrixXd& V, con
         for (auto it = ad.begin(); it != ad.end(); ++it, ++entry_it) {
             int k = it->id;
             double dp = N.col(i).dot(N.col(k));
-            double ratio = A[i] > A[k] ? (A[i] / A[k]) : (A[k] / A[i]);
+            double ratio = (A[i] == 0.0f || A[k] == 0.0f) ? (A[i] > A[k] ? (A[i] / A[k]) : (A[k] / A[i])) : 1.0f;
             *entry_it = Entry(i, k, dp * ratio);
         }
     }

I got /home/jacques/blender/blender/extern/quadriflow/src/hierarchy.cpp:272:48: runtime error: division by zero from ASAN.

Can someone confirm that this fixes it? ``` diff --git a/extern/quadriflow/src/hierarchy.cpp b/extern/quadriflow/src/hierarchy.cpp index 8cc41da23d0..0bf2ba53b23 100644 --- a/extern/quadriflow/src/hierarchy.cpp +++ b/extern/quadriflow/src/hierarchy.cpp @@ -269,7 +269,7 @@ void Hierarchy::DownsampleGraph(const AdjacentMatrix adj, const MatrixXd& V, con for (auto it = ad.begin(); it != ad.end(); ++it, ++entry_it) { int k = it->id; double dp = N.col(i).dot(N.col(k)); - double ratio = A[i] > A[k] ? (A[i] / A[k]) : (A[k] / A[i]); + double ratio = (A[i] == 0.0f || A[k] == 0.0f) ? (A[i] > A[k] ? (A[i] / A[k]) : (A[k] / A[i])) : 1.0f; *entry_it = Entry(i, k, dp * ratio); } } ``` I got `/home/jacques/blender/blender/extern/quadriflow/src/hierarchy.cpp:272:48: runtime error: division by zero` from ASAN.
Member

This fixed the issue for me too. Thanks!

This fixed the issue for me too. Thanks!
Author
Member

Can also confirm this fixes it for me (#105164 still crashes though, but that is another story...)

Can also confirm this fixes it for me (#105164 still crashes though, but that is another story...)

Sorry but can someone explain how that patch works?
To me it looks like it checks if A[i] or A[k] is 0.0f and if it is it still runs the division (which will always be divide by zero or 0.0f) and if not, the ratio is 1.0f.

Sorry but can someone explain how that patch works? To me it looks like it checks if `A[i]` or `A[k]` is 0.0f and if it is it still runs the division (which will always be divide by zero or 0.0f) and if not, the ratio is 1.0f.
Member

@erik85 It probably makes more sense when you have a closer look at the parenthesis (nested ternary conditions are hard to read)

@erik85 It probably makes more sense when you have a closer look at the parenthesis (nested ternary conditions are hard to read)

@erik85 It probably makes more sense when you have a closer look at the parenthesis (nested ternary conditions are hard to read)

Hmm, no I don't see it. I must be misunderstanding the whole point of that.

(A[i] == 0.0f || A[k] == 0.0f)
?
(A[i] > A[k] ? (A[i] / A[k]) : (A[k] / A[i]))
:
1.0f
> @erik85 It probably makes more sense when you have a closer look at the parenthesis (nested ternary conditions are hard to read) Hmm, no I don't see it. I must be misunderstanding the whole point of that. ``` (A[i] == 0.0f || A[k] == 0.0f) ? (A[i] > A[k] ? (A[i] / A[k]) : (A[k] / A[i])) : 1.0f ```
Member

Hm, you're right, that is even more confusing. Guess it cancels the problem out somehow, don't ask me why. It works the the "correct" condition as well though.

Hm, you're right, that is even more confusing. Guess it cancels the problem out somehow, don't ask me why. It works the the "correct" condition as well though.
Jacques Lucke self-assigned this 2023-03-27 14:49:22 +02:00
Blender Bot added
Status
Resolved
and removed
Status
Confirmed
labels 2023-03-28 14:25:35 +02: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#105953
No description provided.