[io] pcl::io::raw_open opens files in text mode on Windows, so raw_read alters binary data
I maintainer di solito rispondono entro 3 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 1/5
- Tempo stimato
- Meno di un'ora
- Idoneità per principianti
- 82/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- cpp
- Ambito
- operating-systems
Direzione di ricerca
Inizia in pcl/io/low_level_io.h, nel ramo _WIN32 in cui raw_open avvolge ::_open; confronta quegli overload con quelli POSIX. Riproduci con un piccolo file binario contenente 0D 0A e 1A, come nell’issue, e controlla i conteggi di byte di raw_read. Poi esercita i chiamanti interessati PCDReader::read per i file binary_compressed e LineRGBD::loadTemplates. Fatto significa che raw_read di Windows restituisce i byte del file invariati e non tronca più in corrispondenza di CRLF o 0x1A.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
On Windows, pcl::io::raw_open (pcl/io/low_level_io.h) calls ::_open without _O_BINARY. The CRT default translation mode is text (_O_TEXT, unless the application changes _fmode). As a result, pcl::io::raw_read on that descriptor:
- collapses every CR LF pair into LF, compacting the buffer in place, and returns fewer bytes;
- stops at a 0x1A byte.
POSIX open has no text mode, so the same code reads different bytes on Linux and Windows.
PCL reads binary data through these wrappers: PCDReader::read for binary_compressed files and LineRGBD::loadTemplates. raw_open/raw_read are also public API for user code.
Expected behavior
raw_read returns the file's bytes unchanged, as it does on POSIX.
Current Behavior
A file holds the bytes 0D 0A 00 01 40 00 00 02, and 4 bytes are read from it:
| open flags | _read returns | buffer
| O_RDONLY (what raw_open does) | 3 | 0A 00 01 01
| O_RDONLY \| _O_BINARY | 4 | 0D 0A 00 01
With the bytes 1A 0A 00 00, text mode returns 0.
Consequences:
LineRGBD::loadTemplatesreads each.sqmmtentry withraw_read (ltm_fd, buffer, fsize)and checks only for-1. After the first0D 0Apair, every following byte is shifted by one and the tail holds stale bytes.sqmmt.deserializethen reads corrupted data.PCDReader::readreads the 4-byte compressed size of abinary_compressedfile withraw_readand checks onlynum_read < 0. On Windows the value is used only for the file-size check, because the whole file is mapped. When translation makes the value larger, a valid file is rejected with "Corrupted PCD file. The file is smaller than expected!". For example, a compressed size of0x01000A0D(16 779 789 bytes) is read as0x0101000A, which is 62 973 bytes too large.
To Reproduce
#include <pcl/io/low_level_io.h>
#include <fcntl.h>
#include <cstdio>
#include <fstream>
int main ()
{
const unsigned char bytes[] = {0x0D, 0x0A, 0x00, 0x01};
std::ofstream ("crlf.bin", std::ios::binary).write (reinterpret_cast<const char*> (bytes), sizeof (bytes));
int fd = pcl::io::raw_open ("crlf.bin", O_RDONLY);
unsigned char buf[4] = {};
const auto n = pcl::io::raw_read (fd, buf,
pcl::io::raw_close (fd);
std::printf ("n=%d %02X %02X %02X %02X\n",, buf[1], buf[2], buf[3]);
// Linux: n=4 0D 0A 00 01
// Windows: n=3 0A 00 01 01
}
Your Environment (please complete the following information):
- OS: Windows 11
- Compiler: MSVC (Visual Studio 2026)
- PCL Version: 1.12.1 and current master
Possible Solution
Open in binary mode inside the Windows wrappers. O_BINARY does not exist on POSIX, so callers cannot pass it portably.
#ifdef _WIN32
# include <fcntl.h> // _O_BINARY
...
inline int raw_open(const char * pathname, int flags, int mode)
{
return ::_open(pathname, flags | _O_BINARY, mode);
}
inline int raw_open(const char * pathname, int flags)
{
return ::_open(pathname, flags | _O_BINARY);
}
- Lingua principale
- C++
- Stelle
- 11.2k
- Fork
- 4.7k
- Merge medio
- 6g 13h
- PR unite (30g)
- 10
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di PointCloudLibrary/pcl
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
PointCloudLibrary/pcl#6509 · 1 commento ·
I maintainer di solito rispondono entro 3 giorni
-
kind: bug status: triage
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
PointCloudLibrary/pcl#6537 ·
I maintainer di solito rispondono entro 3 giorni
-
[cmake] QHULL/FLANN dll missing when linking single moduleForse già presa @SIDDARTHAREDDY8 l’ha presa 5 giorni fa. Apertakind: bug module: cmake
Difficoltà 3/5 Mezza giornata Idoneità per principianti 50/100
PointCloudLibrary/pcl#6522 · 1 commento ·
I maintainer di solito rispondono entro 3 giorni
-
kind: bug status: triage
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
PointCloudLibrary/pcl#6395 ·
I maintainer di solito rispondono entro 3 giorni
-
[sample_consensus] Migrated the SSE and AVX implementations of countWithinDistance to RISC-V RVV 1.0Apertakind: request status: triage
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
PointCloudLibrary/pcl#6385 · 1 reazione ·
I maintainer di solito rispondono entro 3 giorni
Tutte le issue di PointCloudLibrary/pcl
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
nextcloud/passman-android#214 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
feature wsl2
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
microsoft/WSL#42306 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
2026.11.0 fails to install on Intel macOS: requirements.txt pins cryptography==50.0.2 for Darwin x86_64Forse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 87/100
esphome/esphome#22892 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
sec_touch: a corrupted panel ACK ends a GET as malformed while its data frame is still comingApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
distante/esphome-components#50 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno