Blend file corrupted during save caused by high Cubemap Size #78529

Closed
opened 2020-07-02 12:35:02 +02:00 by Marcin Twarowski · 13 comments

System Information
Operating system: Windows-10-10.0.19041-SP0 64 Bits
Graphics card: GeForce GTX 1080/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 451.48

Blender Version
Broken: version: 2.83.1, branch: master, commit date: 2020-06-25 09:47, hash: 8289fc688b
Also broken in 2.90 52b125a790

Short description of error
If indirect lighting is baked in Eeeve with Cubemap Size 2048 or 4096, the file than gets corrupted during save and cannot be opened again. Despite the file weighting 100mb, when opened all you see is default cube. I used to see error message about DNA missing but now it does not appear. There are no error messages during save neither. When indirect lighting is baked with lower Cubemap Sizes it can be reopened normally. It happens to me on two different projects on two different machines.

Exact steps for others to reproduce the error

  • Open attached file.
    DNA_bug.blend
  • Bake Indirect Lighting with Cubemap Size set to 2048
  • Save the file after baking.
  • Try to open the saved file.
    Here's the corrupted blend file:
    DNA_bug_baked_2048.blend
**System Information** Operating system: Windows-10-10.0.19041-SP0 64 Bits Graphics card: GeForce GTX 1080/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 451.48 **Blender Version** Broken: version: 2.83.1, branch: master, commit date: 2020-06-25 09:47, hash: `8289fc688b` Also broken in 2.90 52b125a790e3 **Short description of error** If indirect lighting is baked in Eeeve with Cubemap Size 2048 or 4096, the file than gets corrupted during save and cannot be opened again. Despite the file weighting 100mb, when opened all you see is default cube. I used to see error message about DNA missing but now it does not appear. There are no error messages during save neither. When indirect lighting is baked with lower Cubemap Sizes it can be reopened normally. It happens to me on two different projects on two different machines. **Exact steps for others to reproduce the error** - Open attached file. [DNA_bug.blend](https://archive.blender.org/developer/F8659453/DNA_bug.blend) - Bake Indirect Lighting with Cubemap Size set to 2048 - Save the file after baking. - Try to open the saved file. Here's the corrupted blend file: [DNA_bug_baked_2048.blend](https://archive.blender.org/developer/F8659459/DNA_bug_baked_2048.blend)

Added subscriber: @MarcinTwarowski

Added subscriber: @MarcinTwarowski

Added subscriber: @mano-wii

Added subscriber: @mano-wii

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'

I can confirm.
This message appears when trying to load the files with the saved cubemap textures:

Failed to read blend file 'C:\Users\GERMANO\Downloads\DNA_bug_baked_2048.blend': Missing DNA block
I can confirm. This message appears when trying to load the files with the saved cubemap textures: ``` Failed to read blend file 'C:\Users\GERMANO\Downloads\DNA_bug_baked_2048.blend': Missing DNA block ```

Added subscriber: @fclem

Added subscriber: @fclem
Clément Foucault self-assigned this 2020-07-03 02:25:50 +02:00

The total data size is reported to be 3.5GiB so there is something really strange here. I need to dig further.

The total data size is reported to be 3.5GiB so there is something really strange here. I need to dig further.

Added subscriber: @mont29

Added subscriber: @mont29

Ok, it is caused by an integer overflow in writefile.c:

line 2507: write_lightcache_texture(writer, &cache->cube_tx);
line 2500: BLO_write_raw(writer, data_size, tex->data);

Here data_size is equal to 2 818 572 288 which is casted to int for BLO_write_raw making it negative.

@mont29 So it seems this system was not supposed to support really large datablocks. What would be the best workaround for this? I can split the texture into multiple datablocks if needed.

Ok, it is caused by an integer overflow in `writefile.c`: ```lang=c line 2507: write_lightcache_texture(writer, &cache->cube_tx); line 2500: BLO_write_raw(writer, data_size, tex->data); ``` Here `data_size` is equal to 2 818 572 288 which is casted to `int` for `BLO_write_raw` making it negative. @mont29 So it seems this system was not supposed to support really large datablocks. What would be the best workaround for this? I can split the texture into multiple datablocks if needed.

On the other hand it seems these size of texture are not supported by many OpenGL implementation. Here a Cubemap Texture of 1024x1024x258 (43 cubemaps) is not supported even on high end AMD Polaris (but 42 are supported which still exceed the Writer limit).

I should add a safeguard if the texture cannot be allocated.

On the other hand it seems these size of texture are not supported by many OpenGL implementation. Here a Cubemap Texture of 1024x1024x258 (43 cubemaps) is not supported even on high end AMD Polaris (but 42 are supported which still exceed the Writer limit). I should add a safeguard if the texture cannot be allocated.

After trying to get it right I just have to postpone the real fix for 2.91.

For 2.90 will just have a warning that the cache won't be saved if it exceed the size limit 2.15GB.

This is the start of the fix. https://developer.blender.org/P1564 The issue with this fix is that it doubles the needed memory to load the cache and it is cleary a hack. A better fix would be doable once we have the GPU module refactored (part of the Vulkan port).

After trying to get it right I just have to postpone the real fix for 2.91. For 2.90 will just have a warning that the cache won't be saved if it exceed the size limit 2.15GB. This is the start of the fix. https://developer.blender.org/P1564 The issue with this fix is that it doubles the needed memory to load the cache and it is cleary a hack. A better fix would be doable once we have the GPU module refactored (part of the Vulkan port).

This issue was referenced by 220470be15

This issue was referenced by 220470be1515d90ae2c3157648bd9da311925427

This issue was referenced by 6390b530d0

This issue was referenced by 6390b530d064330edbcc50be0cdabc839f292e7c

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
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
4 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#78529
No description provided.