8000 Early return when result size too large by pca006132 · Pull Request #1166 · elalish/manifold · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Early return when result size too large #1166

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

Merged
merged 1 commit into from
Feb 25, 2025
Merged

Early return when result size too large #1166

merged 1 commit into from
Feb 25, 2025

Conversation

pca006132
Copy link
Collaborator

Closes #1164.

I have looked at the code for cases where the result size can be too large, and it seems that not a lot can cause integer overflow if we limit the input size (halfedge count).

@howardt can you check if this can avoid the crash?

@pca006132 pca006132 requested a review from elalish February 25, 2025 06:48
@@ -531,6 +533,11 @@ Boolean3::Boolean3(const Manifold::Impl &inP, const Manifold::Impl &inQ,
p2q0.Sort();
PRINT("p2q0 size = " << p2q0.size());

if (3 * p1q2_.size() + 3 * p2q1_.size() > INT_MAX_SZ) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the specific expression that can overflow integers.

@@ -573,6 +580,11 @@ Boolean3::Boolean3(const Manifold::Impl &inP, const Manifold::Impl &inQ,
Intersect12(inQ, inP, s20, p2q0, s11, p1q1, z20, xyzz11, p2q1_, false);
PRINT("x21 size = " << x21_.size());

if (x12_.size() > INT_MAX_SZ || x21_.size() > INT_MAX_SZ) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

x12 and x21 can be at most the size of the sparse indices, which is at most n^2 and can cause overflow elsewhere.

Copy link
codecov bot commented Feb 25, 2025

Codecov Report

Attention: Patch coverage is 30.00000% with 7 lines in your changes missing coverage. Please review.

Project coverage is 91.60%. Comparing base (5399bd4) to head (1bac97e).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/boolean_result.cpp 20.00% 4 Missing ⚠️
src/boolean3.cpp 40.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1166      +/-   ##
==========================================
- Coverage   91.70%   91.60%   -0.11%     
==========================================
  Files          32       32              
  Lines        5980     5990      +10     
==========================================
+ Hits         5484     5487       +3     
- Misses        496      503       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Owner
@elalish elalish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@pca006132 pca006132 merged commit cba9e35 into master Feb 25, 2025
27 checks passed
@elalish elalish deleted the fix-overflow branch February 27, 2025 08:32
@elalish elalish mentioned this pull request May 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash with large number of intersections
2 participants
0