"Code marked as unreachable has been executed. Please report this as a bug." #119263

Closed
opened 2024-03-10 00:43:53 +01:00 by Jordan-Henshaw · 14 comments

System Information
Operating system: macOS-13.6.3-x86_64-i386-64bit 64 Bits
Graphics card: Metal API Intel(R) Iris(TM) Plus Graphics 1.2

Blender Version
Broken: version: 4.0.2, branch: blender-v4.0-release, commit date: 2023-12-05 07:41, hash: 9be62e85b727

Short description of error
I have 18,000 lines of my own Python code in the blend file that has manipulated the data, especially the node tree, and I just restructured a bunch of stuff so there are plenty of my own bugs. I am only reporting this as a bug here because Blender has repeatedly asked me to via Terminal over the last few days, particularly before I even run any of my code (although my code has created many custom nodes). This is what Terminal keeps telling me as soon as I open the blend file:

"Error found at source/blender/nodes/intern/node_declaration.cc:290 in matches.
Code marked as unreachable has been executed. Please report this as a bug."

Exact steps for others to reproduce the error
This is associated with 18,000 lines of my own code, so let me know if you actually want me to upload anything and/or if I was actually supposed to report this.

**System Information** Operating system: macOS-13.6.3-x86_64-i386-64bit 64 Bits Graphics card: Metal API Intel(R) Iris(TM) Plus Graphics 1.2 **Blender Version** Broken: version: 4.0.2, branch: blender-v4.0-release, commit date: 2023-12-05 07:41, hash: `9be62e85b727` **Short description of error** I have 18,000 lines of my own Python code in the blend file that has manipulated the data, especially the node tree, and I just restructured a bunch of stuff so there are plenty of my own bugs. I am only reporting this as a bug here because Blender has repeatedly asked me to via Terminal over the last few days, particularly before I even run any of my code (although my code has created many custom nodes). This is what Terminal keeps telling me as soon as I open the blend file: "Error found at source/blender/nodes/intern/node_declaration.cc:290 in matches. Code marked as unreachable has been executed. Please report this as a bug." **Exact steps for others to reproduce the error** This is associated with 18,000 lines of my own code, so let me know if you actually want me to upload anything and/or if I was actually supposed to report this.
Jordan-Henshaw added the
Priority
Normal
Type
Report
Status
Needs Triage
labels 2024-03-10 00:43:54 +01:00
Member

This is associated with 18,000 lines of my own code, so let me know if you actually want me to upload anything and/or if I was actually supposed to report this.

To reproduce this issue, we need access to a file or the exact steps to reproduce this issue.

If you can simplify your code down to the part that causes the issue, then upload it here, that would be great. If you can't simplify it, then uploading the full file might be necessary.


Before going through the process of simplifying the file, or uploading it here for testing, are you able to test Blender 4.1 and/or 4.2 to see if your issue has already been fixed? These versions of Blender can be downloaded from here: https://builder.blender.org/download/daily/

> This is associated with 18,000 lines of my own code, so let me know if you actually want me to upload anything and/or if I was actually supposed to report this. To reproduce this issue, we need access to a file or the exact steps to reproduce this issue. If you can simplify your code down to the part that causes the issue, then upload it here, that would be great. If you can't simplify it, then uploading the full file might be necessary. --- Before going through the process of simplifying the file, or uploading it here for testing, are you able to test Blender 4.1 and/or 4.2 to see if your issue has already been fixed? These versions of Blender can be downloaded from here: https://builder.blender.org/download/daily/
Alaska added
Status
Needs Information from User
and removed
Status
Needs Triage
labels 2024-03-10 01:17:02 +01:00
Author

OK. I deleted all my junior dev code and almost everything else. It still gave the error on startup. I then tried the small file on the 4.2 alpha build and got the same request to report a bug upon opening the file. Minimum .blend file attached.

Since it's open source, I got confident and dug around a bit. It appears as though the error message originated from the below C++ chunk, which ran a macro to get help because in its mind it has received a square circle, so it feels like it needs an IQ boost.

