Opened 7 years ago

Closed 7 years ago

Last modified 6 years ago

#3997 closed defect (fixed)

Division by zero in iterate_4d

Reported by: Algunenano Owned by: strk
Priority: medium Milestone: PostGIS 2.5.0
Component: liblwgeom Version: master
Keywords: Cc:

Description

There is a typo calculating distances in the z-axis.

It appeared as an error as a division by zero

lwgeom_median.c:111:17: runtime error: division by zero

in the test

do_median_test("MULTIPOINT ZM ((0 -1 0 1), (0 0 0 1), (0 1 0 0.5), (0 1 0 0.5))", "POINT (0 0 0)", LW_TRUE, 1000);

Github PR: https://github.com/postgis/postgis/pull/196

Change History (9)

comment:1 by komzpa, 7 years ago

Resolution: fixed
Status: newclosed

In 16341:

Fix bug in iterate_4d.

Patch by Raúl Marín Rodríguez.

Closes #3997
Closes https://github.com/postgis/postgis/pull/196

comment:2 by strk, 7 years ago

Resolution: fixed
Status: closedreopened

Such fixes should come with a testcase. Can you please add one Raul? Or Komzpa ?

comment:3 by Algunenano, 7 years ago

Working on it. It's really tricky you need a really specific geometry. Also the division by zero is still possible.

comment:4 by Algunenano, 7 years ago

PR with the test and removing the possibility of division by zero: https://github.com/postgis/postgis/pull/198

comment:5 by pramsey, 7 years ago

Resolution: fixed
Status: reopenedclosed

In 16366:

lwgeom_median: Avoid division by zero
(Raúl Marín Rodríguez)
Closes #3997
Closes https://github.com/postgis/postgis/pull/198

comment:6 by Algunenano, 7 years ago

Resolution: fixed
Status: closedreopened

As @komzpa commented in the GH issue (https://github.com/postgis/postgis/pull/198#issuecomment-362911760) the ticket introduced here is failing.

Here is the PR with the fix (basically change how the check is done, from comparing coordinates to comparing sum of distances): https://github.com/postgis/postgis/pull/205

comment:7 by Algunenano, 7 years ago

Resolution: fixed
Status: reopenedclosed

comment:8 by algunenano, 6 years ago

In 16579:

Fix bug in lwgeom_median and avoid division by zero

References #3997
Closes https://github.com/postgis/postgis/pull/244

comment:9 by algunenano, 6 years ago

In 16580:

Fix bug in lwgeom_median and avoid division by zero

References #3997
Closes https://github.com/postgis/postgis/pull/245

Note: See TracTickets for help on using tickets.