ply-Import fails if first byte of binary vertex coordinates is equal to 0x0a or 0x0d #116022

Closed
opened 2023-12-11 10:02:13 +01:00 by Michael-Patra · 1 comment

System Information
Operating system: Windows-10-10.0.19045-SP0 64 Bits
Graphics card: Intel(R) Iris(R) Xe Graphics Intel 4.6.0 - Build 31.0.101.4575

Blender Version
Broken: version: 4.1.0 Alpha, branch: main, commit date: 2023-12-10 23:52, hash: fb5d03b5baae
Worked: (newest version of Blender that worked as expected)

Short description of error

The Blender ply-import will fail if the first byte of the vertex data is equal to 0x0a or 0x0d. The error message shown in the console is (a similar message is also shown in the main window for a short while).

PLY Importer: failed importing bad: Invalid face size, must be between 1 and 255

The error will appear whenever the binary data of the vertex point coordinates will start with a 0x0a or 0x0d. The header of a ply-file (as e.g., exported by blender) will end with the text "end_header", followed by a 0x0a byte for line-feed. After that follows the binary representation of the vertex coordinates.

The two attached ply-files differ only in the one byte directly following the line-feed after "end_header" - one will be imported correctly, the other will give an error message.

--- bad.hexdump 2023-12-11 09:51:21.655242354 +0100
+++ good.hexdump 2023-12-11 09:51:15.287243512 +0100
@@ -13,7 +13,7 @@
000000c0 31 0a 70 72 6f 70 65 72 74 79 20 6c 69 73 74 20 |1.property list |
000000d0 75 63 68 61 72 20 75 69 6e 74 20 76 65 72 74 65 |uchar uint verte|
000000e0 78 5f 69 6e 64 69 63 65 73 0a 65 6e 64 5f 68 65 |x_indices.end_he|
-000000f0 61 64 65 72 0a 0a 00 80 bf 00 00 80 bf 00 00 00 |ader............|
+000000f0 61 64 65 72 0a 0b 00 80 bf 00 00 80 bf 00 00 00 |ader............|
00000100 00 00 00 00 00 00 00 00 00 00 00 80 3f 00 00 80 |............?...|
00000110 bf 00 00 00 00 00 00 80 3f 00 00 00 00 00 00 80 |........?.......|
00000120 3f 00 00 80 3f 00 00 00 00 00 00 80 3f 00 00 80 |?...?.......?...|

My educated guess that the ply-importer will read an arbitrary number of 0x0a and 0x0d-bytes after "end_header" believing that they are line-feeds and carriage-returns and thus irrelevant. However, these bytes can belong to the point data, and the entire data is now read shifted by one position - resulting in garbage.

Exact steps for others to reproduce the error
[Please describe the exact steps needed to reproduce the issue]
[Based on the default startup or an attached .blend file (as simple as possible)]

File - Import - Stanford PLY (.ply) - bad.ply ==> This will give an error message
File - Import - Stanford PLY (.ply) - good.ply ==> This will result in a square being imported

**System Information** Operating system: Windows-10-10.0.19045-SP0 64 Bits Graphics card: Intel(R) Iris(R) Xe Graphics Intel 4.6.0 - Build 31.0.101.4575 **Blender Version** Broken: version: 4.1.0 Alpha, branch: main, commit date: 2023-12-10 23:52, hash: `fb5d03b5baae` Worked: (newest version of Blender that worked as expected) **Short description of error** The Blender ply-import will fail if the first byte of the vertex data is equal to 0x0a or 0x0d. The error message shown in the console is (a similar message is also shown in the main window for a short while). PLY Importer: failed importing bad: Invalid face size, must be between 1 and 255 The error will appear whenever the binary data of the vertex point coordinates will start with a 0x0a or 0x0d. The header of a ply-file (as e.g., exported by blender) will end with the text "end_header", followed by a 0x0a byte for line-feed. After that follows the binary representation of the vertex coordinates. The two attached ply-files differ only in the one byte directly following the line-feed after "end_header" - one will be imported correctly, the other will give an error message. --- bad.hexdump 2023-12-11 09:51:21.655242354 +0100 +++ good.hexdump 2023-12-11 09:51:15.287243512 +0100 @@ -13,7 +13,7 @@ 000000c0 31 0a 70 72 6f 70 65 72 74 79 20 6c 69 73 74 20 |1.property list | 000000d0 75 63 68 61 72 20 75 69 6e 74 20 76 65 72 74 65 |uchar uint verte| 000000e0 78 5f 69 6e 64 69 63 65 73 0a 65 6e 64 5f 68 65 |x_indices.end_he| -000000f0 61 64 65 72 0a 0a 00 80 bf 00 00 80 bf 00 00 00 |ader............| +000000f0 61 64 65 72 0a 0b 00 80 bf 00 00 80 bf 00 00 00 |ader............| 00000100 00 00 00 00 00 00 00 00 00 00 00 80 3f 00 00 80 |............?...| 00000110 bf 00 00 00 00 00 00 80 3f 00 00 00 00 00 00 80 |........?.......| 00000120 3f 00 00 80 3f 00 00 00 00 00 00 80 3f 00 00 80 |?...?.......?...| My educated guess that the ply-importer will read an arbitrary number of 0x0a and 0x0d-bytes after "end_header" believing that they are line-feeds and carriage-returns and thus irrelevant. However, these bytes can belong to the point data, and the entire data is now read shifted by one position - resulting in garbage. **Exact steps for others to reproduce the error** [Please describe the exact steps needed to reproduce the issue] [Based on the default startup or an attached .blend file (as simple as possible)] File - Import - Stanford PLY (.ply) - bad.ply ==> This will give an error message File - Import - Stanford PLY (.ply) - good.ply ==> This will result in a square being imported
Michael-Patra added the
Type
Report
Status
Needs Triage
Priority
Normal
labels 2023-12-11 10:02:14 +01:00
Iliya Katushenock added the
Interest
Pipeline, Assets & IO
label 2023-12-11 13:27:45 +01:00
Member

Hi, thanks for the report. Looks like changes done in 6c6edaf513 affected the importing of bad.ply here.
@aras_p , can you check?

Hi, thanks for the report. Looks like changes done in 6c6edaf513a335f0130fbd822ba4adf0d3c54402 affected the importing of bad.ply here. @aras_p , can you check?
Aras Pranckevicius self-assigned this 2023-12-12 11:58:25 +01:00
Aras Pranckevicius added
Type
Bug
and removed
Type
Report
labels 2023-12-12 11:58:41 +01:00
Blender Bot added
Status
Resolved
and removed
Status
Confirmed
labels 2023-12-12 18:10:00 +01: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
2 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#116022
No description provided.