bool NodeDeclaration::matches(const bNode &node) const
{
  const bNodeSocket *current_input = static_cast<bNodeSocket *>(node.inputs.first);
  const bNodeSocket *current_output = static_cast<bNodeSocket *>(node.outputs.first);
  const bNodePanelState *current_panel = node.panel_states_array;
  for (const ItemDeclarationPtr &item_decl : items) {
    if (const SocketDeclaration *socket_decl = dynamic_cast<const SocketDeclaration *>(
            item_decl.get()))
    {
      switch (socket_decl->in_out) {
        case SOCK_IN:
          if (current_input == nullptr || !socket_decl->matches(*current_input)) {
            return false;
          }
          current_input = current_input->next;
          break;
        case SOCK_OUT:
          if (current_output == nullptr || !socket_decl->matches(*current_output)) {
            return false;
          }
          current_output = current_output->next;
          break;
      }
    }
    else if (const PanelDeclaration *panel_decl = dynamic_cast<const PanelDeclaration *>(
                 item_decl.get()))
    {
      if (!node.panel_states().contains_ptr(current_panel) || !panel_decl->matches(*current_panel))
      {
        return false;
      }
      ++current_panel;
    }
    else {
      /* Unknown item type. */
      BLI_assert_unreachable();
    }
  }
  /* If items are left over, some were removed from the declaration. */
  if (current_input == nullptr || current_output == nullptr ||
      !node.panel_states().contains_ptr(current_panel))
  {
    return false;
  }
  return true;
}
OK. I deleted all my junior dev code and almost everything else. It still gave the error on startup. I then tried the small file on the 4.2 alpha build and got the same request to report a bug upon opening the file. Minimum .blend file attached. Since it's open source, I got confident and dug around a bit. It appears as though the error message originated from the below C++ chunk, which ran a macro to get help because in its mind it has received a square circle, so it feels like it needs an IQ boost. ```Cpp bool NodeDeclaration::matches(const bNode &node) const { const bNodeSocket *current_input = static_cast<bNodeSocket *>(node.inputs.first); const bNodeSocket *current_output = static_cast<bNodeSocket *>(node.outputs.first); const bNodePanelState *current_panel = node.panel_states_array; for (const ItemDeclarationPtr &item_decl : items) { if (const SocketDeclaration *socket_decl = dynamic_cast<const SocketDeclaration *>( item_decl.get())) { switch (socket_decl->in_out) { case SOCK_IN: if (current_input == nullptr || !socket_decl->matches(*current_input)) { return false; } current_input = current_input->next; break; case SOCK_OUT: if (current_output == nullptr || !socket_decl->matches(*current_output)) { return false; } current_output = current_output->next; break; } } else if (const PanelDeclaration *panel_decl = dynamic_cast<const PanelDeclaration *>( item_decl.get())) { if (!node.panel_states().contains_ptr(current_panel) || !panel_decl->matches(*current_panel)) { return false; } ++current_panel; } else { /* Unknown item type. */ BLI_assert_unreachable(); } } /* If items are left over, some were removed from the declaration. */ if (current_input == nullptr || current_output == nullptr || !node.panel_states().contains_ptr(current_panel)) { return false; } return true; } ```
Member

@Jordan-Henshaw What are the steps to reproduce the issue with the provided file For Blender Devs.blend?

I opened the file in Blender 4.0.2 and didn't get any errors, and I didn't see any Python scripts in the file to run (You claim this issue is related to some python code you wrote).

@Jordan-Henshaw What are the steps to reproduce the issue with the provided file `For Blender Devs.blend`? I opened the file in Blender 4.0.2 and didn't get any errors, and I didn't see any Python scripts in the file to run (You claim this issue is related to some python code you wrote).
Author

@Alaska You started Blender from command line? I know that .blend prints the error to MacOS's Terminal with a virgin 4.2 dmg build downloaded an hour ago.

The error has never happened after I ran my code in-session, only immediately upon startup.

@Alaska You started Blender from command line? I know that .blend prints the error to MacOS's Terminal with a virgin 4.2 dmg build downloaded an hour ago. The error has never happened after I ran my code in-session, only immediately upon startup.
Member

You started Blender from command line?

