Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[io] savePCDFileBinary causes SEH exception on Windows #5674

Closed
msz-rai opened this issue Apr 19, 2023 · 1 comment · Fixed by #5675
Closed

[io] savePCDFileBinary causes SEH exception on Windows #5674

msz-rai opened this issue Apr 19, 2023 · 1 comment · Fixed by #5675
Labels

Comments

@msz-rai
Copy link

msz-rai commented Apr 19, 2023

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.

@mvieth
Copy link
Member

mvieth commented Apr 19, 2023

Thanks for reporting this. The problem seems to be that CreateFileMapping accepts the file size in two 32 bit, unsigned parameters (a high and a low part). Currently, PCL sets the high part always to 0, so the maximum file size would be 2^32 bytes (roughly 357 million PointXYZ).
I will create a fix for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants