Repeated file block addresses in files saved with 3.5.1 #108150

Closed
opened 2023-05-22 17:14:34 +02:00 by arturoc · 7 comments

System Information
Operating system: Linux-6.2.0-1003-lowlatency-x86_64-with-glibc2.37 64 Bits
Graphics card: NVIDIA GeForce GTX 1080/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 525.105.17

Blender Version
Broken: version: 3.5.1, branch: blender-v3.5-release, commit date: 2023-04-24 18:11, hash: e1ccd9d4a1d3
Worked: version 3.4.1

Just for reference: the following commits seem to have introduced this :

Short description of error
While trying to read the content of a blender file using a custom tool following the format description in "The mystery of the blend" several "DATA" file blocks have the same old address when the file is saved with blender 3.5.0, 3.5.1 or the current beta for 3.6.0 (3.6.0-beta+v36.52f991b1a9b3). This doesn't happen with files saved with versions up until 3.4.1 although those also have a DrawDataList in the "REND" block and a FileGlobal in the "GLOB" block with the same old address.

As far as I understand there should never be two or more blocks with the same address. Also the blocks have different sizes and in some cases even different types, usually with the data content of meshes, ie: vertices, loops, uv loops...

What seems to be happening is that the vertex data in the original mesh and the duplicated one are saved with the same addresses.

Exact steps for others to reproduce the error

Not sure if there's other ways to replicate the error but duplicating a mesh and then editing the vertices on the copy seems to create a file with this problem.

Adding the following lines to the BlendFileReader.py in doc/blender_file_format shows the file blocks with duplicated addresses:

def main():
    handle = openBlendFile(PATH_TO_FILE_TO_PARSE)
    blend = BlendFile(handle)
    blockaddrs = set()
    for block in blend.Blocks:
        if block.Header.OldAddress in blockaddrs:
            print("Duplicated", block.Header.OldAddress)
        else:
            blockaddrs.add(block.Header.OldAddress)

if __name__ == '__main__':
    main()

Attached are two files demonstrating the problem, the one saved with blender 3.3.6 doesn't have data blocks with the same address. The one saved with 3.5.1 has two vertices and uv loop data blocks duplicated. The file was created in 3.5.1 by duplicating a sphere and modifying it's vertices and faces. The version saved with 3.3.6 is the same file just opened in 3.3.6 and saving it with a different name. as _336.

**System Information** Operating system: Linux-6.2.0-1003-lowlatency-x86_64-with-glibc2.37 64 Bits Graphics card: NVIDIA GeForce GTX 1080/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 525.105.17 **Blender Version** Broken: version: 3.5.1, branch: blender-v3.5-release, commit date: 2023-04-24 18:11, hash: `e1ccd9d4a1d3` Worked: version 3.4.1 Just for reference: the following commits seem to have introduced this : - 1af62cb3bf46f0cd328ab0840a1363eca938c628 - 6c774feba2c9a1eb5834646f597a0f2c63177914 **Short description of error** While trying to read the content of a blender file using a custom tool following the format description in "The mystery of the blend" several "DATA" file blocks have the same old address when the file is saved with blender 3.5.0, 3.5.1 or the current beta for 3.6.0 (3.6.0-beta+v36.52f991b1a9b3). This doesn't happen with files saved with versions up until 3.4.1 although those also have a DrawDataList in the "REND" block and a FileGlobal in the "GLOB" block with the same old address. As far as I understand there should never be two or more blocks with the same address. Also the blocks have different sizes and in some cases even different types, usually with the data content of meshes, ie: vertices, loops, uv loops... What seems to be happening is that the vertex data in the original mesh and the duplicated one are saved with the same addresses. **Exact steps for others to reproduce the error** Not sure if there's other ways to replicate the error but duplicating a mesh and then editing the vertices on the copy seems to create a file with this problem. Adding the following lines to the `BlendFileReader.py` in `doc/blender_file_format` shows the file blocks with duplicated addresses: ```Py def main(): handle = openBlendFile(PATH_TO_FILE_TO_PARSE) blend = BlendFile(handle) blockaddrs = set() for block in blend.Blocks: if block.Header.OldAddress in blockaddrs: print("Duplicated", block.Header.OldAddress) else: blockaddrs.add(block.Header.OldAddress) if __name__ == '__main__': main() ``` Attached are two files demonstrating the problem, the one saved with blender 3.3.6 doesn't have data blocks with the same address. The one saved with 3.5.1 has two vertices and uv loop data blocks duplicated. The file was created in 3.5.1 by duplicating a sphere and modifying it's vertices and faces. The version saved with 3.3.6 is the same file just opened in 3.3.6 and saving it with a different name. as _336.
arturoc added the
Priority
Normal
Type
Report
Status
Needs Triage
labels 2023-05-22 17:14:34 +02:00
Iliya Katushenock added the
Interest
Python API
label 2023-05-22 18:10:25 +02:00
Member

Can confirm, interesting...
Might take a bit to investigate when this happened, will try my best.

Can confirm, interesting... Might take a bit to investigate when this happened, will try my best.
Philipp Oeser added
Status
Confirmed
Interest
BlendFile
Module
Core
and removed
Status
Needs Triage
labels 2023-05-23 15:58:05 +02:00
Author

Thanks! I think this might generally not affect blender cause it probably sets the new addresses on the go so when it reads a mesh data it uses the latest it has read already then overwrites those addresses but the next mesh has the correct data pointers anyway.

But wonder if it might create data corruption in some cases.

Thanks! I think this might generally not affect blender cause it probably sets the new addresses on the go so when it reads a mesh data it uses the latest it has read already then overwrites those addresses but the next mesh has the correct data pointers anyway. But wonder if it might create data corruption in some cases.

Having several BLO_CODE_DATA blocks in a .blend file with the same address is not invalid in itself. What would be invalid is having several BLO_CODE_DATA with the same address inside of a same ID range of blocks (i.e. a range of continuous BLO_CODE_DATA blocks, delimited by two non-BLO_CODE_DATA ones).

In other (less implementation-related) words, the uniqueness of pointers of sub-data only has to be ensured per-ID, not across the whole blendfile.

Having several `BLO_CODE_DATA` blocks in a .blend file with the same address is not invalid in itself. What would be invalid is having several `BLO_CODE_DATA` with the same address inside of a same `ID` range of blocks (i.e. a range of continuous `BLO_CODE_DATA` blocks, delimited by two non-`BLO_CODE_DATA` ones). In other (less implementation-related) words, the uniqueness of pointers of sub-data only has to be ensured per-ID, not across the whole blendfile.
Author

I see. That makes sense. Feel free to close it then, I thought it might be an error since I had never seen it in previous versions.

I see. That makes sense. Feel free to close it then, I thought it might be an error since I had never seen it in previous versions.
Member

Just for reference: the following commits seem to have introduced this :

CC @HooglyBoogly
CC @Baardaap

Will leave up to the modules to decide who is responsible.

Just for reference: the following commits seem to have introduced this : - 1af62cb3bf46f0cd328ab0840a1363eca938c628 - 6c774feba2c9a1eb5834646f597a0f2c63177914 CC @HooglyBoogly CC @Baardaap Will leave up to the modules to decide who is responsible.
Philipp Oeser added
Interest
Modeling
and removed
Interest
Python API
labels 2023-05-24 12:51:36 +02:00

Note: About uniqueness of BLO_CODE_DATA blocks: A few type of data (e.g. viewlayers) actually need to have a unique memaddress across the whole blender file (essentially because they are also registered in the globmap mapping for global data pointers).

Note: About uniqueness of BLO_CODE_DATA blocks: A few type of data (e.g. viewlayers) actually need to have a unique memaddress across the whole blender file (essentially because they are also registered in the `globmap` mapping for global data pointers).

But ultimately the cases here should not be an issue. Although that kind of dynamically generated data on file write should be avoided, it's not always possible, especially when dealing with forward compatibility.

The only way to fully avoid such cases would be to have some kind of dedicated allocator for file writing, which would ensure to never ever return the same memory address twice.

But ultimately the cases here should not be an issue. Although that kind of dynamically generated data on file write should be avoided, it's not always possible, especially when dealing with forward compatibility. The only way to fully avoid such cases would be to have some kind of dedicated allocator for file writing, which would ensure to never ever return the same memory address twice.
Blender Bot added
Status
Archived
and removed
Status
Confirmed
labels 2023-05-24 17:05:47 +02: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#108150
No description provided.