Opened 9 years ago

Closed 9 years ago

#8575 closed Bugs (fixed)

boost::polygon::operators::operator* crashes on a specific pair of polygons

Reported by: ckozhukhin@… Owned by: Andrii Sydorchuk
Milestone: Boost 1.56.0 Component: polygon
Version: Boost 1.53.0 Severity: Problem
Keywords: Cc:

Description

The issue appears to be caused by int overflow - if I halve the value of coordinates of both polygons operator* works correctly.

Polygon1: (-2147483646, -2147483646), (429496729, -2147483646), (2147483646, 2147483646)

Polygon2: (-1288490188, -2147483646), (1288490188, -2147483646), (1288490188, 2147483646), (-1288490188, 2147483646)

Code snippet:

namespace bp = boost::polygon;
using namespace boost::polygon::operators;

typedef bp::polygon_data<int> Polygon;
typedef bp::polygon_traits<Polygon>::point_type Point;
typedef std::vector<Polygon> PolygonSet;

...

Polygon p1 = makeBoostPolygon(...);
Polygon p2 = makeBoostPolygon(...);
PolygonSet ps1;
ps1 += p1;
PolygonSet ps2;
ps2 += p2;
PolygonSet intersection;
assign(intersection, ps1*ps2); // Crashes with access violation

Attachments (2)

LargeIntCrash.zip (3.5 KB ) - added by ckozhukhin@… 9 years ago.
Crash reproducer
8575.diff (4.8 KB ) - added by Andrii Sydorchuk 9 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 by Constantine Kozhukhin <ckozhukhin@…>, 9 years ago

Forgot to mention - I observed the crash on Windows x64 in Visual Studio 2010 Express.

comment:2 by Andrii Sydorchuk, 9 years ago

Milestone: To Be DeterminedBoost 1.55.0
Owner: changed from Lucanus Simonson to Andrii Sydorchuk
Status: newassigned

comment:3 by Andrii Sydorchuk, 9 years ago

Hi,

Thanks for the report. If possible, could you attach the full code snippet or file?

Thanks, Andrii

by ckozhukhin@…, 9 years ago

Attachment: LargeIntCrash.zip added

Crash reproducer

comment:4 by ckozhukhin@…, 9 years ago

Andrii, I attached VC++ project with the reproducer. I used VS 2010 Express. In Debug configuration it triggers a debug assertion in line 45

	ps1 += p1;

comment:5 by Andrii Sydorchuk, 9 years ago

Milestone: Boost 1.55.0To Be Determined

by Andrii Sydorchuk, 9 years ago

Attachment: 8575.diff added

comment:6 by Andrii Sydorchuk, 9 years ago

Milestone: To Be DeterminedBoost 1.56.0
Resolution: fixed
Status: assignedclosed

The issue was related to the integer overflow. I've fixed the problem. Please apply the attached patch or sync with the trunk branch: https://svn.boost.org/svn/boost/trunk/boost/polygon/

Note: See TracTickets for help on using tickets.