Subject: CGAL users discussion list
List archive
- From: Bernhard Kornberger <>
- To:
- Subject: [cgal-discuss] Multithreading and do_intersect(..)
- Date: Sun, 29 Jan 2012 02:08:55 +0100
Hello!
I use CGAL 3.9 and my multithreaded code fails occasionally. Now I'd
like to ask if the respective part of CGAL is thread safe? Here is a
code snippet:
***
#define CGAL_HAS_THREADS
typedef CGAL::Exact_predicates_exact_constructions_kernel K;
class ESegment_3 : public K::Segment_3
{
...
}
EPoint_3* ESegment_3::splitLowPoint(const K::Line_3& axLin)
{
if(CGAL::do_intersect(*this,axLin)) // Line 582
{
}
}
***
There are 8 std::vector<ESegment*>, and they are treated by 8
separate threads. Each ESegment is unique. Here is a backtrace,
created with gdb:
***
[Switching to Thread 0x7fffe3fff700 (LWP 28117)]
CGAL::Lazy_rep_1<CGAL::Object_cast<CGAL::Point_3<CGAL::Simple_cartesian<CGAL::Interval_nt<false> > > >, CGAL::Object_cast<CGAL::Point_3<CGAL::Simple_cartesian<CGAL::Gmpq> > >, 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::Lazy<CGAL::Object, CGAL::Object, CGAL::Gmpq, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::NT_converter<CGAL::Gmpq, CGAL::Interval_nt<false> > > > >::update_exact (
this=0x99dcfd0) at /opt/CGAL39_ALL/include/CGAL/Lazy.h:328
328 this->et = new ET(ec()(CGAL::exact(l1_)));
(gdb) backtrace
#0 CGAL::Lazy_rep_1<CGAL::Object_cast<CGAL::Point_3<CGAL::Simple_cartesian<CGAL::Interval_nt<false> > > >, CGAL::Object_cast<CGAL::Point_3<CGAL::Simple_cartesian<CGAL::Gmpq> > >, 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::Lazy<CGAL::Object, CGAL::Object, CGAL::Gmpq, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::NT_converter<CGAL::Gmpq, CGAL::Interval_nt<false> > > > >::update_exact (
this=0x99dcfd0) at /opt/CGAL39_ALL/include/CGAL/Lazy.h:328
#1 0x00000000004ae48a in exact (this=0x99dd350) at /opt/CGAL39_ALL/include/CGAL/Lazy.h:239
#2 exact (this=0x99dd350) at /opt/CGAL39_ALL/include/CGAL/Lazy.h:1148
#3 exact<CGAL::Point_3<CGAL::Simple_cartesian<CGAL::Interval_nt<false> > >, CGAL::Point_3<CGAL::Simple_cartesian<CGAL::Gmpq> >, CGAL::Gmpq, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> > > > (this=0x99dd350) at /opt/CGAL39_ALL/include/CGAL/Lazy.h:71
#4 CGAL::Lazy_rep_1<CGAL::CartesianKernelFunctors::Compute_z_3<CGAL::Simple_cartesian<CGAL::Interval_nt<false> > >, CGAL::CartesianKernelFunctors::Compute_z_3<CGAL::Simple_cartesian<CGAL::Gmpq> >, CGAL::To_interval<CGAL::Gmpq>, CGAL::Point_3<CGAL::Epeck> >::update_exact (this=0x99dd350) at /opt/CGAL39_ALL/include/CGAL/Lazy.h:328
#5 0x00000000004d862a in exact (this=0x99dddd0) at /opt/CGAL39_ALL/include/CGAL/Lazy.h:239
#6 exact (this=0x99dddd0) at /opt/CGAL39_ALL/include/CGAL/Lazy.h:1148
#7 exact<CGAL::Interval_nt<false>, CGAL::Gmpq, CGAL::Lazy_exact_nt<CGAL::Gmpq>, CGAL::To_interval<CGAL::Gmpq> > (this=0x99dddd0) at /opt/CGAL39_ALL/include/CGAL/Lazy.h:71
#8 CGAL::Lazy_rep_4<CGAL::CartesianKernelFunctors::Construct_point_3<CGAL::Simple_cartesian<CGAL::Interval_nt<false> > >, CGAL::CartesianKernelFunctors::Construct_point_3<CGAL::Simple_cartesian<CGAL::Gmpq> >, 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::Return_base_tag, CGAL::Lazy_exact_nt<CGAL::Gmpq>, CGAL::Lazy_exact_nt<CGAL::Gmpq>, CGAL::Lazy_exact_nt<CGAL::Gmpq> >::update_exact (this=0x99dddd0) at /opt/CGAL39_ALL/include/CGAL/Lazy.h:488
#9 0x0000000000509cea in exact (this=0x99de380) at /opt/CGAL39_ALL/include/CGAL/Lazy.h:239
#10 exact (this=0x99de380) at /opt/CGAL39_ALL/include/CGAL/Lazy.h:1148
#11 exact<CGAL::Point_3<CGAL::Simple_cartesian<CGAL::Interval_nt<false> > >, CGAL::Point_3<CGAL::Simple_cartesian<CGAL::Gmpq> >, CGAL::Gmpq, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> > > > (this=0x99de380) at /opt/CGAL39_ALL/include/CGAL/Lazy.h:71
#12 CGAL::Lazy_rep_3<CGAL::CommonKernelFunctors::Construct_segment_3<CGAL::Simple_cartesian<CGAL::Interval_nt<false> > >, CGAL::CommonKernelFunctors::Construct_segment_3<CGAL::Simple_cartesian<CGAL::Gmpq> >, 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::Return_base_tag, CGAL::Point_3<CGAL::Epeck>, CGAL::Point_3<CGAL::Epeck> >::update_exact (this=0x99de380) at /opt/CGAL39_ALL/include/CGAL/Lazy.h:428
#13 0x00000000005133e1 in exact (this=<value optimized out>, a1=..., a2=<value optimized out>) at /opt/CGAL39_ALL/include/CGAL/Lazy.h:239
#14 exact (this=<value optimized out>, a1=..., a2=<value optimized out>) at /opt/CGAL39_ALL/include/CGAL/Lazy.h:1148
#15 operator()<CGAL::Segment_3<CGAL::Epeck> > (this=<value optimized out>, a1=..., a2=<value optimized out>) at /opt/CGAL39_ALL/include/CGAL/Lazy.h:869
#16 CGAL::Filtered_predicate<CGAL::CommonKernelFunctors::Do_intersect_3<CGAL::Simple_cartesian<CGAL::Gmpq> >, CGAL::CommonKernelFunctors::Do_intersect_3<CGAL::Simple_cartesian<CGAL::Interval_nt<false> > >, CGAL::Exact_converter<CGAL::Epeck, CGAL::Simple_cartesian<CGAL::Gmpq> >, CGAL::Approx_converter<CGAL::Epeck, CGAL::Simple_cartesian<CGAL::Interval_nt<false> > >, true>::operator()<CGAL::Line_3<CGAL::Epeck>, CGAL::Segment_3<CGAL::Epeck> > (this=<value optimized out>, a1=..., a2=<value optimized out>) at /opt/CGAL39_ALL/include/CGAL/Filtered_predicate.h:217
#17 0x0000000000505858 in do_intersect<CGAL::Epeck> (this=0x994d7b0, pData=..., axLin=...) at /opt/CGAL39_ALL/include/CGAL/Intersections_3/intersection_3_1_impl.h:1596
#18 do_intersect<CGAL::Epeck> (this=0x994d7b0, pData=..., axLin=...) at /opt/CGAL39_ALL/include/CGAL/intersection_3_1.h:329
#19 GEOM_RCT::ESegment_3::splitLowPoint (this=0x994d7b0, pData=..., axLin=...) at /home/bernd/openSource/windev64/rctLib/ESegment_3.cpp:582
(gdb) info threads
9 Thread 0x7fffe37fe700 (LWP 28118) __mcount_internal (frompc=5153075, selfpc=4838414) at mcount.c:72
* 8 Thread 0x7fffe3fff700 (LWP 28117) CGAL::Lazy_rep_1<CGAL::Object_cast<CGAL::Point_3<CGAL::Simple_cartesian<CGAL::Interval_nt<false> > > >, CGAL::Object_cast<CGAL::Point_3<CGAL::Simple_cartesian<CGAL::Gmpq> > >, 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::Lazy<CGAL::Object, CGAL::Object, CGAL::Gmpq, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::NT_converter<CGAL::Gmpq, CGAL::Interval_nt<false> > > > >::update_exact (this=0x99dcfd0) at /opt/CGAL39_ALL/include/CGAL/Lazy.h:328
6 Thread 0x7ffff13e1700 (LWP 28115) 0x00007ffff773b1b6 in __gmpz_divexact () from /usr/lib/libgmp.so.3
5 Thread 0x7ffff1be2700 (LWP 28114) 0x00007ffff774d1a0 in __gmpn_mul_1 () from /usr/lib/libgmp.so.3
4 Thread 0x7ffff23e3700 (LWP 28113) __strlen_sse42 () at ../sysdeps/x86_64/multiarch/strlen-sse4.S:33
3 Thread 0x7ffff2be4700 (LWP 28112) 0x00007ffff775a2f5 in __gmpn_gcd_1 () from /usr/lib/libgmp.so.3
2 Thread 0x7ffff33e5700 (LWP 28111) fesetround (round=0) at ../sysdeps/x86_64/fpu/fesetround.c:41
1 Thread 0x7ffff7fbd740 (LWP 28107) pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:162
***
I have tried to create a minimal example with randomly created
segments, but that worked. Any hints are appreciated, thank you!
best regards
- [cgal-discuss] Multithreading and do_intersect(..), Bernhard Kornberger, 01/29/2012
- Re: [cgal-discuss] Multithreading and do_intersect(..), Marc Glisse, 01/29/2012
- Re: [cgal-discuss] Multithreading and do_intersect(..), Bernhard Kornberger, 01/29/2012
- Re: [cgal-discuss] Multithreading and do_intersect(..), Marc Glisse, 01/29/2012
- Re: [cgal-discuss] Multithreading and do_intersect(..), Bernhard Kornberger, 01/29/2012
- Re: [cgal-discuss] Multithreading and do_intersect(..), Marc Glisse, 01/29/2012
Archive powered by MHonArc 2.6.16.