Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assertion violation "ray should hit vertex, edge, or facet" in CGAL::convex_decomposition_3 #8447

Open
yuubi opened this issue Aug 30, 2024 · 0 comments

Comments

@yuubi
Copy link

yuubi commented Aug 30, 2024

Issue Details

When trying to call CGAL::convex_decomposition_3 on a certain polyhedron, I receive the following error:

terminate called after throwing an instance of 'CGAL::Assertion_exception'
  what():  CGAL ERROR: assertion violation!
File: ./CGAL/Convex_decomposition_3/Ray_hit_generator.h
Line: 144
Explanation: ray should hit vertex, edge, or facet
Aborted (core dumped)

I have a repro file that's usable with an example program cfom the CGAL distribution.

The geometry originated in an OpenSCAD nightly version, and I first saw the error with the CGAL-5.5.1 that it uses, but the same error happens with "v6.0-beta1.tar.gz", using either the whole polyhedron that OpenSCAD wanted to convex-decompose, or a piece at least 0.1 x 1 x 1 around the ray. (I added a "std::cerr << decomposed_nef" before the call to convex_decomposition_3 so I could repro the problem without involving all of openscad).

I tried building openscad (and CGAL 5.5.1)with -DCGAL_USE_TRACE and put slight effort into correcting the resulting compile errors (if it was obvious how to fix it, i fixed it; otherwise commented out the trace statement). The following is the end of the output from openscad built with a modified copy of 5.5.1:

 shoot ray in SNC -3995611/262144 -8541657/262144 -5593795/262144 -1/1 0/1 0/1
 SNC_point_locator: shooting: -3995611/262144 -8541657/262144 -5593795/262144 -1/1 0/1 0/1
 Objects_along_ray: input ray: -3995611/262144 -8541657/262144 -5593795/262144 -1/1 0/1 0/1
 Objects_around_segment: input segment: -3995611/262144 -8541657/262144 -5593795/262144 -4257755/262144 -8541657/262144 -5593795/262144
 find next intersected cell: segment: -3995611/262144 -8541657/262144 -5593795/262144 -4257755/262144 -8541657/262144 -5593795/262144
 find next intersected cell: node plane: 1/1 0/1 0/1 31912459/2097152, point: -31912459/2097152 0/1 0/1
 find next intersected cell: segment: -3995611/262144 -8541657/262144 -5593795/262144 -4257755/262144 -8541657/262144 -5593795/262144
 find next intersected cell: node plane: 0/1 1/1 0/1 17035459/524288, point: 0/1 -17035459/524288 0/1
 find next intersected cell: segment: -3995611/262144 -8541657/262144 -5593795/262144 -4257755/262144 -8541657/262144 -5593795/262144
 find next intersected cell: node plane: 0/1 0/1 1/1 5576403/262144, point: 0/1 0/1 -5576403/262144
 find next intersected cell: segment: -3995611/262144 -8541657/262144 -5593795/262144 -4257755/262144 -8541657/262144 -5593795/262144
 find next intersected cell: node plane: 1/1 0/1 0/1 3995611/262144, point: -3995611/262144 0/1 0/1
 operator++: prev_segment=(none), segment=-3995611/262144 -8541657/262144 -5593795/262144 -4257755/262144 -8541657/262144 -5593795/262144
 SNC_point_locator: trying vertex on -3995611/262144 -4273339/131072 -5584051/262144
 SNC_point_locator: trying vertex on -3995611/262144 -4273899/131072 -5581877/262144
 SNC_point_locator: trying vertex on -3995611/262144 -4342829/131072 -2849779/131072
 SNC_point_locator: trying vertex on -3995611/262144 -8536091/262144 -5604441/262144
 SNC_point_locator: trying vertex on -3995611/262144 -8541657/262144 -5593795/262144
 SNC_point_locator: trying vertex on -3995611/262144 -4270321/131072 -5595737/262144
 SNC_point_locator: trying vertex on -3995611/262144 -8535167/262144 -11212375/524288
 SNC_point_locator: trying vertex on -3995611/262144 -533189/16384 -87719/4096
 SNC_point_locator: trying vertex on -3995611/262144 -8530177/262144 -1403901/65536
 SNC_point_locator: trying vertex on -3995611/262144 -532585/16384 -11264275/524288
 SNC_point_locator: trying vertex on -3995611/262144 -8518077/262144 -2819163/131072
 SNC_point_locator: trying vertex on -3995611/262144 -2130523/65536 -5630757/262144
 SNC_point_locator: trying vertex on -3995611/262144 -8525599/262144 -5624187/262144
 SNC_point_locator: trying vertex on -3995611/262144 -4263191/131072 -5622721/262144
 SNC_point_locator: trying edge on -3995611/262144 -8525599/262144 -5624187/262144 -3995611/262144 -2130523/65536 -5630757/262144
 SNC_point_locator: trying edge on -3995611/262144 -8525599/262144 -5624187/262144 -3995611/262144 -4273339/131072 -5584051/262144
 SNC_point_locator: trying edge on -3995611/262144 -8525599/262144 -5624187/262144 -3995611/262144 -4263191/131072 -5622721/262144
 SNC_point_locator: trying edge on -3995611/262144 -8535167/262144 -11212375/524288 -3995611/262144 -8536091/262144 -5604441/262144
 SNC_point_locator: trying edge on -3995611/262144 -8535167/262144 -11212375/524288 -3995611/262144 -533189/16384 -87719/4096
 SNC_point_locator: trying edge on -3995611/262144 -4273339/131072 -5584051/262144 -3995611/262144 -8541657/262144 -5593795/262144
 SNC_point_locator: trying edge on -3995611/262144 -4273339/131072 -5584051/262144 -3995611/262144 -4273899/131072 -5581877/262144
 SNC_point_locator: trying edge on -3995611/262144 -4342829/131072 -2718707/131072 -3995611/262144 -4342829/131072 -2849779/131072
 SNC_point_locator: trying edge on -3995611/262144 -4258691/131072 -2819829/131072 -3995611/262144 -8518077/262144 -2819163/131072
 SNC_point_locator: trying edge on -3995611/262144 -8518077/262144 -2819163/131072 -3995611/262144 -532585/16384 -11264275/524288
 SNC_point_locator: trying edge on -3995611/262144 -532585/16384 -11264275/524288 -3995611/262144 -2130523/65536 -5630757/262144
 SNC_point_locator: trying edge on -3995611/262144 -4263191/131072 -5622721/262144 -3995611/262144 -8530177/262144 -1403901/65536
 SNC_point_locator: trying edge on -3995611/262144 -8530177/262144 -1403901/65536 -3995611/262144 -533189/16384 -87719/4096
 SNC_point_locator: trying edge on -3995611/262144 -4270321/131072 -5595737/262144 -3995611/262144 -8536091/262144 -5604441/262144
 SNC_point_locator: trying edge on -3995611/262144 -4270321/131072 -5595737/262144 -3995611/262144 -8541657/262144 -5593795/262144
 SNC_point_locator: trying edge on -3995611/262144 -4273899/131072 -5581877/262144 -3995611/262144 -2138337/65536 -5570929/262144
 SNC_point_locator: trying edge on -3995611/262144 -4342829/131072 -2849779/131072 -3995611/262144 -4244827/131072 -2849779/131072
 SNC_point_locator: trying facet with on plane -9141/68719476736 0/1 0/1 -36523880151/18014398509481984 with point on -3995611/262144 0/1 0/1
 -> Intersection facet - ray
 -> facet's plane: -9141/68719476736 0/1 0/1 -36523880151/18014398509481984
 -> a point on the plane: -3995611/262144 0/1 0/1
 -> ray: -3995611/262144 -8541657/262144 -5593795/262144 -1/1 0/1 0/1
 SNC_point_locator: trying facet with on plane -17755877/34359738368 0/1 0/1 -70945577455847/9007199254740992 with point on -3995611/262144 0/1 0/1
 -> Intersection facet - ray
 -> facet's plane: -17755877/34359738368 0/1 0/1 -70945577455847/9007199254740992
 -> a point on the plane: -3995611/262144 0/1 0/1
 -> ray: -3995611/262144 -8541657/262144 -5593795/262144 -1/1 0/1 0/1
