4
$\begingroup$

I have a list of 2 Polygon objects (see below for the list polys and a visualization). They are all seem valid. Still, when I try to map Area over this list (after a fresh kernel restart), it crashes the kernel. Surprisingly, when mapping over the reversed list (after a fresh kernel restart) it works. For each individual Polygon in the list, Area works as expected.

This bug has kept me busy for a full day already, finally pinpointing it to this MWE.

  • What is going on here?
  • How can this be avoided?
  • What is a 'safe' order of the polygons in a list, in order to map Area over it?

My setup: Macbook Pro, 32 GB RAM, macOS 10.14.6, Mathematica 13.0.

What doesn't work for me (after a fresh kernel start; though, doing this after trying what does work, it also works; maybe a caching issue?):

Map[Area, polys]

The above call silently crashes my kernel (no error message whatsoever).

The following do work (try each after restarting the kernel, e.g. using Quit[]):

Area@polys[[1]]
Area@polys[[2]]
Map[Area, Reverse@polys]

N.B. Polygon 1 has two (almost) collinear edges. In other cases this has never been an issue. Besides, the evaluation of the individual areas is not the issue. The crash is triggered by the order of evaluation.

A visualization of the 2 polygons (they come from a much longer list):

2 polygons

Here is the list of polygons:

polys = {Polygon[{{-12., 20.784609690826528`}, {-16., 
    13.856406460551018`}, {0., 0.}, {-6., 10.392304845413264`}}], 
   Polygon[{{48., 20.784609690826528`}, {42., 31.17691453623979}, {
    36., 20.784609690826528`}}]};
$\endgroup$
9
  • $\begingroup$ Work fine in 13.0.1. {62.3538, 83.1384} {83.1384, 62.3538} $\endgroup$
    – cvgmt
    Mar 12, 2022 at 14:42
  • $\begingroup$ So, is this a known bug? $\endgroup$ Mar 12, 2022 at 14:48
  • $\begingroup$ Works in Mma 13.0.1 on Win 10 $\endgroup$
    – Edmund
    Mar 12, 2022 at 15:15
  • $\begingroup$ Works on a MacBookPro, 32GB RAM, macOS 12.2.1, Mathematica 13.0.0 and 13.0.1 $\endgroup$
    – Bob Hanlon
    Mar 12, 2022 at 15:22
  • 1
    $\begingroup$ After further experimentation, on my system (MacBookPro, 32GB RAM, macOS 12.2.1, MMA 13.0.1), it depends on the order of the evaluations not just the order of the polygons. Evaluating Map[Area, Reverse@polys] first then Map[Area, polys] works fine. However, evaluating Map[Area, Reverse@polys] after Map[Area, polys] (even if Map[Area, Reverse@polys] has already been successfully evaluated) crashes the kernel. Oddly, Area /@ (polys = RandomPolygon[3, 10]) and Area /@ Reverse[polys] work irrespective of order. Recommend that you report this to Wolfram Tech Support. $\endgroup$
    – Bob Hanlon
    Mar 12, 2022 at 16:01

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.