Fix crashes when connecting cyclic grease pencil curves #117842

Merged
Lukas Tönne merged 5 commits from LukasTonne/blender:fix-cyclic-curves-crash into main 2024-02-05 14:47:15 +01:00
Member

Curves draw buffer updates and operations like resampling access the
evaluated lengths cache of curves. However, when the curve has only one
point the evaluated lengths will be empty. This is not a problem for
open curves, because they skip calculation of the last point, but cyclic
curves expect to have as many length entries as there are points.

This crashes in certain cases:

  • Grease Pencil v3 edit mode "Toggle Cyclic" operator
  • Geometry nodes resampling of cyclic, single-vertex curves

Checking for the single-point case when building draw buffers handles
these corner cases.

Fixes #117833
Fixes #117838

Curves draw buffer updates and operations like resampling access the evaluated lengths cache of curves. However, when the curve has only one point the evaluated lengths will be empty. This is not a problem for open curves, because they skip calculation of the last point, but cyclic curves expect to have as many length entries as there are points. This crashes in certain cases: - Grease Pencil v3 edit mode "Toggle Cyclic" operator - Geometry nodes resampling of cyclic, single-vertex curves Checking for the single-point case when building draw buffers handles these corner cases. Fixes #117833 Fixes #117838
Lukas Tönne added 1 commit 2024-02-05 13:05:11 +01:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
dd839e5d1b
Fix crashes when connecting cyclic grease pencil curves.
Curves draw buffer updates and operations like resampling access the
evaluated lengths cache of curves. However, when the curve has only one
point the evaluated lengths will be empty. This is not a problem for
open curves, because they skip calculation of the last point, but cyclic
curves expect to have as many length entries as there are points.

This crashes in certain cases:
- Grease Pencil v3 edit mode "Toggle Cyclic" operator
- Geometry nodes resampling of cyclic, single-vertex curves

Checking for the single-point case when building draw buffers handles
these corner cases.

Fixes #117833
Fixes #117838
Lukas Tönne requested review from Jacques Lucke 2024-02-05 13:05:29 +01:00
Lukas Tönne requested review from Falk David 2024-02-05 13:05:29 +01:00
Lukas Tönne added this to the Grease Pencil project 2024-02-05 13:05:36 +01:00
Author
Member

@blender-bot build

@blender-bot build
Falk David requested review from Hans Goudey 2024-02-05 13:09:29 +01:00
Falk David approved these changes 2024-02-05 13:09:44 +01:00
Falk David left a comment
Member

LGTM

LGTM
Author
Member

Just to demonstrate that this is a generic curves issue and not just GP3, here's a test with geometry nodes that also crashes:
#117838 (comment)

image

Just to demonstrate that this is a generic curves issue and not just GP3, here's a test with geometry nodes that also crashes: https://projects.blender.org/blender/blender/issues/117838#issuecomment-1115777 ![image](/attachments/1d51db1c-405f-42b5-8cd6-95bb363b2865)
Lukas Tönne added 1 commit 2024-02-05 13:42:55 +01:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
0078938749
Merge branch 'main' into fix-cyclic-curves-crash
Author
Member

@blender-bot build

@blender-bot build
Hans Goudey reviewed 2024-02-05 14:00:31 +01:00
Hans Goudey left a comment
Member

Thanks for the fix!

Thanks for the fix!
@ -1011,1 +1013,4 @@
BLI_assert(lengths_range.is_empty());
continue;
}
length_parameterize::accumulate_lengths(evaluated_positions.slice(evaluated_points),
Member

Maybe this fix should go into length_parameterize::accumulate_lengths instead. Looks like the last check could become cyclic && points.size() > 1

Maybe this fix should go into `length_parameterize::accumulate_lengths` instead. Looks like the last check could become `cyclic && points.size() > 1`
Author
Member

Yes, all the info is available in accumulate_lengths, moved the check there.

Yes, all the info is available in `accumulate_lengths`, moved the check there.
LukasTonne marked this conversation as resolved
@ -605,3 +605,3 @@
if (is_cyclic) {
const int idx = points.size() + 1;
const float length = lengths[points.size() - 1];
const float length = (points.size() > 1 ? lengths[points.size() - 1] : 0.0f);
Member

The parentheses are unnecessary

The parentheses are unnecessary
LukasTonne marked this conversation as resolved
Lukas Tönne added 2 commits 2024-02-05 14:12:35 +01:00
Lukas Tönne added 1 commit 2024-02-05 14:14:06 +01:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
3861df4373
Merge branch 'main' into fix-cyclic-curves-crash
Author
Member

@blender-bot build

@blender-bot build
Hans Goudey approved these changes 2024-02-05 14:24:42 +01:00
Lukas Tönne merged commit d7127dea02 into main 2024-02-05 14:47:15 +01:00
Lukas Tönne deleted branch fix-cyclic-curves-crash 2024-02-05 14:47:20 +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
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#117842
No description provided.