OldNewMap handling of pointers in blenloader does not work correctly with FD_FLAGS_SWITCH_ENDIAN #81226

Closed
opened 2020-09-27 12:53:40 +02:00 by Marcus Comstedt · 10 comments

System Information
Operating system: Linux/ppc64
Graphics card: llvmpipe

Blender Version
Broken: 2.83.4, master
Worked: ?

Short description of error
The functions switch_endian_bh4 and switch_endian_bh8 in readfile.c do not byteswap the "old" pointer field. In theory this is fine, as it is just used as an opaque handle, which is mapped to an actual pointer via the OldNewMap. However, in practice this does not work because it seems that the reference pointers to the object are byteswapped, and so if the pointer used as key to create the entry in the OldNewMap is not byteswapped as well, the values will not match and the lookup will fail.

This can easily fixed by just swapping the "old" pointer in the bh swapping functions. That also removes the need for the workaround in bh4_from_bh8. Please see the following patch:
blender.patch

Exact steps for others to reproduce the error

  1. Start blender on a big endian 64-bit system
  2. Startup crashes as it fails to load the builtin WM blendfile, getting a NULL back from oldnewmap_lookup_and_inc
**System Information** Operating system: Linux/ppc64 Graphics card: llvmpipe **Blender Version** Broken: 2.83.4, master Worked: ? **Short description of error** The functions switch_endian_bh4 and switch_endian_bh8 in readfile.c do not byteswap the "old" pointer field. In theory this is fine, as it is just used as an opaque handle, which is mapped to an actual pointer via the OldNewMap. However, in practice this does not work because it seems that the reference pointers to the object *are* byteswapped, and so if the pointer used as key to create the entry in the OldNewMap is not byteswapped as well, the values will not match and the lookup will fail. This can easily fixed by just swapping the "old" pointer in the bh swapping functions. That also removes the need for the workaround in bh4_from_bh8. Please see the following patch: [blender.patch](https://archive.blender.org/developer/F8928134/blender.patch) **Exact steps for others to reproduce the error** 1) Start blender on a big endian 64-bit system 2) Startup crashes as it fails to load the builtin WM blendfile, getting a NULL back from oldnewmap_lookup_and_inc

Added subscriber: @zeldin

Added subscriber: @zeldin

Added subscribers: @JacquesLucke, @mano-wii

Added subscribers: @JacquesLucke, @mano-wii

Thanks for the report, unfortunately I don't have a big endian 64-bit system to test.

@JacquesLucke, if I'm not mistaken, you worked in this area recently.
Do you know what's going on here?

Thanks for the report, unfortunately I don't have a big endian 64-bit system to test. @JacquesLucke, if I'm not mistaken, you worked in this area recently. Do you know what's going on here?
Member

Just last week I found this issue as well. My fix (which is essentially the same) is part of D9089.

@zeldin, can you provide a .blend file that has been saved on a big endian 64 bit system? Can you also check if D9089 fixes it for you?

Just last week I found this issue as well. My fix (which is essentially the same) is part of [D9089](https://archive.blender.org/developer/D9089). @zeldin, can you provide a .blend file that has been saved on a big endian 64 bit system? Can you also check if [D9089](https://archive.blender.org/developer/D9089) fixes it for you?

@JacquesLucke Sure. Here you go:
untitled.blend

I'll try your patch later, need to make a new git checkout since the patch does not apply cleanly to 2.83.4. :-)

@JacquesLucke Sure. Here you go: [untitled.blend](https://archive.blender.org/developer/F8958873/untitled.blend) I'll try your patch later, need to make a new git checkout since the patch does not apply cleanly to 2.83.4. :-)
Member

Thanks!

Did any older version of Blender work on your hardware?

Thanks! Did any older version of Blender work on your hardware?

Yes. The "?" in "Worked" just means that I can't remember what the version number was. :-)

Well, I can't say for sure that it was possible to load little endian .blend files from disk, but running it in BE worked fine.

Yes. The "?" in "Worked" just means that I can't remember what the version number was. :-) Well, I can't say for sure that it was possible to load little endian .blend files from disk, but running it in BE worked fine.

This issue was referenced by ffb220590e

This issue was referenced by ffb220590ea76bc279eeb3498776a360467125c1

This issue was referenced by 724a4f4676

This issue was referenced by 724a4f4676586d65b718deab7f04f207e0ad6488

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

Changed status from 'Needs Triage' to: 'Resolved'
Campbell Barton self-assigned this 2020-10-07 13:00:44 +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
5 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#81226
No description provided.