Page MenuHome

OldNewMap handling of pointers in blenloader does not work correctly with FD_FLAGS_SWITCH_ENDIAN
Closed, ResolvedPublic


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:

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

Event Timeline

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

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

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

@Marcus Comstedt (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?

@Jacques Lucke (JacquesLucke) Sure. Here you go:

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


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.