You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: Binary ply - Line-ending char after the end_header line causes parsing issues #5341
Describe the bug
For a binary ply, if the first char after the "end_header\n" line is '\n' (hence empty line), this char (and line) will be skipped, causing the parser to read the first face element as a vertex part, and shifting everything (all vertices will be incorrect, and faces will be wrong).
To Reproduce
Steps to reproduce the behavior:
Take a binary ply, replace the first char after "end_header\n" by '\n' and try to import it in assimp.
See error, there will probably be something like 'Validation failed: aiMesh::mFaces[4]::mIndices[0] is out of range' (because of the shifting)
Expected behavior
The mesh should be read without any issue.
Platform (please complete the following information):
OS: Windows 10
Version: reproduced on current master (tag 77a8f01)
Additional context
My mesh is a little endian mesh with faces property 'property list uchar int vertex_indices', since the first line begins with x03x00x00x00x00x01x00x00x00x02, the first char (x03) is considered as the last part of the vertices, hence the 4 first faces are considered to have 0 vertices, and the fifth to have 1 vertex of index 33554432 (which is larger than the total number of vertices, hence the validation error).
The removal of the end of line char error occurs in the PlyParser.cpp file, because of the function SkipSpacesAndLineEnd(std::vector &buffer) called in PLY::Element::ParseElement(IOStreamBuffer &streamBuffer, std::vector &buffer, PLY::Element *pOut), itself called in PLY::DOM::ParseHeader(IOStreamBuffer &streamBuffer, std::vector &buffer, bool isBinary); which will remove the "empty line" after the end of the header
Reacted by fchapelle-modjaw, Carbene Hu, max and afavray-modjaw
Ran into the same problem recently, I digged out that it may be related to IOStreamBuffer<T>::getNextLine, refered from PLY::Element::ParseElement. This piece of code would eat all following '\n' and '\r' in m_cache:
Hello @tellypresence, I'm working with @flogtk and yes, the problem persists.
We're currently using Assimp 5.2.5. Do you know if the bug has been fixed in later versions?
Note for future readers: The above linked issue was live in ubuntu jammy (assimp 5.2.5), in noble (assimp 5.3.1) you get the same error, but this time it comes from a different location in the code, and the fix is the following: b973086#5692
Activity
Hyiker commentedon Dec 6, 2023
Ran into the same problem recently, I digged out that it may be related to
IOStreamBuffer<T>::getNextLine, refered fromPLY::Element::ParseElement. This piece of code would eat all following '\n' and '\r' in m_cache:Perhaps we could offer another function with an argument specifying the max count of LFs to be consumed?
tellypresence commentedon Apr 15, 2025
@flogtk Is this still a problem?
afavray-modjaw commentedon Apr 15, 2025
Hello @tellypresence, I'm working with @flogtk and yes, the problem persists.
We're currently using Assimp 5.2.5. Do you know if the bug has been fixed in later versions?
tellypresence commentedon May 13, 2025
PLY issues tracked via epic #6163
whateverforever commentedon Sep 12, 2025
got the same issue, this used to work under focal, but I think the update that happened during the package changes for jammy
Manage /R/N lines ends correctly on binary files, tested with solidwo…
whateverforever commentedon May 8, 2026
Note for future readers: The above linked issue was live in ubuntu jammy (assimp 5.2.5), in noble (assimp 5.3.1) you get the same error, but this time it comes from a different location in the code, and the fix is the following: b973086 #5692
afavray-modjaw commentedon May 11, 2026
Thanks @whateverforever for the notification!
It looks merged in Assimp 6.0.0, I need to check that ASAP