WIP: Fix #93103: modifier iterations can be set to a negative value #110916

Draft
Philipp Oeser wants to merge 1 commits from lichtwerk/blender:93103 into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Member

Sanitize "iterations" in a couple of modifiers (namely Smooth, Corrective
Smooth, Laplacian Smooth & Laplacian Deform) to always
have a hard limit of 0.

Putting in negative values does not make sense (and could have caused an
infinite loop since the negative value is cast to unsigned internally in
the case of the 'Corrective Smooth' modifier).

Sanitize "iterations" in a couple of modifiers (namely Smooth, Corrective Smooth, Laplacian Smooth & Laplacian Deform) to always have a hard limit of 0. Putting in negative values does not make sense (and could have caused an infinite loop since the negative value is cast to unsigned internally in the case of the 'Corrective Smooth' modifier).
Philipp Oeser added 1 commit 2023-08-08 10:36:02 +02:00
Sanitize "iterations" in a couple of modifiers (namely Smooth, Corrective
Smooth, Laplacian Smooth & Laplacian Deform) to always
have a hard limit of 0.

Putting in negative values does not make sense (and could have caused an
infinite loop since the negative value is cast to unsigned internally in
the case of the 'Corrective Smooth' modifier).
Philipp Oeser added the
Interest
Modeling
Interest
Modifiers
Interest
User Interface
labels 2023-08-08 10:36:27 +02:00
Philipp Oeser requested review from Bastien Montagne 2023-08-08 10:36:55 +02:00
Philipp Oeser requested review from Hans Goudey 2023-08-08 10:37:09 +02:00
Author
Member

This came up again in chat (was already on phabricator, see https://archive.blender.org/developer/D13240)

This came up again in chat (was already on phabricator, see https://archive.blender.org/developer/D13240)
Bastien Montagne requested changes 2023-08-08 10:43:11 +02:00
Bastien Montagne left a comment
Owner

LGTM, but think there should also be hard-coded clamping in the modifiers code itself? Especially given the fact that DNA values are short, not unsigned short... And even SHRT_MAX is likely waaaaayyyy to high as absolute max value, think hard-coded clamping in the [0, 1000] range would be a reasonable value?

LGTM, but think there should also be hard-coded clamping in the modifiers code itself? Especially given the fact that DNA values are `short`, not `unsigned short`... And even `SHRT_MAX` is likely waaaaayyyy to high as absolute max value, think hard-coded clamping in the `[0, 1000]` range would be a reasonable value?
Author
Member

LGTM, but think there should also be hard-coded clamping in the modifiers code itself? Especially given the fact that DNA values are short, not unsigned short... And even SHRT_MAX is likely waaaaayyyy to high as absolute max value, think hard-coded clamping in the [0, 1000] range would be a reasonable value?

Dont think we are going the extra route of clamping theoretical DNA values in the modifiers code elsewhere (if we already "clamp" in RNA)? We dont do this in SubD for example. Not saying this would be bad to do, but then we should also do everywhere else?

No strong opinion about the range, in the worst case, this is just wasting compute time, dont think this will actually cause issues running out of memory etc? And I do recall cases were we lifted "arbitrary" range limits again (for folks who were actually in need to have higher limits) -- but like I said, no strong opinion about changing that to [0, 1000] ...

> LGTM, but think there should also be hard-coded clamping in the modifiers code itself? Especially given the fact that DNA values are `short`, not `unsigned short`... And even `SHRT_MAX` is likely waaaaayyyy to high as absolute max value, think hard-coded clamping in the `[0, 1000]` range would be a reasonable value? Dont think we are going the extra route of clamping theoretical DNA values in the modifiers code elsewhere (if we already "clamp" in RNA)? We dont do this in SubD for example. Not saying this would be bad to do, but then we should also do everywhere else? No strong opinion about the range, in the worst case, this is just wasting compute time, dont think this will actually cause issues running out of memory etc? And I do recall cases were we lifted "arbitrary" range limits again (for folks who were actually in need to have higher limits) -- but like I said, no strong opinion about changing that to `[0, 1000]` ...

Most of these modifiers applied to production data with too many iterations will lead to Blender freezing for minutes, if not hours.

Also since so far there was no limit, if you do not want to do a hard clamping in modifiers code itself, then you need at least to do a do-version, otherwise older files can still have negative (or insanely high positive) values...

IMHO it's way simpler and safer here to have same hard-clamping applied in modifiers code, as the one defined in RNA (can even use defines from DNA file actually, to be sure they always remain in sync).

And indeed could see other similar cases needing similar handling, yes.

Most of these modifiers applied to production data with too many iterations will lead to Blender freezing for minutes, if not hours. Also since so far there was no limit, if you do not want to do a hard clamping in modifiers code itself, then you need at least to do a do-version, otherwise older files can still have negative (or insanely high positive) values... IMHO it's way simpler and safer here to have same hard-clamping applied in modifiers code, as the one defined in RNA (can even use defines from DNA file actually, to be sure they always remain in sync). And indeed could see other similar cases needing similar handling, yes.
Philipp Oeser changed title from Fix #93103: modifier iterations can be set to a negative value to WIP: Fix #93103: modifier iterations can be set to a negative value 2023-08-08 13:51:16 +02:00
Hans Goudey approved these changes 2024-01-30 04:59:12 +01:00
Hans Goudey left a comment
Member

I would not add the clamping to the modifiers code when it exists in RNA, I think this is fine as is. Or even if that clamping is wanted by some, it should be discussed and added later. This will fix the crash.

I would not add the clamping to the modifiers code when it exists in RNA, I think this is fine as is. Or even if that clamping is wanted by some, it should be discussed and added later. This will fix the crash.
This pull request is marked as a work in progress.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 93103:lichtwerk-93103
git checkout lichtwerk-93103
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
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
Asset Browser Project
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
3 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#110916
No description provided.