Fix #108254: Infinite loop in rna_info.BuildRNAInfo when a registered class has a non-registered superclass #108256

Manually merged
Campbell Barton merged 1 commits from Mysteryem/blender:rna_info_infinite_loop_pr into main 2024-07-02 08:12:50 +02:00
Member

The while loop in rna_info.get_py_class_from_rna was not mutating the
variables within the loop nor the variable in its condition, meaning it
would loop infinitely if the loop didn't exit in its first iteration.

When yielding registered classes in subclasses_recurse, the function
was erroneously checking if the class' superclass was registered rather
than checking the class itself, causing registered classes to be skipped
if their superclass was not also registered. If the class to be found
was skipped, the while loop would not exit in its first iteration and
would thus loop infinitely.

The while loop has been modified to iterate through each base rna type
until there is no further base type.

The subclasses_recurse function now correctly checks whether the
subclass is registered, not its superclass, when determining if the
subclass should be yielded.

The while loop in `rna_info.get_py_class_from_rna` was not mutating the variables within the loop nor the variable in its condition, meaning it would loop infinitely if the loop didn't exit in its first iteration. When yielding registered classes in `subclasses_recurse`, the function was erroneously checking if the class' superclass was registered rather than checking the class itself, causing registered classes to be skipped if their superclass was not also registered. If the class to be found was skipped, the while loop would not exit in its first iteration and would thus loop infinitely. The while loop has been modified to iterate through each base rna type until there is no further base type. The `subclasses_recurse` function now correctly checks whether the subclass is registered, not its superclass, when determining if the subclass should be yielded.
Thomas Barlow added 1 commit 2023-05-25 06:24:10 +02:00
The while loop in `rna_info.get_py_class_from_rna` was not mutating the
variables within the loop nor the variable in its condition, meaning it
would loop infinitely if the loop didn't exit in its first iteration.

When yielding registered classes in `subclasses_recurse`, the function
was erroneously checking if the class' superclass was registered rather
than checking the class itself, causing registered classes to be skipped
if their superclass was not also registered. If the class to be found
was skipped, the while loop would not exit in its first iteration and
would thus loop infinitely.

The while loop has been modified to iterate through each base rna type
until there is no further base type.

The `subclasses_recurse` function now correctly checks whether the
subclass is registered, not its superclass, when determining if the
subclass should be yielded.
Iliya Katushenock added this to the Core project 2023-05-25 07:53:29 +02:00
Iliya Katushenock added the
Interest
Python API
label 2023-05-25 07:53:33 +02:00
Bastien Montagne added
Module
Python API
Interest
Core
and removed
Interest
Python API
labels 2024-07-01 17:57:58 +02:00
Bastien Montagne requested review from Campbell Barton 2024-07-01 17:58:05 +02:00
Bastien Montagne removed this from the Core project 2024-07-01 17:58:15 +02:00
Bastien Montagne reviewed 2024-07-01 18:01:21 +02:00
Bastien Montagne left a comment
Owner

Changes look sensible to me...

@Mysteryem do you have a practical example of how to reproduce the issue?

(And many excuses for lack of review of this PR so far)

Changes look sensible to me... @Mysteryem do you have a practical example of how to reproduce the issue? (And many excuses for lack of review of this PR so far)
Bastien Montagne requested review from Bastien Montagne 2024-07-01 18:01:36 +02:00

Ah sorry, did not see the linked report with reproducible case.

Ah sorry, did not see the linked report with reproducible case.
Bastien Montagne force-pushed rna_info_infinite_loop_pr from ba01a3ac64 to b6bf2f9b9d 2024-07-01 18:22:00 +02:00 Compare

NOTE; Forced-pushed a version of the PR rebased onto current 4.2 branch. But no way to get gitea to actually rebase the PR on 4.2, getting timeout errors all the time :(

NOTE; Forced-pushed a version of the PR rebased onto current 4.2 branch. But no way to get gitea to actually rebase the PR on 4.2, getting timeout errors all the time :(
Bastien Montagne approved these changes 2024-07-01 18:26:36 +02:00
Bastien Montagne left a comment
Owner

LGTM

LGTM
Campbell Barton approved these changes 2024-07-02 08:06:53 +02:00

Double checked Python API docs remain unchanged, LGTM too.

Double checked Python API docs remain unchanged, LGTM too.
Campbell Barton manually merged commit d1cff7974a into main 2024-07-02 08:12:50 +02:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
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
Asset Browser Project
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#108256
No description provided.