Fix #120731: sculpt trim tool crash #120733

Merged
Hans Goudey merged 2 commits from PratikPB2123/blender:120731-trim-tool-crash into main 2024-04-19 20:27:12 +02:00
Member

Caused by f7d5ec8661
initialize_cursor_info requires gesture_data.operation initialized.
So move allocation outside of init_operation

Caused by f7d5ec8661cac87553c9aa199b38d65a8052d666 `initialize_cursor_info` requires `gesture_data.operation` initialized. So move allocation outside of `init_operation`
Pratik Borhade added 1 commit 2024-04-17 10:40:10 +02:00
905dcc0ec4 Fix #120731: sculpt trim tool crash
`initialize_cursor_info` requires `gesture_data.operation` initialized.
So call this function after `init_operation`.
Pratik Borhade requested review from Hans Goudey 2024-04-17 10:40:26 +02:00
Author
Member

I can not find @Sean-Kim in reviewers list so tagging in comments ;)

I can not find @Sean-Kim in reviewers list so tagging in comments ;)
Sean Kim requested changes 2024-04-17 10:58:43 +02:00
Dismissed
Sean Kim left a comment
Member

Ugh, sorry. Don't know how I missed this crash before submitting the PR. Appreciate you taking a stab at the fix.

Made a note of what I noticed, but it's late at night here and I won't be able to check replies until tomorrow.

Ugh, sorry. Don't know how I missed this crash before submitting the PR. Appreciate you taking a stab at the fix. Made a note of what I noticed, but it's late at night here and I won't be able to check replies until tomorrow.
@ -727,3 +727,3 @@
initialize_cursor_info(*C, *op, *gesture_data);
init_operation(*gesture_data, *op);
initialize_cursor_info(*C, *op, *gesture_data);
Member

The order of initialze_cursor_info and then init_operation is actually still needed. This fix would just introduce other errors on the following line:

if (!trim_operation->initial_hit) {
    trim_operation->orientation = OrientationType::View;
}

For now, this is probably best fixed by adding something like

gesture_data->operation = reinterpret_cast<gesture::Operation *>(MEM_cnew<TrimOperation>(__func__));

above initialize_cursor_info

The order of `initialze_cursor_info` and then `init_operation` is actually still needed. This fix would just introduce other errors on the following line: ``` if (!trim_operation->initial_hit) { trim_operation->orientation = OrientationType::View; } ``` For now, this is probably best fixed by adding something like `gesture_data->operation = reinterpret_cast<gesture::Operation *>(MEM_cnew<TrimOperation>(__func__));` above `initialize_cursor_info`
Author
Member

Hi, this will cause the memory leak. I would instead call initialize_cursor_info inside init_operation after operation is initialized.

Hi, this will cause the memory leak. I would instead call `initialize_cursor_info` inside `init_operation` after operation is initialized.
Member

This allocation is already occurring in the existing code inside init_operation and is cleaned up when the unique_ptr goes out of scope by the GestureData destructor, but I agree that moving initialize_cursor_info into init_operation is also a fine way of solving this.

This allocation is already occurring in the existing code inside `init_operation` and is cleaned up when the `unique_ptr` goes out of scope by the `GestureData` destructor, but I agree that moving `initialize_cursor_info` into `init_operation` is also a fine way of solving this.
Author
Member

This allocation is already occurring in the existing code inside init_operation and is cleaned up when the unique_ptr goes out of scope by the GestureData destructor

Pointer was created in _exec function, it'll be freed once we exit the _exec function. So the earlier allocated memory in initialize_cursor_info is not freed.

BTW, I ended up moving allocation outside of init_operation 👀

> This allocation is already occurring in the existing code inside init_operation and is cleaned up when the unique_ptr goes out of scope by the GestureData destructor Pointer was created in _exec function, it'll be freed once we exit the _exec function. So the earlier allocated memory in `initialize_cursor_info` is not freed. BTW, I ended up moving allocation outside of init_operation 👀
Pratik Borhade added 1 commit 2024-04-17 11:56:01 +02:00
Sean Kim approved these changes 2024-04-17 18:34:05 +02:00
Hans Goudey approved these changes 2024-04-19 20:26:43 +02:00
Hans Goudey merged commit d7cd25fc94 into main 2024-04-19 20:27:12 +02:00
Pratik Borhade deleted branch 120731-trim-tool-crash 2024-04-20 10:34:14 +02:00
Sign in to join this conversation.
No reviewers
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#120733
No description provided.