Running from the command line, I can reproduce this issue. Sorry, I forgot how these error messages were reported to the user.

When I open this file in a debug build of Blender, the issue seems to occur because item_decl = NULL inside the for loop in NodeDeclaration::matches().


Sorry for the questions. What are the steps to reproduce create this file? Presumably you created a new file, did something (ran your python script?), then saved your file and the file you saved is the one you uploaded here.

Can you share the steps you did, and if you used your python script, can you provide a simplified version if possible? (Looking at the file, it seems like you created four node groups, with many of the nodes in the groups having invalid socket types. There are highly likely to be the cause for this issue, we only need the steps to reproduce one of these broken nodes.)

> You started Blender from command line? Running from the command line, I can reproduce this issue. Sorry, I forgot how these error messages were reported to the user. When I open this file in a debug build of Blender, the issue seems to occur because `item_decl = NULL` inside the for loop in `NodeDeclaration::matches()`. --- Sorry for the questions. What are the steps to reproduce create this file? Presumably you created a new file, did something (ran your python script?), then saved your file and the file you saved is the one you uploaded here. Can you share the steps you did, and if you used your python script, can you provide a simplified version if possible? (Looking at the file, it seems like you created four node groups, with many of the nodes in the groups having invalid socket types. There are highly likely to be the cause for this issue, we only need the steps to reproduce one of these broken nodes.)
Author

OK, I am attaching one of my scripts, which defines some nodes, but not all. However, I'm 70% sure that this message first popped up when I was trying to figure out how to create updaters, min/max, sliders, and all that kind of stuff on node sockets. That created a lot of problems, it wasn't being agreeable, so I ditched that effort and went back to what I was doing before. That is, registering normal properties onto the node, as seen in the attached script towards the bottom.

So there were many "normal" errors when I was trying to get the custom sockets to do anything at all. By "normal" errors, I mean error messages that do not tell me to report a bug to Blender. Sometime throughout that process I got the message telling me to report bug to Blender. All that code is gone now, but this is an example of type of stuff I was auditioning at the time the funky error popped up:

def intensity_updater(self, node, update_value):
    print("updating")


class GroupDriverNode(bpy.types.Node):
    def init(self, context):
        self.inputs.new('NodeSocketFloat', "Intensity").default_value = 0

    def update(self):
        intensity_socket = self.inputs.get("Intensity")
        if intensity_socket:
            intensity_value = intensity_socket.default_value
            intensity_updater(self, intensity_value)


**And also trying to set min/max:**

    def init(self, context):
        self.inputs.new('NodeSocketFloat', "Intensity").default_value = 0
        self.inputs['Intensity'].min_value = 0
        self.inputs['Intensity'].max_value = 100

All that stuff was throwing wonky errors left and right with no progress so I scrapped it. There were some inconclusive forum posts about it. It just didn't seem like the API was built out for that type of customizability, so I'm back to using label-only sockets as pointers. Initial goal was to make better use of the super cool node group functionality, but I've now gotten that working with label-only sockets. This a while ago because it was obviously because I was doing stuff wrong on my end, so I ignored it for a while.

If you're curious, the type of addon is a technical theatre use-case. It basically turns as much of Blender's toolkit into light design and 3D audio tools for live production. It has its tentacles in VSE, Properties, Node Editor, and 3D view so far, so plenty of potential for improper context problems :)