terminate called after throwing an instance of 'CGAL::Assertion_exception'
  what():  CGAL ERROR: assertion violation!
File: /home/yuubi/openscad_deps/include/CGAL/Convex_decomposition_3/Ray_hit_generator.h
Line: 143
Explanation: ray should hit vertex, edge, or facet

The facets tried lie in a plane containing the starting point of the ray (conveniently the normal to the plane is the x axis), and I managed to convince myself while poking around the code that this doesn't count as a hit; maybe this is relevant.

The following gdb session is with 6.0beta1 (no edits to make it build, just the .h files as shipped):

(gdb) run < convex-decomp-fail-assert-ray-should-hit-1x1.txt
Starting program: /home/yuubi/test-case-reduction/mod-list_of_convex_parts < convex-decomp-fail-assert-ray-should-hit-1x1.txt

This GDB supports auto-downloading debuginfo from the following URLs:
  <https://debuginfod.ubuntu.com>
Enable debuginfod for this session? (y or [n])
Debuginfod has been disabled.
To make this setting permanent, add 'set debuginfod enabled off' to .gdbinit.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
is_valid: 1
is_simple: 1
terminate called after throwing an instance of 'CGAL::Assertion_exception'
  what():  CGAL ERROR: assertion violation!
File: ./CGAL/Convex_decomposition_3/Ray_hit_generator.h
Line: 144
Explanation: ray should hit vertex, edge, or facet

