Heap buffer overflow when removing keymap entries on add-on unregister #86431
Labels
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
5 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#86431
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
System Information
Operating system: Linux-5.4.0-66-generic-x86_64-with-glibc2.31 64 Bits
Graphics card: GeForce RTX 2080/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 450.102.04
Blender Version
Broken: version: 2.93.0 Alpha, branch: master, commit date: 2021-03-09 12:55, hash:
7f9b6b1dc9
Worked: the commit before
9e09214979
Short description of error
When closing Blender, ASAN complains about a heap-buffer-overflow. This happens in the
addon_utils.disable_all()
call fromWM_exit_ex()
.9e09214979
adds a check that pointers to temporary datablocks are not assigned to anything:value_owner_id->tag & LIB_TAG_TEMP_MAIN
. Unfortunately, in the above case (Blender shutting down, addons being unregistered),value_owner_id
is no longer valid.This issue was introduced in
9e09214979
. However, I suspect that the underlying issue was already present before, and just comes to light now because of that commit.Exact steps for others to reproduce the error
This patch makes it more visible what is exactly being accessed:
On my machine it outputs:
Added subscriber: @dr.sybren
Added subscriber: @ideasman42
Added subscriber: @rjg
Notes
PointerRNA.owner_id
of window manager become invalid when loading a new file.Firstly, the invalid ID pointer has been happening for years, surprising the error only shows up now.
It seems the API functions for keymaps don't use this and access
G.main.wm.first
instead, so we didn't run into this problem before.Unfortunately as far as I can see all solutions have some significant trade-offs.
Remove this check (temporary ID's can then be assigned when this shouldn't be allowed).
The invalid ID problem will likely bite us later on, it's OK short term.
Keep the window-manager at the same memory location on file load P2027
This means any pointers to the window-manager in the file will become invalid, although by default AFAICS, there are no pointers that do this, besides ID-properties which may reference the window-manager ID.
Perform a hack that reassigns window-manager ID pointers on file load, using
gc.get_objects()
for example, could be slow - mentioning for completeness. I'd need to check this would work reliably too, it does detect the keymap items from this report.Change the API usage not to store the keymap items, instead use strings for example - that can be used to lookup the keymap items for removal
(Also not nice as this is the documented way to add/remove keymap items, mentioning for completeness).
This idea may actually be preferable because it could also prevent bugs like #83099 from happening.
Added subscriber: @mont29
Think the swap option is the best here, though it needs to be refined compared to the proposed P2027:
Main.relations
in either Main's..@mont29 submitted D10690: Fix #86431: Keep the memory location of the window manager when loading a file which does the remap, although I'm a skeptical about how useful it is to reference windowing-data from ID properties in general.
This issue was referenced by
2cc5af9c55
Changed status from 'Needs Triage' to: 'Resolved'