OK, I am attaching one of my scripts, which defines some nodes, but not all. However, I'm 70% sure that this message first popped up when I was trying to figure out how to create updaters, min/max, sliders, and all that kind of stuff on node sockets. That created a lot of problems, it wasn't being agreeable, so I ditched that effort and went back to what I was doing before. That is, registering normal properties onto the node, as seen in the attached script towards the bottom. So there were many "normal" errors when I was trying to get the custom sockets to do anything at all. By "normal" errors, I mean error messages that do not tell me to report a bug to Blender. Sometime throughout that process I got the message telling me to report bug to Blender. All that code is gone now, but this is an example of type of stuff I was auditioning at the time the funky error popped up: ```Py def intensity_updater(self, node, update_value): print("updating") class GroupDriverNode(bpy.types.Node): def init(self, context): self.inputs.new('NodeSocketFloat', "Intensity").default_value = 0 def update(self): intensity_socket = self.inputs.get("Intensity") if intensity_socket: intensity_value = intensity_socket.default_value intensity_updater(self, intensity_value) **And also trying to set min/max:** def init(self, context): self.inputs.new('NodeSocketFloat', "Intensity").default_value = 0 self.inputs['Intensity'].min_value = 0 self.inputs['Intensity'].max_value = 100 ``` All that stuff was throwing wonky errors left and right with no progress so I scrapped it. There were some inconclusive forum posts about it. It just didn't seem like the API was built out for that type of customizability, so I'm back to using label-only sockets as pointers. Initial goal was to make better use of the super cool node group functionality, but I've now gotten that working with label-only sockets. This a while ago because it was obviously because I was doing stuff wrong on my end, so I ignored it for a while. If you're curious, the type of addon is a technical theatre use-case. It basically turns as much of Blender's toolkit into light design and 3D audio tools for live production. It has its tentacles in VSE, Properties, Node Editor, and 3D view so far, so plenty of potential for improper context problems :)
Member

To be perfectly honest, I'm a bit lost here as my knowledge in this area is quite limited. I will mark this report as Needs Triaging in hope that someone with more knowledge than me can help in tracking this issue down.

Just a recap for anyone else who comes to check this out:

  1. Opening For developers.blend in Blender will trigger this issue. The issue can be observed by running Blender from the command line, in which case the error will be reported to the command line interface. Or by running a debug build, in which the debug build will stop with an assert.
  2. I don't know how to recreate this file from scratch. @Jordan-Henshaw has provided a python script, but I'm not sure how to simplify it due to limited knowledge in this area. I tried opening the script in Blender, running it, then trying to add one of the problematic nodes, but I couldn't quite figure it out. @Jordan-Henshaw might be able to share better instructions on how to recreate the file from scratch.
To be perfectly honest, I'm a bit lost here as my knowledge in this area is quite limited. I will mark this report as `Needs Triaging` in hope that someone with more knowledge than me can help in tracking this issue down. Just a recap for anyone else who comes to check this out: 1. Opening ![For developers.blend](/attachments/1e946f61-4793-4460-9a58-f38b15a3d367) in Blender will trigger this issue. The issue can be observed by running Blender from the command line, in which case the error will be reported to the command line interface. Or by running a debug build, in which the debug build will stop with an assert. 2. I don't know how to recreate this file from scratch. @Jordan-Henshaw has provided a python script, but I'm not sure how to simplify it due to limited knowledge in this area. I tried opening the script in Blender, running it, then trying to add one of the problematic nodes, but I couldn't quite figure it out. @Jordan-Henshaw might be able to share better instructions on how to recreate the file from scratch.
Alaska added
Status
Needs Triage
and removed
Status
Needs Information from User
labels 2024-03-11 04:46:20 +01:00

@Jordan-Henshaw Hi, i can reproduce bug. But if i run your script from new file, there is nothing. Can you describe, that to do after running the script? And yeah, 18k lines script is not the best way to report a bug. I can see that somewhere socket creation are wrong, but this still tricki to decide where.

@Jordan-Henshaw Hi, i can reproduce bug. But if i run your script from new file, there is nothing. Can you describe, that to do after *running* the script? And yeah, 18k lines script is not the best way to report a bug. I can see that somewhere socket creation are wrong, but this still tricki to decide where.
Author

Running the script will not reproduce it. The C++ code that seemingly called the BLI_assert_unreachable() macro seems to be code that runs specifically on startup of Blender. It seems to loop through the node data in the blend file expecting to know what everything is under all circumstances. It found stuff it didn't understand and so it told me to get help because it thinks it's losing its mind. My code generated the node data inside the .blend that confused the C++ code, but my improper Python code has long since been deleted because it didn't work. But stuff that incorrect Python code created is still in the .blend. That's why opening a new .blend and running my script would not reproduce the "unreachable" error. That's why deleting the node groups in the tiny blend makes the error go away.

It seems like someone wrote that else into the C++ to have someone look at the data in the blend file that prompted it to see if the startup logic needs to be smarter or not. So the question here seems to be, does the startup logic need to be smarter? For example, perhaps there would be an additional "else if" that handles cases where improper scripting leads to abnormal .blend file data, and handles it without explicitly instructing the user to report a bug to Blender. I believe that is the question here.

Running the script will not reproduce it. The C++ code that seemingly called the BLI_assert_unreachable() macro seems to be code that runs specifically on startup of Blender. It seems to loop through the node data in the blend file expecting to know what everything is under all circumstances. It found stuff it didn't understand and so it told me to get help because it thinks it's losing its mind. My code generated the node data inside the .blend that confused the C++ code, but my improper Python code has long since been deleted because it didn't work. But stuff that incorrect Python code created is still in the .blend. That's why opening a new .blend and running my script would not reproduce the "unreachable" error. That's why deleting the node groups in the tiny blend makes the error go away. It seems like someone wrote that else into the C++ to have someone look at the data in the blend file that prompted it to see if the startup logic needs to be smarter or not. So the question here seems to be, does the startup logic need to be smarter? For example, perhaps there would be an additional "else if" that handles cases where improper scripting leads to abnormal .blend file data, and handles it **without** explicitly instructing the user to report a bug to Blender. I believe that is the question here.

Your file have nullptr socket. If you think you want to send report about this (what the message in the console asked for), we'll be happy to know which part of the python api is not working correctly and allows you to do this in list of the steps. If these steps are missing, then for us it’s just another broken file and I’ll close this report.

Your file have nullptr socket. If you think you want to send report about this (what the message in the console asked for), we'll be happy to know which part of the python api is not working correctly and allows you to do this in list of the steps. If these steps are missing, then for us it’s just another broken file and I’ll close this report.
Author

Python API is working as designed, I reported this because it repeatedly and explicitly asked me to, the reporting burden is the only burden to me, it is definitely a broken file, and tat is why I waited so long to report it. I only reported because it kept explicitly asking me to. If you close this out, that means more time spent focusing on more important things for everyone. Again, I only reported because of the "Please report this as a bug" I was receiving day in, day out. I have vague idea of what the intention of the "BLI_assert_unreachable" macro was, but I don't know if the macro should have actually run in this case since I don't know the exact intention behind adding it (whether or not the developer who added that wanted me to report a bug in this specific case per potential for domino effect).

EDIT: It's not a bug, it's a potential pre-bug.

Python API is working as designed, I reported this because it repeatedly and explicitly asked me to, the reporting burden is the only burden to me, it is definitely a broken file, and tat is why I waited so long to report it. I only reported because it kept explicitly asking me to. If you close this out, that means more time spent focusing on more important things for everyone. Again, I only reported because of the "Please report this as a bug" I was receiving day in, day out. I have vague idea of what the intention of the "BLI_assert_unreachable" macro was, but I don't know if the macro should have actually run in this case since I don't know the exact intention behind adding it (whether or not the developer who added that wanted me to report a bug in this specific case per potential for domino effect). EDIT: It's not a bug, it's a potential pre-bug.
Author

Your file have nullptr socket.

Should the C++ be asking user to report a bug to Blender if that is the case? The only context where a user would even see that message is in a custom scripting context, because why else would you be running Blender from command line and checking print outputs?

> Your file have nullptr socket. Should the C++ be asking user to report a bug to Blender if that is the case? The only context where a user would even see that message is in a custom scripting context, because why else would you be running Blender from command line and checking print outputs?

You didn't get a crash only due to the luck, your script provocate undefined behavior. This is the point of terminal message.

You didn't get a crash only due to the luck, your script provocate undefined behavior. This is the point of terminal message.
Author

OK, so that's there to help diagnose crashing. I'm just going to go ahead and click the Comment and Close button since I don't see this going in a direction providing value to anyone or Blender.

OK, so that's there to help diagnose crashing. I'm just going to go ahead and click the Comment and Close button since I don't see this going in a direction providing value to anyone or Blender.
Blender Bot added
Status
Archived
and removed
Status
Needs Information from User
labels 2024-03-11 21:17: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#119263
No description provided.