Skip to content

[io] savePCDFileBinary causes SEH exception on Windows #5674

@msz-rai

Description

@msz-rai

Describe the bug

When trying to save a PCD file with at least 375 000 000 points (PointXYZ), I get an SEH exception with code 0xc0000005.

Expected behavior

Saved PCD file or proper exception thrown.
Also, I expect that this point cloud will be saved on my PC (with 64GB RAM, and the application takes about 6GB of memory).

Current Behavior

App crash with SEH exception.

To Reproduce

Generate pcl::pointcloud<pcl::PointXYZ> with 375000000 points, and save PCD binary file. Sample code:

std::string filePath = "test.pcd";
size_t pointCount = 375000000;
pcl::PointCloud<pcl::PointXYZ> pclCloud;
pclCloud.resize(pointCount, 1);
for (int i = 0; i < pointCount; ++i) {
	pclCloud[i] = pcl::PointXYZ(i, i, i);
}
pclCloud.is_dense = true;
pcl::io::savePCDFileBinary(filePath, pclCloud);

My Environment:

  • OS: Windows 11
  • RAM: 64GB
  • Compiler: MSVC 19.29.30148.0
  • PCL Version 1.12.0 (provided from vcpkg on tag 2022.08.15)

Possible Solution

image

I am not a Windows guy, but function MapViewOfFile() in line 174 may fail and return NULL. This case is not checked; it is assumed that map is always created successfully. Next, in line 198 map is accessed but contains NULL.

The result of MapViewOfFile() should be checked, and a proper exception should be thrown in case of failure.

Please consider adding my suggestion.
I would be grateful if you also debug why the PCD file is not saved successfully.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions