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

segfault during preprocessing (swapping) #75

Open
MariusCausemann opened this issue Aug 14, 2024 · 4 comments
Open

segfault during preprocessing (swapping) #75

MariusCausemann opened this issue Aug 14, 2024 · 4 comments

Comments

@MariusCausemann
Copy link

Hi,
first of all, thanks for this great meshing tool! In most cases, fTetWild works very well for me, but recently, I encountered a segfault in the preprocessing stage. It is quite a complex mesh (consisting of ~200 separate surfaces) and unfortunately, I can reproduce using a simpler example. If necessary, I can provide the input files.

Here is fTetWild output:

6 10 12 2 9 5 16 13 0 14 4 1 19 8 18 11 3 17 15 7 
TBB threads 7
[2024-08-14 10:07:12.503] [geogram] [info] Loading file results/cortical_mm3/surfaces/size+20000/dx+20_ncells+200/roi.ply...
[2024-08-14 10:07:12.504] [geogram] [info] (FP64) nb_v:8 nb_e:0 nb_f:6 nb_b:0 tri:0 dim:3
[2024-08-14 10:07:12.504] [geogram] [info] Attributes on vertices: point[3]
[2024-08-14 10:07:12.505] [geogram] [info] Loading file results/cortical_mm3/surfaces/size+20000/dx+20_ncells+200/2.ply...
[2024-08-14 10:07:12.521] [geogram] [info] (FP64) nb_v:20838 nb_e:0 nb_f:41650 nb_b:19 tri:1 dim:3
[2024-08-14 10:07:12.521] [geogram] [info] Attributes on vertices: point[3]
[2024-08-14 10:07:12.522] [geogram] [info] Loading file results/cortical_mm3/surfaces/size+20000/dx+20_ncells+200/3.ply...
[2024-08-14 10:07:12.533] [geogram] [info] (FP64) nb_v:16564 nb_e:0 nb_f:33120 nb_b:4 tri:1 dim:3
[2024-08-14 10:07:12.533] [geogram] [info] Attributes on vertices: point[3]
[2024-08-14 10:07:12.533] [geogram] [info] Loading file results/cortical_mm3/surfaces/size+20000/dx+20_ncells+200/4.ply...
[2024-08-14 10:07:12.547] [geogram] [info] (FP64) nb_v:24800 nb_e:0 nb_f:49587 nb_b:228 tri:1 dim:3
[2024-08-14 10:07:12.547] [geogram] [info] Attributes on vertices: point[3]
[2024-08-14 10:07:12.548] [geogram] [info] Loading file results/cortical_mm3/surfaces/size+20000/dx+20_ncells+200/5.ply...
[2024-08-14 10:07:12.558] [geogram] [info] (FP64) nb_v:19343 nb_e:0 nb_f:38678 nb_b:13 tri:1 dim:3
[2024-08-14 10:07:12.559] [geogram] [info] Attributes on vertices: point[3]
[2024-08-14 10:07:12.559] [geogram] [info] Loading file results/cortical_mm3/surfaces/size+20000/dx+20_ncells+200/6.ply...
[2024-08-14 10:07:12.586] [geogram] [info] (FP64) nb_v:13240 nb_e:0 nb_f:26475 nb_b:2 tri:1 dim:3
[2024-08-14 10:07:12.586] [geogram] [info] Attributes on vertices: point[3]
...

bbox_diag_length = 34575
ideal_edge_length = 1728.75
stage = 2
eps_input = 18.2627
eps = 10.1101
eps_simplification = 8.08806
eps_coplanar = 0.034575
dd = 12.1752
dd_simplification = 9.74013
[2024-08-14 10:07:59.389] [float-tetwild] [info] remove duplicates: 
[2024-08-14 10:07:59.389] [float-tetwild] [info] #v: 10072385 -> 10072385
[2024-08-14 10:07:59.389] [float-tetwild] [info] #f: 20149242 -> 20149242
[2024-08-14 10:07:59.801] [float-tetwild] [info] remove degenerate triangles and duplicated opposite-oriented triangles:
[2024-08-14 10:07:59.801] [float-tetwild] [info] (removing degenerate triangles might leave lone vertices that will be removed later)
[2024-08-14 10:07:59.801] [float-tetwild] [info] #v: 10072385 -> 10072385
[2024-08-14 10:07:59.801] [float-tetwild] [info] #f: 20149242 -> 20149242
collapsing 1410.3s
segfault

Any idea what the problem could be?
@nmnoble, I also tried your fTetWild branch, leading to the same issue. Any ideas?

@nmnobre
Copy link

nmnobre commented Aug 15, 2024

Hi @MariusCausemann, I'm afraid I don't have any ideas, it's been a while since I've used fTetWild...
Have you tried using a debugger, like gdb or lldb, to help you narrow down the problematic code?

@MariusCausemann
Copy link
Author

I've tried to narrow down the problem with a debugger now. Using gdb:

Thread 1 "FloatTetwild_bi" received signal SIGSEGV, Segmentation fault.
floatTetWild::get_angle_cos (p=..., p1=..., p2=...) at /home/mariusca/emimesh/fTetWild/fTetWild-master/src/Simplification.cpp:875
875         Vector3 v1 = p1 - p;
(gdb) print p
$1 = (const floatTetWild::Vector3 &) <error reading variable: Cannot access memory at address 0x1555452abff8>
(gdb) print p1
$2 = (const floatTetWild::Vector3 &) @0x15554710b518: {<Eigen::PlainObjectBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >> = {<Eigen::MatrixBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >> = {<Eigen::DenseBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >> = {<Eigen::DenseCoeffsBase<Eigen::Matrix<double, 3, 1, 0, 3, 1>, 3>> = {<Eigen::DenseCoeffsBase<Eigen::Matrix<double, 3, 1, 0, 3, 1>, 1>> = {<Eigen::DenseCoeffsBase<Eigen::Matrix<double, 3, 1, 0, 3, 1>, 0>> = {<Eigen::EigenBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >> = {<No data fields>}, <No data fields>}, <No data fields>}, <No data fields>}, <No data fields>}, <No data fields>}, m_storage = {m_data = {array = {4676.6656289838811, 3589.3853991366313, 
          1557.1230833073887}}}}, <No data fields>}
(gdb) print p2
$3 = (const floatTetWild::Vector3 &) @0x155547131a50: {<Eigen::PlainObjectBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >> = {<Eigen::MatrixBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >> = {<Eigen::DenseBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >> = {<Eigen::DenseCoeffsBase<Eigen::Matrix<double, 3, 1, 0, 3, 1>, 3>> = {<Eigen::DenseCoeffsBase<Eigen::Matrix<double, 3, 1, 0, 3, 1>, 1>> = {<Eigen::DenseCoeffsBase<Eigen::Matrix<double, 3, 1, 0, 3, 1>, 0>> = {<Eigen::EigenBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >> = {<No data fields>}, <No data fields>}, <No data fields>}, <No data fields>}, <No data fields>}, <No data fields>}, m_storage = {m_data = {array = {4693.8347660668605, 3581.6003856561606, 
          1508.7043087844927}}}}, <No data fields>}
(gdb) up
#1  0x0000555555670db7 in floatTetWild::swapping (input_vertices=..., input_faces=..., tree=..., params=..., v_is_removed=..., f_is_removed=..., conn_fs=...)
    at /home/mariusca/emimesh/fTetWild/fTetWild-master/src/Simplification.cpp:546
546             Scalar cos_a1 = get_angle_cos(input_vertices[n_v_ids[1]], input_vertices[v1_id], input_vertices[v2_id]);
(gdb) down
#0  floatTetWild::get_angle_cos (p=..., p1=..., p2=...) at /home/mariusca/emimesh/fTetWild/fTetWild-master/src/Simplification.cpp:875
875         Vector3 v1 = p1 - p;
(gdb) up

So it seems p is out of memory when get_angle_cos is being called in line 546 in Simplification.cpp. But I'm not familiar enough with the algorithm to figure out what could be going wrong...

@MariusCausemann
Copy link
Author

The issue can be reproduced with:

FloatTetwild_bin --csg csgtree_roi.json --max-threads 8 --level 2 -e 0.004

The files are available here:
https://drive.google.com/file/d/1cRMugFdne2H4Mi7GOxlD-sga4rv7oODW/view?usp=sharing
I'd appreciate if someone could take a look! (@danielepanozzo ?)

@MariusCausemann
Copy link
Author

Hi @teseoch , I've seen that you added a few fixes to the simplification process in wildmeshing/wildmeshing-toolkit#788. Do you think those would also address this issue?

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

2 participants