title: CGAL Segmentation Fault using CGAL::create_offset_polygons_2
body: <p>I'm trying the CGAL library. Specifically the straight skeleton package.
  I'm getting a segmentation fault when executing one of the simple examples in the documentation and I don't know if it is a possible bug or I am doing something wrong. I appreciate any help. Thanks in advance.</p>
  
  <p>This is the example:</p>
  
  <pre><code>#include &lt;vector&gt;
  #include &lt;boost/shared_ptr.hpp&gt;
  #include &lt;CGAL/Exact_predicates_inexact_constructions_kernel.h&gt;
  #include &lt;CGAL/Polygon_2.h&gt;
  #include &lt;CGAL/create_offset_polygons_2.h&gt;
  //#include "print.h"
  
  typedef CGAL::Exact_predicates_inexact_constructions_kernel K ;
  typedef K::Point_2                   Point ;
  typedef CGAL::Polygon_2&lt;K&gt;           Polygon_2 ;
  typedef CGAL::Straight_skeleton_2&lt;K&gt; Ss ;
  typedef boost::shared_ptr&lt;Polygon_2&gt; PolygonPtr ;
  typedef boost::shared_ptr&lt;Ss&gt; SsPtr ;
  typedef std::vector&lt;PolygonPtr&gt; PolygonPtrVector ;
  
  int main()
  {
    Polygon_2 poly ;
  
    poly.push_back( Point(-1,-1) ) ;
    poly.push_back( Point(0,-12) ) ;
    poly.push_back( Point(1,-1) ) ;
    poly.push_back( Point(12,0) ) ;
    poly.push_back( Point(1,1) ) ;
    poly.push_back( Point(0,12) ) ;
    poly.push_back( Point(-1,1) ) ;
    poly.push_back( Point(-12,0) ) ;
  
    SsPtr ss = CGAL::create_interior_straight_skeleton_2(poly);
  
    double lOffset = 1 ;
  
    PolygonPtrVector offset_polygons = CGAL::create_offset_polygons_2&lt;Polygon_2&gt;(lOffset,*ss);
  
    //print_polygons(offset_polygons);
  
    return 0;
  }
  </code></pre>
  
  <p>The segmentation fault happens when the program ends, in one of the destructors, according to the debugger.
  If I comment the line with <code>create_offset_polygons_2</code> the program exits normally.
  The debugger says that the error happens in the file <code>Handle.h</code>in line 62:</p>
  
  <pre><code>60  ~Handle()
  61  {
  62  if ( PTR &amp;&amp; (--PTR-&gt;count == 0))
  63      delete PTR;
  64  }
  </code></pre>
  
  <p>This is the stack trace:</p>
  
  <pre><code>1  CGAL::Handle::~Handle                                                                                                                                                                                                                                                                                                      Handle.h 62  0x41d3c4   
  2  CGAL::Lazy&lt;CGAL::Line_2&lt;CGAL::Simple_cartesian&lt;CGAL::Interval_nt&lt;false&gt;&gt;&gt;, CGAL::Line_2&lt;CGAL::Simple_cartesian&lt;CGAL::Gmpq&gt;&gt;, CGAL::Gmpq, CGAL::Cartesian_converter&lt;CGAL::Simple_cartesian&lt;CGAL::Gmpq&gt;, CGAL::Simple_cartesian&lt;CGAL::Interval_nt&lt;false&gt;&gt;, CGAL::NT_converter&lt;CGAL::Gmpq, CGAL::Interval_nt&lt;false&gt;&gt;&gt;&gt;::~Lazy Lazy.h   712 0x41ccbf   
  3  libstdc++-6!_ZN11__gnu_debug30_Safe_unordered_container_base7_M_swapERS0_                                                                                                                                                                                                                                                               0x6fe5a72a 
  4  libstdc++-6!_ZN11__gnu_debug30_Safe_unordered_container_base7_M_swapERS0_                                                                                                                                                                                                                                                               0x6fe5a780 
  5  ??                                                                                                                                                                                                                                                                                                                                      0x6fe411b4 
  6  ??                                                                                                                                                                                                                                                                                                                                      0x6fe41325 
  7  ??                                                                                                                                                                                                                                                                                                                                      0x6fe41433 
  8  ntdll!RtlDecompressBuffer                                                                                                                                                                                                                                                                                                               0x77eae58e 
  9  ntdll!LdrShutdownThread                                                                                                                                                                                                                                                                                                                 0x77e80e46 
  10 ??                                                                                                                                                                                                                                                                                                                                      0x6fe41410 
  11 ntdll!LdrShutdownProcess                                                                                                                                                                                                                                                                                                                0x77e6a862 
  12 ??                                                                                                                                                                                                                                                                                                                                                 
  </code></pre>
  
  <p>I'm using:</p>
  
  <ul>
  <li>MinGW 32 with gcc 5.3.0 (the one that comes with Qt 5.8)</li>
  <li>CGAL version 4.9.1 with CGAL_HEADER_ONLY option</li>
  <li>Boost version 1.64.0</li>
  <li>libgmp version 6.1.2</li>
  <li>libmpfr version 3.1.5</li>
  <li>The third party libraries are compiled with the same MinGW</li>
  </ul>