WIP: Fix #103824: CompositorNodeOutputFile inputs.new() crash #118807

Draft
Philipp Oeser wants to merge 1 commits from lichtwerk/blender:103824 into blender-v4.1-release

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

Even though this has a more dedicated API in file_slots.new() this
shouldnt crash.

The crash is due to NodeImageMultiFileSocket not being initialized
properly, ntreeBlendWrite then crashes accessing garbage data.

Note this is more of a bandaid, the proper way forward would be some
sort of dynamic declration such as
blender::nodes::node_group_declare_dynamic as outlined in #108728, but
since this is a more involved change, this PR just fixes the crash with
what we have atm. (using ntreeCompositOutputFileAddSocket which takes
care of NodeImageMultiFileSocket data for us).

Even though this has a more dedicated API in `file_slots.new()` this shouldnt crash. The crash is due to `NodeImageMultiFileSocket` not being initialized properly, `ntreeBlendWrite` then crashes accessing garbage data. Note this is more of a bandaid, the proper way forward would be some sort of dynamic declration such as `blender::nodes::node_group_declare_dynamic` as outlined in #108728, but since this is a more involved change, this PR just fixes the crash with what we have atm. (using `ntreeCompositOutputFileAddSocket` which takes care of `NodeImageMultiFileSocket` data for us).
Philipp Oeser added 1 commit 2024-02-27 15:57:09 +01:00
dbe557e8cb Fix #103824: CompositorNodeOutputFile inputs.new() crash
Even though this has a more dedicated API in `file_slots.new()` this
shouldnt crash.

The crash is due to `NodeImageMultiFileSocket` not being initialized
properly, `ntreeBlendWrite` then crashes accessing garbage data.

Note this is more of a bandaid, the proper way forward would be some
sort of dynamic declration such as
`blender::nodes::node_group_declare_dynamic` as outlined in #108728, but
since this is a more involved change, this PR just fixes the crash with
what we have atm. (using `ntreeCompositOutputFileAddSocket` which takes
care of `NodeImageMultiFileSocket` data for us).
Philipp Oeser added this to the Nodes & Physics project 2024-02-27 15:57:23 +01:00
Philipp Oeser requested review from Hans Goudey 2024-02-27 15:57:33 +01:00
Raul Fernandez Hernandez approved these changes 2024-02-27 21:54:30 +01:00
Member

With a follow up PR it looks good to me.

With a follow up PR it looks good to me.
Member

What about changing allow_changing_sockets? That would be an API change technically, but if it's just not working to change the sockets directly, maybe it's better that people just use the dedicated API. Otherwise delaying that to 4.2 and following up with a change to use dynamic declarations would be fine.

What about changing `allow_changing_sockets`? That would be an API change technically, but if it's just not working to change the sockets directly, maybe it's better that people just use the dedicated API. Otherwise delaying that to 4.2 and following up with a change to use dynamic declarations would be fine.
Author
Member

What about changing allow_changing_sockets? That would be an API change technically, but if it's just not working to change the sockets directly, maybe it's better that people just use the dedicated API

Possible of course (and I have advised reporters to use the dedicated API), but not sure breaking the API just for a release or two is worth it (if we can make the general API work as well)?

Otherwise delaying that to 4.2 and following up with a change to use dynamic declarations would be fine.

Not sure I understand correctly, you mean delaying this fix to 4.2? Why?

If the way this PR does the fix is a no-go, I would vote for the allow_changing_sockets solution, but still do it for 4.1 (unless having an API change like this is a no-go in bcon3?)

> What about changing `allow_changing_sockets`? That would be an API change technically, but if it's just not working to change the sockets directly, maybe it's better that people just use the dedicated API Possible of course (and I have advised reporters to use the dedicated API), but not sure breaking the API just for a release or two is worth it (if we can make the general API work as well)? >Otherwise delaying that to 4.2 and following up with a change to use dynamic declarations would be fine. Not sure I understand correctly, you mean delaying this fix to 4.2? Why? If the way this PR does the fix is a no-go, I would vote for the `allow_changing_sockets` solution, but still do it for 4.1 (unless having an API change like this is a no-go in bcon3?)
Hans Goudey requested review from Jacques Lucke 2024-02-28 17:24:22 +01:00
Member

I think c0f33814c1 might have been the wrong fix for #102611. The bug report specifically asks for file_output_node.file_slots.remove and not to remove sockets directly. However, the fix allowed that.

I think the fix here is to remove CMP_NODE_OUTPUT_FILE from allow_changing_sockets and to use more specific rna functions in rna_def_cmp_output_file_slots_api. See for example how rna_Node_socket_remove is reused.

I think c0f33814c13c38aa49b909ba2a8946798d14d078 might have been the wrong fix for #102611. The bug report specifically asks for `file_output_node.file_slots.remove` and not to remove sockets directly. However, the fix allowed that. I think the fix here is to remove `CMP_NODE_OUTPUT_FILE` from `allow_changing_sockets` and to use more specific rna functions in `rna_def_cmp_output_file_slots_api`. See for example how `rna_Node_socket_remove` is reused.
Author
Member

I think c0f33814c1 might have been the wrong fix for #102611. The bug report specifically asks for file_output_node.file_slots.remove and not to remove sockets directly. However, the fix allowed that.

I think the fix here is to remove CMP_NODE_OUTPUT_FILE from allow_changing_sockets and to use more specific rna functions in rna_def_cmp_output_file_slots_api. See for example how rna_Node_socket_remove is reused.

OK, will take that route.
@3di : that would work for you as well, right?

> I think c0f33814c13c38aa49b909ba2a8946798d14d078 might have been the wrong fix for #102611. The bug report specifically asks for `file_output_node.file_slots.remove` and not to remove sockets directly. However, the fix allowed that. > > I think the fix here is to remove `CMP_NODE_OUTPUT_FILE` from `allow_changing_sockets` and to use more specific rna functions in `rna_def_cmp_output_file_slots_api`. See for example how `rna_Node_socket_remove` is reused. OK, will take that route. @3di : that would work for you as well, right?
Philipp Oeser changed title from Fix #103824: CompositorNodeOutputFile inputs.new() crash to WIP: Fix #103824: CompositorNodeOutputFile inputs.new() crash 2024-02-29 09:43:34 +01:00
First-time contributor

@lichtwerk as long as the below code continues remove the actual socket I'm happy (or if there's an alternative way) 👍

import bpy
scene = bpy.context.scene
file_output_node =scene.node_tree.nodes.new("CompositorNodeOutputFile")
file_output_node.file_slots.remove(file_output_node.inputs[0])
@lichtwerk as long as the below code continues remove the actual socket I'm happy (or if there's an alternative way) 👍 ``` import bpy scene = bpy.context.scene file_output_node =scene.node_tree.nodes.new("CompositorNodeOutputFile") file_output_node.file_slots.remove(file_output_node.inputs[0]) ```
This pull request is marked as a work in progress.
This branch is out-of-date with the base branch

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 103824:lichtwerk-103824
git checkout lichtwerk-103824
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 Assignees
5 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#118807
No description provided.