Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#1002 closed defect (fixed)

assertion failures with VS2017 / VS2019

Reported by: dbaston Owned by: geos-devel@…
Priority: major Milestone: 3.8.1
Component: Default Version: 3.8.0
Severity: Unassigned Keywords:
Cc:

Description

Reported by Asa Packer:

If I build in Debug mode, with either VS2017 or VS2019, I get tons of assertion failures when I do ctest. They all come from line 115 of MonotoneChainBuilder.cpp, which on the last time through the loop causes an access of an element one past the end of a std::vector. Even if I ignore the assertion failures, the tests show as fails because the C runtime considers these to be fatal errors.

Proposed fix:

--- geos-3.8.0/src/index/chain/MonotoneChainBuilder.cpp

+++ geos-3.8.0/src/index/chain/MonotoneChainBuilder.cpp

@@ -111,8 +111,10 @@

             }

         }

         ++last;

-        prev = curr;

-        curr = &pts[last];

+        if (last < npts) {

+            prev = curr;

+            curr = &pts[last];

+        }

     }

Change History (6)

comment:2 by strk, 3 years ago

Merge instructions, for local testing:

git checkout -b dbaston-trac-1002 master git pull https://github.com/dbaston/libgeos.git trac-1002

comment:3 by strk, 3 years ago

Daniel any chance to see a test added for this case ?

comment:4 by dbaston, 3 years ago

Not without adding these MSVC configurations to our CI. The code in question is already hit by our test suites; the bug is just optimized out.

comment:5 by Daniel Baston <dbaston@…>, 3 years ago

Resolution: fixed
Status: newclosed

In 3fc6528/git:

Avoid access past end of vector

In most configurations this access would be optimized out (as it is
never used) but this is not always the case.

Fixes #1002

comment:6 by Dan Baston <dbaston@…>, 3 years ago

In 93be2e1/git:

Avoid access past end of vector

In most configurations this access would be optimized out (as it is
never used) but this is not always the case.

Fixes #1002

Note: See TracTickets for help on using tickets.