wo80 / Triangle

CMake project for Jonathan Shewchuk's Triangle mesh generator.
Other
63 stars 26 forks source link

Sporadic crash due to NULL pointer #40

Closed madscientist159 closed 2 years ago

madscientist159 commented 5 years ago

I'm seeing a crash on one or two (unfortunately proprietary) files when triangle is running. Somehow farvertex is NULL:

Program received signal SIGSEGV, Segmentation fault.
constrainededge (m=0x100327560, b=0x1002d3300, starttri=<optimized out>, endpoint2=0x1002e2cd0, newmark=<optimized out>, status=0x7fffffffe630) at /home/femm/Triangle/src/Triangle/triangle.c:6242
6242        if ((farvertex[0] == endpoint2[0]) && (farvertex[1] == endpoint2[1])) {
(gdb) bt
#0  constrainededge (m=0x100327560, b=0x1002d3300, starttri=<optimized out>, endpoint2=0x1002e2cd0, newmark=<optimized out>, status=0x7fffffffe630) at /home/femm/Triangle/src/Triangle/triangle.c:6242
#1  0x00007ffff7f12f20 in insertsegment (m=0x100327560, b=0x1002d3300, endpoint1=0x1002e2cb0, endpoint2=<optimized out>, newmark=<optimized out>, status=<optimized out>) at /home/femm/Triangle/src/Triangle/triangle.c:6391
#2  0x00007ffff7f132cc in formskeleton (m=<optimized out>, b=<optimized out>, segmentlist=0x100d47740, segmentmarkerlist=0x10033b940, numberofsegments=<optimized out>, status=<optimized out>)
    at /home/femm/Triangle/src/Triangle/triangle.c:6494
#3  0x00007ffff7f062f4 in triangle_mesh_create (ctx=<optimized out>, in=0x7fffffffe990) at /home/femm/Triangle/src/Triangle/triangle_api.c:221
#4  0x000000010007a1cc in (anonymous namespace)::TriangulateHelper::triangulate (this=this@entry=0x7fffffffe980, verbose=<optimized out>) at /home/femm/xfemm-hgrepo/cfemm/fmesher/writepoly.cpp:2301
#5  0x000000010007bcfc in fmesher::FMesher::DoNonPeriodicBCTriangulation (this=0x10021c780, PathName="simulation-frame-162-1.fee") at /home/femm/xfemm-hgrepo/cfemm/fmesher/writepoly.cpp:802
#6  0x0000000100044a8c in femmcli::LuaElectrostaticsCommands::luaAnalyze (L=0x1001d27f0) at /usr/include/c++/8/ext/new_allocator.h:81
#7  0x000000010014ba30 in callCclosure (base=0x7ffff7f50080, cl=<optimized out>, L=0x1001d27f0) at /home/femm/xfemm-hgrepo/cfemm/libfemm/liblua/ldo.cpp:149
#8  luaD_call (L=0x1001d27f0, func=0x7ffff7f50048, nResults=<optimized out>) at /home/femm/xfemm-hgrepo/cfemm/libfemm/liblua/ldo.cpp:195
#9  0x000000010015c730 in luaV_execute (L=0x1001d27f0, cl=0x10022f650, base=0x7ffff7f50048) at /home/femm/xfemm-hgrepo/cfemm/libfemm/liblua/lvm.cpp:434
#10 0x000000010014bb68 in luaD_call (L=0x1001d27f0, func=0x7ffff7f50010, nResults=<optimized out>) at /home/femm/xfemm-hgrepo/cfemm/libfemm/liblua/ldo.cpp:195
#11 0x000000010014bfd4 in luaD_runprotected (L=L@entry=0x1001d27f0, f=f@entry=0x10014bd50 <f_call(lua_State*, void*)>, ud=ud@entry=0x7ffffffff3e0) at /home/femm/xfemm-hgrepo/cfemm/libfemm/liblua/ldo.cpp:417
#12 0x000000010014c53c in lua_call (nresults=-1, nargs=0, L=0x1001d27f0) at /home/femm/xfemm-hgrepo/cfemm/libfemm/liblua/ldo.cpp:245
#13 lua_dofile (L=0x1001d27f0, filename=<optimized out>) at /home/femm/xfemm-hgrepo/cfemm/libfemm/liblua/ldo.cpp:323
#14 0x000000010013a57c in femm::LuaInstance::doFile (this=0x7ffffffff460, filename="run-simulation-slice-1.lua", mode=<optimized out>) at /usr/include/c++/8/bits/basic_string.h:2290
#15 0x0000000100037bf0 in execLuaFile (inputFile="run-simulation-slice-1.lua", luaInit="/usr/local/share//xfemm/release/init.lua", luaTrace=<optimized out>, luaBaseDir="") at /home/femm/xfemm-hgrepo/cfemm/femmcli/main.cpp:85
#16 0x0000000100035ef8 in main (argc=<optimized out>, argv=0x7ffffffffa98) at /home/femm/xfemm-hgrepo/cfemm/femmcli/main.cpp:234
(gdb) p farvertex
$1 = (vertex) 0x0
(gdb) p endpoint2
$2 = (vertex) 0x1002e2cd0

The crash is 100% repeatable on these files, but triangle works fine for most of the other files we're throwing at xfemm. Building in Debug mode instead of Release mode also seems to resolve the crash, though it may just alter the code paths enough to avoid it vs. actually fixing it.

wo80 commented 5 years ago

I never encountered a crash in constrainededge. Any chance, you can give a (minimal) example input file where this happens?

wo80 commented 2 years ago

Please re-open, if you think this is still relevant.