Program received signal SIGABRT, Aborted.
__pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:44
44      ./nptl/pthread_kill.c: No such file or directory.
(gdb) bt
#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:44
#1  __pthread_kill_internal (signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:78
#2  __GI___pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3  0x00007ffff78428e6 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4  0x00007ffff78268b7 in __GI_abort () at ./stdlib/abort.c:79
#5  0x00007ffff7ca4f06 in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
#6  0x00007ffff7cb6e6c in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
#7  0x00007ffff7cb6ed7 in std::terminate() () from /lib/x86_64-linux-gnu/libstdc++.so.6
#8  0x00007ffff7cb7138 in __cxa_throw () from /lib/x86_64-linux-gnu/libstdc++.so.6
#9  0x0000555555567ae5 in CGAL::assertion_fail (expr=0x5555556bf022 "", file=0x5555556c3738 "./CGAL/Convex_decomposition_3/Ray_hit_generator.h", line=144,
    msg=0x5555556c3710 "ray should hit vertex, edge, or facet") at ./CGAL/assertions_impl.h:173
#10 0x0000555555659b95 in CGAL::Ray_hit_generator<CGAL::Nef_polyhedron_3<CGAL::Epeck, CGAL::SNC_indexed_items, bool> >::create_vertex_on_first_hit (this=0x7fffffffe670,
    r=...) at ./CGAL/Convex_decomposition_3/Ray_hit_generator.h:144
#11 0x0000555555648e59 in CGAL::Ray_hit_generator2<CGAL::Nef_polyhedron_3<CGAL::Epeck, CGAL::SNC_indexed_items, bool> >::operator() (this=0x7fffffffe670, sncpl=...)
    at ./CGAL/Convex_decomposition_3/Ray_hit_generator2.h:85
#12 0x0000555555592f9e in CGAL::Nef_polyhedron_3<CGAL::Epeck, CGAL::SNC_indexed_items, bool>::delegate (this=0x7fffffffe7e0, modifier=..., compute_external=false,
    do_simplify=false) at ./CGAL/Nef_polyhedron_3.h:1086
#13 0x00005555555882c4 in CGAL::convex_decomposition_3<CGAL::Nef_polyhedron_3<CGAL::Epeck, CGAL::SNC_indexed_items, bool> > (N=...) at ./CGAL/convex_decomposition_3.h:115
#14 0x0000555555564fca in main () at mod-list_of_convex_parts.cpp:22

Source Code

To try to ensure the problem wasn't a bad polyhedron, I modified list_of_convex_parts.cpp by adding the following lines before the call to CGAL::convex_decomposition_3:

  std::cout << "is_valid: " << N.is_valid() << std::endl;                             |
  std::cout << "is_simple: " << N.is_simple() << std::endl;                           |

Both results are 1.

Environment

  • Operating system (Windows/Mac/Linux, 32/64 bits): Ubuntu 23.10, x86_64
  • Compiler: gcc version 13.2.0 (Ubuntu 13.2.0-4ubuntu3)
  • Release or debug mode: both at various times with openscad and 5.5.1; g++ -g for the example program and 6.0beta1
  • Specific flags used (if any):
  • CGAL version: 5.5.1 and 6.0beta1
  • Boost version: 1.81 (openscad builds it) with cgal-5.5.1; 1.74 from ubuntu with cgan 6.0beta1
  • Other libraries versions if used (Eigen, TBB, etc.): openscad deps available if you care (there are many, and can repro without openscad);with cgal-6.0beta1, libmpfr6 4.2.1-1 and libgmp10 2:6.3.0+dfsg-2ubuntu4 ubuntu packages
    convex-decomp-fail-assert-ray-should-hit-1x1.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant