[io] pcl::io::raw_open opens files in text mode on Windows, so raw_read alters binary data
Maintainer thường phản hồi trong vòng 3 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 1/5
- Thời gian dự kiến
- Dưới một giờ
- Mức phù hợp với người mới
- 82/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- cpp
- Lĩnh vực
- operating-systems
Hướng nghiên cứu
Bắt đầu trong pcl/io/low_level_io.h, ở nhánh _WIN32 nơi raw_open bọc ::_open; so sánh các overload đó với các overload POSIX. Tái hiện bằng một tệp nhị phân nhỏ chứa 0D 0A và 1A, như trong issue, và kiểm tra số byte của raw_read. Sau đó chạy thử các caller bị ảnh hưởng PCDReader::read cho các tệp binary_compressed và LineRGBD::loadTemplates. Hoàn tất nghĩa là raw_read trên Windows trả về các byte của tệp không đổi và không còn cắt ngắn tại CRLF hoặc 0x1A.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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);
}
- Ngôn ngữ chính
- C++
- Star
- 11.2k
- Fork
- 4.7k
- Merge trung bình
- 6 ngày 13 giờ
- Pull request đã merge (30 ngày)
- 10
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của PointCloudLibrary/pcl
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
PointCloudLibrary/pcl#6509 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
kind: bug status: triage
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
PointCloudLibrary/pcl#6537 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
[cmake] QHULL/FLANN dll missing when linking single moduleCó thể đã có người làm @SIDDARTHAREDDY8 đã nhận 5 ngày trước. Đang mởkind: bug module: cmake
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 50/100
PointCloudLibrary/pcl#6522 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
kind: bug status: triage
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
PointCloudLibrary/pcl#6395 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
[sample_consensus] Migrated the SSE and AVX implementations of countWithinDistance to RISC-V RVV 1.0Đang mởkind: request status: triage
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
PointCloudLibrary/pcl#6385 · 1 reaction ·
Maintainer thường phản hồi trong vòng 3 ngày
Tất cả issue của PointCloudLibrary/pcl
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
nextcloud/passman-android#214 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
feature wsl2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
microsoft/WSL#42306 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
2026.11.0 fails to install on Intel macOS: requirements.txt pins cryptography==50.0.2 for Darwin x86_64Có thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 87/100
esphome/esphome#22892 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
sec_touch: a corrupted panel ACK ends a GET as malformed while its data frame is still comingĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
distante/esphome-components#50 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày