Regression: Crash when loading project using custom material nodes #106467

Closed
opened 2023-04-02 21:05:15 +02:00 by Max Schlecht · 10 comments
Contributor

System Information
Operating system: Windows 10
Graphics card: 980Ti

Blender Version
Broken: version: 3.6.0 Alpha, branch: main, commit date: 2023-03-01 23:48, hash: 6b8cdd597996
Worked: version: 3.6.0 Alpha, branch: main, commit date: 2023-02-26 23:09, hash: ca2c0da79eeb

Short description of error
I have a python addon which uses custom material nodes, based on group nodes.
This works by inheriting from ShaderNodeCustomGroup, registering the new node class and adding new node categories to the material node menus.

I don't think this behavior is entirely intended, but it's very useful and I've seen it used by some other addons aswell.

The problem is, that saving a file containing such custom material nodes and loading it using Blender 3.5 will simply crash Blender under certain conditions:

  1. the addon is active (if it's not, it'll load fine, but the nodes won't work)
  2. the custom node uses one of the new NodeSocket types (any of the new NodeSocketFloat variants or the new NodeSocketVector variants)
    It doesn't crash if the node is only using "the old" NodeSocket types, so this is somehow related to the new socket types being added and could also lead to issues in other scenarios.

Exact steps for others to reproduce the error

  1. Install the attached min_customnodes_addon addon and enable it.
  2. Create a cube and add a material to it
  3. Add the new "TestNode" node from the "Test" category.
  4. Save the file
  5. Restart Blender
  6. Load the file

If anyone has an idea what could cause this, I'd be happy to dig into this further, but because Blender just straight up crashes, I don't really have any good starting point. Thanks!

**System Information** Operating system: Windows 10 Graphics card: 980Ti **Blender Version** Broken: version: 3.6.0 Alpha, branch: main, commit date: 2023-03-01 23:48, hash: `6b8cdd597996` Worked: version: 3.6.0 Alpha, branch: main, commit date: 2023-02-26 23:09, hash: `ca2c0da79eeb` **Short description of error** I have a python addon which uses custom material nodes, based on group nodes. This works by inheriting from `ShaderNodeCustomGroup`, registering the new node class and adding new node categories to the material node menus. I don't think this behavior is entirely intended, but it's very useful and I've seen it used by some other addons aswell. The problem is, that saving a file containing such custom material nodes and loading it using Blender 3.5 will simply crash Blender under certain conditions: 1. the addon is active (if it's not, it'll load fine, but the nodes won't work) 2. **the custom node uses one of the new NodeSocket types (any of the new NodeSocketFloat variants or the new NodeSocketVector variants)** It doesn't crash if the node is only using "the old" `NodeSocket` types, so this is somehow related to the new socket types being added and **could also lead to issues in other scenarios**. **Exact steps for others to reproduce the error** 1. Install the attached `min_customnodes_addon` addon and enable it. 2. Create a cube and add a material to it 3. Add the new "TestNode" node from the "Test" category. 4. Save the file 5. Restart Blender 6. Load the file If anyone has an idea what could cause this, I'd be happy to dig into this further, but because Blender just straight up crashes, I don't really have any good starting point. Thanks!
Max Schlecht added the
Priority
Normal
Status
Needs Triage
Type
Report
labels 2023-04-02 21:05:15 +02:00
Iliya Katushenock added the
Interest
Nodes & Physics
Interest
Python API
labels 2023-04-02 21:06:14 +02:00
Author
Contributor

(This might or might not contain useful information, not sure.)

(This might or might not contain useful information, not sure.)
Author
Contributor

