Refactor: Blend file reading asserts for broken pointers #120997

Open
Brecht Van Lommel wants to merge 1 commits from brecht/blender:refactor-assert-broken-pointer into main

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

Previously these were silently ignored. In general they should not happen,
but due to versioning and bugs some blend files do have broken pointers.

The known cases are explicitly marked as such now, and the assert is skipped.
Those cases must correctly handle the pointer being null.

Future Blender versions are likely to write more invalid pointers, which
would then trigger these asserts in older versions. I guess as long as
it is only an assert this is ok, but could be annoying in some cases.
Though with these asserts they are more likely to be caught and fixed.

Previously these were silently ignored. In general they should not happen, but due to versioning and bugs some blend files do have broken pointers. The known cases are explicitly marked as such now, and the assert is skipped. Those cases must correctly handle the pointer being null. Future Blender versions are likely to write more invalid pointers, which would then trigger these asserts in older versions. I guess as long as it is only an assert this is ok, but could be annoying in some cases. Though with these asserts they are more likely to be caught and fixed.
Brecht Van Lommel added 2 commits 2024-04-23 21:30:23 +02:00
9262110ce6 Refactor: Use typed functions for blend file data reading
This makes the read and write API functions match more closely, and adds
asserts to check that the data size is as expected.

There are still a few places remaining that use BLO_read_data_address
and similar, these should eventually be replaced as well.
59ca145ef9 Refactor: Blend file reading asserts for broken pointers
Previously these were silently ignored. In general they should not happen,
but due to versioning and bugs some blend files do have broken pointers.

The known cases are explicitly marked as such now, and the assert is skipped.
Those cases must correctly handle the pointer being null.

Future Blender versions are likely to write more invalid pointers, which
would then trigger these asserts in older versions. I guess as long as
it is only an assert this is ok, but could be annoying in some cases.
Though with these asserts they are more likely to be caught and fixed.
Brecht Van Lommel force-pushed refactor-assert-broken-pointer from 59ca145ef9 to 1cf8a76b9a 2024-04-24 17:07:57 +02:00 Compare
Author
Owner

@blender-bot build

@blender-bot build
Brecht Van Lommel requested review from Bastien Montagne 2024-04-24 17:44:29 +02:00

@blender-bot build

@blender-bot build

Future Blender versions are likely to write more invalid pointers, which
would then trigger these asserts in older versions. I guess as long as
it is only an assert this is ok, but could be annoying in some cases.
Though with these asserts they are more likely to be caught and fixed.

Honestly, I'd rather have a CLOG_ERROR here... I suspect an assert may indeed become very annoying in the future, given how little testing (if any at all) forward compatibility gets... And the log error will also appear in release builds, not only debug ones.

> Future Blender versions are likely to write more invalid pointers, which > would then trigger these asserts in older versions. I guess as long as > it is only an assert this is ok, but could be annoying in some cases. > Though with these asserts they are more likely to be caught and fixed. Honestly, I'd rather have a `CLOG_ERROR` here... I suspect an assert may indeed become very annoying in the future, given how little testing (if any at all) forward compatibility gets... And the log error will also appear in release builds, not only debug ones.
Author
Owner

I'd rather not bother users with this message. But I guess I can make it a not abort and still show the message when asserts are enabled? Though I don't think we have an existing mechanism or convention for that.

I'd rather not bother users with this message. But I guess I can make it a not abort and still show the message when asserts are enabled? Though I don't think we have an existing mechanism or convention for that.

What's the practical difference between 'use CLOG' and 'assert with no abort', from a user PoV?

Am also not sure how noisy that would be for the user - it's only in console, and is not expected to happen often, especially not (hopefully!) with files produced by official releases?

And IIRC, CLOG_ERROR will be detected and cause failure of unittests steps on the buildbot (because its message starts with ERROR in the console)?

What's the practical difference between 'use `CLOG`' and 'assert with no abort', from a user PoV? Am also not sure how noisy that would be for the user - it's only in console, and is not expected to happen often, especially not (hopefully!) with files produced by official releases? And IIRC, `CLOG_ERROR` will be detected and cause failure of unittests steps on the buildbot (because its message starts with `ERROR` in the console)?
All checks were successful
buildbot/vexp-code-patch-lint Build done.
buildbot/vexp-code-patch-linux-x86_64 Build done.
buildbot/vexp-code-patch-darwin-arm64 Build done.
buildbot/vexp-code-patch-darwin-x86_64 Build done.
buildbot/vexp-code-patch-windows-amd64 Build done.
buildbot/vexp-code-patch-coordinator Build done.
This pull request has changes conflicting with the target branch.
  • source/blender/blenloader/intern/readfile.cc

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u refactor-assert-broken-pointer:brecht-refactor-assert-broken-pointer
git checkout brecht-refactor-assert-broken-pointer
Sign in to join this conversation.
No reviewers
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.

Reference: blender/blender#120997
No description provided.