Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] Segment_2 compare segmentation fault

Subject: CGAL users discussion list

List archive

[cgal-discuss] Segment_2 compare segmentation fault


Chronological Thread 
  • From: Sterpa <>
  • To:
  • Subject: [cgal-discuss] Segment_2 compare segmentation fault
  • Date: Tue, 20 Oct 2009 21:51:07 +0200 (CEST)

This is my code:

vector<Segment_2> getBCorridors(vector<Segment_2> V) {
vector<Segment_2> result;

for(int i = 0;i < V.size()-1;i++) {
if(V[i] == V[i+1]) continue;
Point_2 p_a1 = V[i].source();
Point_2 p_a2 = V[i].target();
if(p_a1.y() < p_a2.y()) {
p_a1 = p_a2;
p_a2 = V[i].source();
}
Point_2 p_b1 = V[i+1].source();
Point_2 p_b2 = V[i+1].target();
if(p_b1.y() < p_b2.y()) {
p_b1 = p_b2;
p_b2 = V[i+1].source();
}
Line_2 h_a = Line_2(p_a1, p_b1);
Line_2 h_b = Line_2(p_a2, p_b2);
if(CGAL::do_intersect(h_a, h_b)) {
Point_2 x_ab =
CGAL::object_cast<Point_2>(CGAL::intersection(h_a, h_b));
NT x = -1/x_ab.x();
if(p_a1.x() <= x && x <= p_b1.x()) {
Point_2 p1 = Point_2(x, h_a.y_at_x(x));
Point_2 p2 = Point_2(x, h_b.y_at_x(x));
result.push_back(Segment_2(p1, p2));
}
}
}

return result;
}

And the following is the error I get:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb7c8f6d0 (LWP 12482)]
0x080ea7fc in
CGAL::Filtered_predicate<CGAL::CommonKernelFunctors::Equal_2<CGAL::Simple_cartesian<CGAL::Gmpq>
>,
CGAL::CommonKernelFunctors::Equal_2<CGAL::Simple_cartesian<CGAL::Interval_nt<false>
> >,
CGAL::Exact_converter<CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>,
CGAL::Simple_cartesian<CGAL::Interval_nt<false> >,
CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>,
CGAL::Simple_cartesian<CGAL::Interval_nt<false> >,
CGAL::NT_converter<CGAL::Gmpq, CGAL::Interval_nt<false> > > >,
CGAL::Simple_cartesian<CGAL::Gmpq> >,
CGAL::Approx_converter<CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>,
CGAL::Simple_cartesian<CGAL::Interval_nt<false> >,
CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>,
CGAL::Simple_cartesian<CGAL::Interval_nt<false> >,
CGAL::NT_converter<CGAL::Gmpq, CGAL::Interval_nt<false> > > >,
CGAL::Simple_cartesian<CGAL::Interval_nt<false> > >,
true>::operator()<CGAL::Segment_2<CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>,
CGAL::Simple_cartesian<CGAL::Interval_nt<false> >,
CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>,
CGAL::Simple_cartesian<CGAL::Interval_nt<false> >,
CGAL::NT_converter<CGAL::Gmpq, CGAL::Interval_nt<false> > > > >,
CGAL::Segment_2<CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>,
CGAL::Simple_cartesian<CGAL::Interval_nt<false> >,
CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>,
CGAL::Simple_cartesian<CGAL::Interval_nt<false> >,
CGAL::NT_converter<CGAL::Gmpq, CGAL::Interval_nt<false> > > > > >
(this=0xbf87dfa4,
a1=@0x0,

a2=@0x4)
at /usr/local/include/CGAL/Lazy.h:1161
1161 Self_rep * ptr() const { return (Self_rep*) PTR; }

This is the backtrace from gdb:

#0 0x080ea7fc in
CGAL::Filtered_predicate<CGAL::CommonKernelFunctors::Equal_2<CGAL::Simple_cartesian<CGAL::Gmpq>
>,
CGAL::CommonKernelFunctors::Equal_2<CGAL::Simple_cartesian<CGAL::Interval_nt<false>
> >,
CGAL::Exact_converter<CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>,
CGAL::Simple_cartesian<CGAL::Interval_nt<false> >,
CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>,
CGAL::Simple_cartesian<CGAL::Interval_nt<false> >,
CGAL::NT_converter<CGAL::Gmpq, CGAL::Interval_nt<false> > > >,
CGAL::Simple_cartesian<CGAL::Gmpq> >,
CGAL::Approx_converter<CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>,
CGAL::Simple_cartesian<CGAL::Interval_nt<false> >,
CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>,
CGAL::Simple_cartesian<CGAL::Interval_nt<false> >,
CGAL::NT_converter<CGAL::Gmpq, CGAL::Interval_nt<false> > > >,
CGAL::Simple_cartesian<CGAL::Interval_nt<false> > >,
true>::operator()<CGAL::Segment_2<CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>,
CGAL::Simple_cartesian<CGAL::Interval_nt<false> >,
CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>,
CGAL::Simple_cartesian<CGAL::Interval_nt<false> >,
CGAL::NT_converter<CGAL::Gmpq, CGAL::Interval_nt<false> > > > >,
CGAL::Segment_2<CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>,
CGAL::Simple_cartesian<CGAL::Interval_nt<false> >,
CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>,
CGAL::Simple_cartesian<CGAL::Interval_nt<false> >,
CGAL::NT_converter<CGAL::Gmpq, CGAL::Interval_nt<false> > > > > >
(this=0xbf87dfa4,
a1=@0x0,

a2=@0x4)
at /usr/local/include/CGAL/Lazy.h:1161
#1 0x080cece8 in getBCorridors (V=

