Sanitize size handling in write code #79561
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
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#79561
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?
Current handling of size (in bytes) in writer code is rather messy, to say the least: different part of the code uses
int
,uint
andsize_t
.BHead
itself stores size inint
...While
int
should be enough in most cases (it allows chunks of 2GB at most), we are now hitting some rare issues, see e.g. #78529 (Blend file corrupted during save caused by high Cubemap Size).I think we should at the very least use
size_t
everywhere in functions, and assert/try to handle the issue when actual size exceedsBHead
'sint
capacity?Ultimately it might be nice to allow bigger chunks (using
int64_t
inBHead
)? But I am not sure how we could handle that in a compatible way?Changed status from 'Needs Triage' to: 'Confirmed'
Added subscribers: @mont29, @brecht, @dfelinto, @ideasman42
Looked into this and there doesn't seem to be any elegant options seeing as the
BHead.len
is always used as the final length irrespective of the kind of data written.Increase limit to 4GB
Firstly, we could make
BHead.len
unsigned, as long as the new files don't use large allocations, they will load in older Blender versions.In the case they do, older Blender versions will see this as
len < 0
and stop loading the file.Mentioning this as as far as I can see, all the alternatives are quite involved.
Encode Large Data in the Existing Format
There are some other tricks which could work but will most likely make the code messy/unmaintainable, although if they could be done in a manageable way, we could use them in the case of over 2GB chunks being written.
This would need to be done in way that older Blender versions could read back, skipping the large allocations *. If that can't be properly supported we might as well just make all the
BHead
variables 64bit and break forwards compatibility for older Blender versions.We could for example add a new
DATA
code, only use for >2GB blocks, older Blender versions will skip it, new versions can read/write chunks multiple BHead's that don't exceedINT_MAX
.I considered using some kind of tag to show the
BHead
should be treated differently, in a way that causes it to be ignored, while there are a few options,BHead.nr
can be used for this as it's ignored on read at the moment, so this could hint at different behavior.However we still need to skip the ignored data for older Blender versions, so unless we do something really strange (writing data after the
ENDB
chunk for example), I think it's not such a good option.Other Limits
Conclusions:
I'm not convinced it's practical to support >2GB
BHead
support without breaking forward compatibility.Short term we could make
BHead.len
unsigned, then update theBHead
for a major release (3.0 for e.g) to support 64bit BHead's, with the ability to optionally save blend files for older versions.*
skipping the large allocations might not be stable and cause crashes on load, older Blender versions would need to allow for these struct-members to be NULL.Changed status from 'Confirmed' to: 'Resolved'
Sanitized code a bit in
5ea1049e75
, think we'll have to go with that for now.