Oh also: This only happens with NodeSocketFloat... and NodeSocketVector.... Other new socket types like NodeSocketVirtual, NodeSocketImage etc. seem to work fine (didn't test all of them).
So I'm guessing this does have something to do with all the Float and Vector subtypes.

Oh also: This only happens with `NodeSocketFloat...` and `NodeSocketVector...`. Other new socket types like `NodeSocketVirtual`, `NodeSocketImage` etc. seem to work fine (didn't test all of them). So I'm guessing this does have something to do with all the Float and Vector subtypes.

I'll check

I'll check
Author
Contributor

Thanks! I'll try to find the exact version where this got broken. I just tested the earliest alpha build I could find and it worked fine there.

Thanks! I'll try to find the exact version where this got broken. I just tested the earliest alpha build I could find and it worked fine there.

When updating the node declaration, the socket have a null pointer to the socket type. Not sure who and when should initialize and find the right type instance...

When updating the node declaration, the socket have a null pointer to the socket type. Not sure who and when should initialize and find the right type instance...
Author
Contributor

I think I found it!
In D17183 @JacquesLucke fixed this crash for normal group nodes here like this:

/* Don't update node groups here because they may depend on other node groups which are not
* fully versioned yet and don't have `typeinfo` pointers set. */
if (node->type != NODE_GROUP) {
  node_verify_sockets(ntree, node, false);
}

This only affects normal node groups though. The "custom" material nodes I create are of type NODE_CUSTOM_GROUP though, so the crash still happens for them.

Updating the code like this, should fix this.

/* Don't update node groups here because they may depend on other node groups which are not
* fully versioned yet and don't have `typeinfo` pointers set. */
if (node->type != NODE_GROUP && node->type != NODE_CUSTOM_GROUP) {
  node_verify_sockets(ntree, node, false);
}
I think I found it! In [D17183](https://archive.blender.org/developer/D17183) @JacquesLucke fixed this crash for normal group nodes [here](https://projects.blender.org/blender/blender/src/commit/e7f395dd206dcd46ff9d8e89682b33cd9e95abe7/source/blender/blenkernel/intern/node.cc#L926) like this: ```c /* Don't update node groups here because they may depend on other node groups which are not * fully versioned yet and don't have `typeinfo` pointers set. */ if (node->type != NODE_GROUP) { node_verify_sockets(ntree, node, false); } ``` This only affects normal node groups though. The "custom" material nodes I create are of type `NODE_CUSTOM_GROUP` though, so the crash still happens for them. Updating the code like this, should fix this. ```c /* Don't update node groups here because they may depend on other node groups which are not * fully versioned yet and don't have `typeinfo` pointers set. */ if (node->type != NODE_GROUP && node->type != NODE_CUSTOM_GROUP) { node_verify_sockets(ntree, node, false); } ```

Not totally sure but look wrong, the problem here is with sockets, not groups.

Not totally sure but look wrong, the problem here is with sockets, not groups.
Iliya Katushenock changed title from Crash when loading project using custom material nodes to Regression: Crash when loading project using custom material nodes 2023-04-03 19:24:12 +02:00
Iliya Katushenock added
Priority
High
and removed
Priority
Normal
labels 2023-04-03 19:24:17 +02:00
Author
Contributor

Not totally sure but look wrong, the problem here is with sockets, not groups.

Yes, but no. The crash seems to happen because of uninitialized node socket types, but this is somehow only a problem with node groups.
I'm 95% this is the issue.
In T104296 they were also talking about node sockets being NULL.

> Not totally sure but look wrong, the problem here is with sockets, not groups. Yes, but no. The crash seems to happen because of uninitialized node socket types, but this is somehow only a problem with node groups. I'm 95% this is the issue. In [T104296](https://archive.blender.org/developer/maniphest/0104/0104296/index.html#1482913) they were also talking about node sockets being NULL.

I'll try to make a more accurate bisect today, I don't see any potential culprits

I'll try to make a more accurate bisect today, I don't see any potential culprits
Author
Contributor

100% sure now, just did a build with the fix applied and it works. Making a PR.

100% sure now, just did a build with the fix applied and it works. Making a PR.
Blender Bot added
Status
Resolved
and removed
Status
Confirmed
labels 2023-04-05 15:36:37 +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
2 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#106467
No description provided.