{<std::_Vector_base<CGAL::Segment_2<CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>,
CGAL::Simple_cartesian<CGAL::Interval_nt<false> >,
CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>,
CGAL::Simple_cartesian<CGAL::Interval_nt<false> >,
CGAL::NT_converter<CGAL::Gmpq, CGAL::Interval_nt<false> > > > >,
std::allocator<CGAL::Segment_2<CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>,
CGAL::Simple_cartesian<CGAL::Interval_nt<false> >,
CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>,
CGAL::Simple_cartesian<CGAL::Interval_nt<false> >,
CGAL::NT_converter<CGAL::Gmpq, CGAL::Interval_nt<false> > > > > > >> =
{_M_impl
=
{<std::allocator<CGAL::Segment_2<CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>,
CGAL::Simple_cartesian<CGAL::Interval_nt<false> >,
CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>,
CGAL::Simple_cartesian<CGAL::Interval_nt<false> >,
CGAL::NT_converter<CGAL::Gmpq, CGAL::Interval_nt<false> > > > > >> =
{<__gnu_cxx::new_allocator<CGAL::Segment_2<CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>,
CGAL::Simple_cartesian<CGAL::Interval_nt<false> >,
CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>,
CGAL::Simple_cartesian<CGAL::Interval_nt<false> >,
CGAL::NT_converter<CGAL::Gmpq, CGAL::Interval_nt<false> > > > > >> = {<No data
fields>}, <No data fields>}, _M_start = 0xbf87e1c8, _M_finish = 0x0,
_M_end_of_storage = 0x0}}, <No data fields>}) at
/usr/local/include/CGAL/Segment_2.h:134
#2 0x080d5bd8 in algorithm_2 (lines=

{<std::_Vector_base<CGAL::Line_2<CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>,
CGAL::Simple_cartesian<CGAL::Interval_nt<false> >,
CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>,
CGAL::Simple_cartesian<CGAL::Interval_nt<false> >,
CGAL::NT_converter<CGAL::Gmpq, CGAL::Interval_nt<false> > > > >,
std::allocator<CGAL::Line_2<CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>,
CGAL::Simple_cartesian<CGAL::Interval_nt<false> >,
CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>,
CGAL::Simple_cartesian<CGAL::Interval_nt<false> >,
CGAL::NT_converter<CGAL::Gmpq, CGAL::Interval_nt<false> > > > > > >> =
{_M_impl
=
{<std::allocator<CGAL::Line_2<CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>,
CGAL::Simple_cartesian<CGAL::Interval_nt<false> >,
CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>,
CGAL::Simple_cartesian<CGAL::Interval_nt<false> >,
CGAL::NT_converter<CGAL::Gmpq, CGAL::Interval_nt<false> > > > > >> =
{<__gnu_cxx::new_allocator<CGAL::Line_2<CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>,
CGAL::Simple_cartesian<CGAL::Interval_nt<false> >,
CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>,
CGAL::Simple_cartesian<CGAL::Interval_nt<false> >,
CGAL::NT_converter<CGAL::Gmpq, CGAL::Interval_nt<false> > > > > >> = {<No data
fields>}, <No data fields>}, _M_start = 0xbf87e2f4, _M_finish = 0xbf87e3b4,
_M_end_of_storage = 0xbf87e090}}, <No data fields>}, k=-2) at
/home/marco/Desktop/cgal.project/arrangement.cpp:259
#3 0x080d7069 in main (argc=Cannot access memory at address 0x0
) at /home/marco/Desktop/cgal.project/arrangement.cpp:224

I'm using CGAL 3.5 on Ubuntu, is there anyone who can point me to the
solution?
I really need to solve this in few days. Thanks in advance, best regards.


  • [cgal-discuss] Segment_2 compare segmentation fault, Sterpa, 10/20/2009

Archive powered by MHonArc 2.6.16.

Top of Page