CGAL / cgal

The public CGAL repository, see the README below
https://github.com/CGAL/cgal#readme
Other
4.89k stars 1.38k forks source link

Segfault with recent gcc #8214

Closed sloriot closed 1 month ago

sloriot commented 4 months ago

I create this issue to track a problem observed recently with g++ (GCC) 14.1.1 20240507 (Red Hat 14.1.1-1)

In this test result and probably this one.

I can only be reproduce with optimizers with DNDEBUG defined. gdb says:

Program received signal SIGSEGV, Segmentation fault.
0x0000000000407589 in CGAL::Handle::incref (this=0x7fffffffd850) at /usr/include/c++/14/bits/atomic_base.h:501
501     return __atomic_load_n(&_M_i, int(__m));
(gdb) up
#1  0x00000000004361fc in CGAL::Handle::Handle (this=0x7fffffffd850, x=...) at /CGAL-6.0-I-246/include/CGAL/Handle.h:55
55        incref();
(gdb) 
#2  CGAL::Lazy<CGAL::Interval_nt<false>, __gmp_expr<__mpq_struct [1], __mpq_struct [1]>, CGAL::To_interval<__gmp_expr<__mpq_struct [1], __mpq_struct [1]> > >::Lazy (this=0x7fffffffd850) at /CGAL-6.0-I-246/include/CGAL/Lazy.h:1074
1074    class Lazy : public Handle
(gdb) 
#3  CGAL::Lazy_exact_nt<__gmp_expr<__mpq_struct [1], __mpq_struct [1]> >::Lazy_exact_nt (this=0x7fffffffd850)
    at /CGAL-6.0-I-246/include/CGAL/Lazy_exact_nt.h:359
359 class Lazy_exact_nt
(gdb) 
#4  CGAL::Kd_tree_rectangle<CGAL::Lazy_exact_nt<__gmp_expr<__mpq_struct [1], __mpq_struct [1]> >, CGAL::Dimension_tag<2> >::max_coord (
    this=0x7fffffffd850, i=2) at /CGAL-6.0-I-246/include/CGAL/Kd_tree_rectangle.h:171
171       return upper_[i];

This happens in a non concurrent context, only accessing a FT (Lazy_exact_nt) stored in an array (but copied).

afabri commented 4 months ago

Do we have to boil it down for a gcc bug report?

lrineau commented 4 months ago

I create this issue to track a problem observed recently with g++ (GCC) 14.1.1 20240507 (Red Hat 14.1.1-1)

In this test result and probably this one.

I can only be reproduce with optimizers with DNDEBUG defined. gdb says:

That is the compiler I have on my own laptop (Fedora Linux 40):

[lrineau@fernand]~% rpm -q gcc
gcc-14.1.1-1.fc40.x86_64
[lrineau@fernand]~% gcc --version
gcc (GCC) 14.1.1 20240507 (Red Hat 14.1.1-1)
Copyright (C) 2024 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

So... to reproduce: use that compiler, -DNDEBUG, -O3... and which CMake target have you compiled?

afabri commented 4 months ago

ERROR: execution of test_region_growing_on_point_set_2 in 0.400651 s : SEGFAULT

lrineau commented 4 months ago

I can reproduce, with -O2 -DNDEBUG, with that command:

[lrineau@fernand]~/Git/cgal-master% cmake -DCGAL_ROOT=$PWD -DCMAKE_CXX_FLAGS='-O2 -g -DNDEBUG' -S Shape_detection/test/Shape_detection -B build-Shape_detection && cmake --build build-Shape_detection --clean-first -t test_region_growing_on_point_set_2 -v && /home/lrineau/Git/cgal-master/build-Shape_detection/test_region_growing_on_point_set_2

lrineau commented 1 month ago

This can no longer be reproduced with gcc 14.2.1 from Fedora 40. It was probably a compiler bug. Closing this issue.