assert "m_shapes.size() == m_points.size()" failed in fixIndicesRotation()
Description
When drawing a route from a PTH, I got this assertion failure. My routing tool was in the "free angle" mode, and I had drawn one intermediate point. This assertion failure happened when I moved my mouse pointer to touch another PHT that belongs to a different net (without clicking mouse button).
Interestingly, continuing does not result in a crash; it's not obvious that anything went wrong except for the assertion failure. I was able to reproduce this a few times during that same run, but it stopped happening when I tried to take a screen recording...
Here's a backtrace:
/home/sliedes/scratch/build/kicad/kicad/libs/kimath/src/geometry/shape_line_chain.cpp(131): assert "m_shapes.size() == m_points.size()" failed in fixIndicesRotation().
Thread 1 "kicad" received signal SIGTRAP, Trace/breakpoint trap.
__pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=5, no_tid=no_tid@entry=0) at pthread_kill.c:44
44 return INTERNAL_SYSCALL_ERROR_P (ret) ? INTERNAL_SYSCALL_ERRNO (ret) : 0;
(gdb) bt
#0 __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=5, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1 0x00007ffff53a33d3 in __pthread_kill_internal (signo=5, threadid=<optimized out>) at pthread_kill.c:78
#2 0x00007ffff5353838 in __GI_raise (sig=5) at ../sysdeps/posix/raise.c:26
#3 0x00007ffff7445c06 in () at /usr/lib/libwx_baseu-3.0.so.0
#4 0x00007ffff743fa7b in wxOnAssert(char const*, int, char const*, char const*, wchar_t const*) () at /usr/lib/libwx_baseu-3.0.so.0
#5 0x00007ffff78c0567 in wxGUIAppTraits::ShowAssertDialog(wxString const&) () at /usr/lib/libwx_gtk3u_core-3.0.so.0
#6 0x00007ffff7444997 in () at /usr/lib/libwx_baseu-3.0.so.0
#7 0x00007ffff7444bf1 in wxAppConsoleBase::OnAssertFailure(wchar_t const*, int, wchar_t const*, wchar_t const*, wchar_t const*) () at /usr/lib/libwx_baseu-3.0.so.0
#8 0x00007ffff7891655 in wxApp::OnAssertFailure(wchar_t const*, int, wchar_t const*, wchar_t const*, wchar_t const*) () at /usr/lib/libwx_gtk3u_core-3.0.so.0
#9 0x00007ffff7445ba6 in () at /usr/lib/libwx_baseu-3.0.so.0
#10 0x00007ffff743f7b8 in wxOnAssert(char const*, int, char const*, char const*, char const*) () at /usr/lib/libwx_baseu-3.0.so.0
#11 0x00007fffceff9aad in SHAPE_LINE_CHAIN::fixIndicesRotation() (this=0x55556e45be70) at /home/sliedes/scratch/build/kicad/kicad/libs/kimath/src/geometry/shape_line_chain.cpp:131
#12 0x00007fffceffa609 in SHAPE_LINE_CHAIN::mergeFirstLastPointIfNeeded() (this=0x55556e45be70) at /home/sliedes/scratch/build/kicad/kicad/libs/kimath/src/geometry/shape_line_chain.cpp:168
#13 0x00007fffcdb88c95 in SHAPE_LINE_CHAIN::SetClosed(bool) (this=0x55556e45be70, aClosed=true) at /home/sliedes/scratch/build/kicad/kicad/libs/kimath/include/geometry/shape_line_chain.h:255
#14 0x00007fffce87fda1 in PNS::MOUSE_TRAIL_TRACER::GetPosture(VECTOR2<int> const&) (this=0x5555570d5308, aP=...) at /home/sliedes/scratch/build/kicad/kicad/pcbnew/router/pns_mouse_trail_tracer.cpp:153
#15 0x00007fffce8637ab in PNS::LINE_PLACER::buildInitialLine(VECTOR2<int> const&, PNS::LINE&, bool) (this=0x5555570d4c30, aP=..., aHead=..., aForceNoVia=false) at /home/sliedes/scratch/build/kicad/kicad/pcbnew/router/pns_line_placer.cpp:1699
#16 0x00007fffce8649be in PNS::LINE_PLACER::rhMarkObstacles(VECTOR2<int> const&, PNS::LINE&) (this=0x5555570d4c30, aP=..., aNewHead=...) at /home/sliedes/scratch/build/kicad/kicad/pcbnew/router/pns_line_placer.cpp:688
#17 0x00007fffce86560e in PNS::LINE_PLACER::routeHead(VECTOR2<int> const&, PNS::LINE&) (this=0x5555570d4c30, aP=..., aNewHead=...) at /home/sliedes/scratch/build/kicad/kicad/pcbnew/router/pns_line_placer.cpp:826
#18 0x00007fffce867ccd in PNS::LINE_PLACER::routeStep(VECTOR2<int> const&) (this=0x5555570d4c30, aP=...) at /home/sliedes/scratch/build/kicad/kicad/pcbnew/router/pns_line_placer.cpp:941
#19 0x00007fffce869781 in PNS::LINE_PLACER::route(VECTOR2<int> const&) (this=0x5555570d4c30, aP=...) at /home/sliedes/scratch/build/kicad/kicad/pcbnew/router/pns_line_placer.cpp:1009
#20 0x00007fffce86adc6 in PNS::LINE_PLACER::Move(VECTOR2<int> const&, PNS::ITEM*) (this=0x5555570d4c30, aP=..., aEndItem=0x0) at /home/sliedes/scratch/build/kicad/kicad/pcbnew/router/pns_line_placer.cpp:1235
#21 0x00007fffce8223d7 in PNS::ROUTER::movePlacing(VECTOR2<int> const&, PNS::ITEM*) (this=0x55555f8dcbb0, aP=..., aEndItem=0x0) at /home/sliedes/scratch/build/kicad/kicad/pcbnew/router/pns_router.cpp:588
#22 0x00007fffce822344 in PNS::ROUTER::Move(VECTOR2<int> const&, PNS::ITEM*) (this=0x55555f8dcbb0, aP=..., endItem=0x0) at /home/sliedes/scratch/build/kicad/kicad/pcbnew/router/pns_router.cpp:438
#23 0x00007fffce7ce3fe in ROUTER_TOOL::performRouting() (this=0x55556d953a00) at /home/sliedes/scratch/build/kicad/kicad/pcbnew/router/router_tool.cpp:1173
#24 0x00007fffce7cf7fb in ROUTER_TOOL::MainLoop(TOOL_EVENT const&) (this=0x55556d953a00, aEvent=...) at /home/sliedes/scratch/build/kicad/kicad/pcbnew/router/router_tool.cpp:1451
#25 0x00007fffce7debc6 in std::__invoke_impl<int, int (ROUTER_TOOL::*&)(TOOL_EVENT const&), ROUTER_TOOL*&, TOOL_EVENT const&>(std::__invoke_memfun_deref, int (ROUTER_TOOL::*&)(TOOL_EVENT const&), ROUTER_TOOL*&, TOOL_EVENT const&)
(__f=@0x55557047a4d0: (int (ROUTER_TOOL::*)(class ROUTER_TOOL * const, const class TOOL_EVENT &)) 0x7fffce7cefb0 <ROUTER_TOOL::MainLoop(TOOL_EVENT const&)>, __t=@0x55557047a4e0: 0x55556d953a00, __args=...) at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.1.0/../../../../include/c++/12.1.0/bits/invoke.h:74
#26 0x00007fffce7deac7 in std::__invoke<int (ROUTER_TOOL::*&)(TOOL_EVENT const&), ROUTER_TOOL*&, TOOL_EVENT const&>(int (ROUTER_TOOL::*&)(TOOL_EVENT const&), ROUTER_TOOL*&, TOOL_EVENT const&)
(__fn=@0x55557047a4d0: (int (ROUTER_TOOL::*)(class ROUTER_TOOL * const, const class TOOL_EVENT &)) 0x7fffce7cefb0 <ROUTER_TOOL::MainLoop(TOOL_EVENT const&)>, __args=@0x55557047a4e0: 0x55556d953a00, __args=...) at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.1.0/../../../../include/c++/12.1.0/bits/invoke.h:96
#27 0x00007fffce7dea4f in std::_Bind<int (ROUTER_TOOL::*(ROUTER_TOOL*, std::_Placeholder<1>))(TOOL_EVENT const&)>::__call<int, TOOL_EVENT const&, 0ul, 1ul>(std::tuple<TOOL_EVENT const&>&&, std::_Index_tuple<0ul, 1ul>) (this=0x55557047a4d0, __args=...) at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.1.0/../../../../include/c++/12.1.0/functional:484
#28 0x00007fffce7de9ab in std::_Bind<int (ROUTER_TOOL::*(ROUTER_TOOL*, std::_Placeholder<1>))(TOOL_EVENT const&)>::operator()<TOOL_EVENT const&, int>(TOOL_EVENT const&) (this=0x55557047a4d0, __args=...) at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.1.0/../../../../include/c++/12.1.0/functional:567
#29 0x00007fffce7de942 in std::__invoke_impl<int, std::_Bind<int (ROUTER_TOOL::*(ROUTER_TOOL*, std::_Placeholder<1>))(TOOL_EVENT const&)>&, TOOL_EVENT const&>(std::__invoke_other, std::_Bind<int (ROUTER_TOOL::*(ROUTER_TOOL*, std::_Placeholder<1>))(TOOL_EVENT const&)>&, TOOL_EVENT const&) (__f=..., __args=...)
at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.1.0/../../../../include/c++/12.1.0/bits/invoke.h:61
#30 0x00007fffce7de8e2 in std::__invoke_r<int, std::_Bind<int (ROUTER_TOOL::*(ROUTER_TOOL*, std::_Placeholder<1>))(TOOL_EVENT const&)>&, TOOL_EVENT const&>(std::_Bind<int (ROUTER_TOOL::*(ROUTER_TOOL*, std::_Placeholder<1>))(TOOL_EVENT const&)>&, TOOL_EVENT const&) (__fn=..., __args=...)
at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.1.0/../../../../include/c++/12.1.0/bits/invoke.h:114
#31 0x00007fffce7de6f2 in std::_Function_handler<int (TOOL_EVENT const&), std::_Bind<int (ROUTER_TOOL::*(ROUTER_TOOL*, std::_Placeholder<1>))(TOOL_EVENT const&)> >::_M_invoke(std::_Any_data const&, TOOL_EVENT const&) (__functor=..., __args=...) at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.1.0/../../../../include/c++/12.1.0/bits/std_function.h:290
#32 0x00007fffceb73a55 in std::function<int (TOOL_EVENT const&)>::operator()(TOOL_EVENT const&) const (this=0x555557ab8cb0, __args=...) at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.1.0/../../../../include/c++/12.1.0/bits/std_function.h:591
#33 0x00007fffceb73937 in COROUTINE<int, TOOL_EVENT const&>::callerStub(long) (aData=140737488337048) at /home/sliedes/scratch/build/kicad/kicad/include/tool/coroutine.h:428
#34 0x00007fffcec5caa1 in make_fcontext () at /home/sliedes/.local/bin/_pcbnew.kiface
#35 0x0000000000000000 in ()
(gdb) fra 11
#11 0x00007fffcdb88c95 in SHAPE_LINE_CHAIN::SetClosed (this=0x55556e45be70, aClosed=true) at /home/sliedes/scratch/build/kicad/kicad/libs/kimath/include/geometry/shape_line_chain.h:255
255 mergeFirstLastPointIfNeeded();
(gdb) p m_shapes.size()
$1 = 46
(gdb) p m_points.size()
$2 = 1
(gdb) p m_shapes
$3 = std::vector of length 46, capacity 47 = {{first = -1, second = -1}, {first = -1, second = -1}, {first = -1, second = -1}, {first = -1, second = -1}, {first = -1, second = -1}, {first = -1, second = -1}, {first = -1, second = -1}, {first = -1, second = -1}, {first = -1, second = -1}, {first = -1, second = -1}, {first = -1, second = -1}, {first = -1,
second = -1}, {first = -1, second = -1}, {first = -1, second = -1}, {first = -1, second = -1}, {first = -1, second = -1}, {first = -1, second = -1}, {first = -1, second = -1}, {first = -1, second = -1}, {first = -1, second = -1}, {first = -1, second = -1}, {first = -1, second = -1}, {first = -1, second = -1}, {first = -1, second = -1}, {first = -1,
second = -1}, {first = -1, second = -1}, {first = -1, second = -1}, {first = -1, second = -1}, {first = -1, second = -1}, {first = -1, second = -1}, {first = -1, second = -1}, {first = -1, second = -1}, {first = -1, second = -1}, {first = -1, second = -1}, {first = -1, second = -1}, {first = -1, second = -1}, {first = -1, second = -1}, {first = -1,
second = -1}, {first = -1, second = -1}, {first = -1, second = -1}, {first = -1, second = -1}, {first = -1, second = -1}, {first = -1, second = -1}, {first = -1, second = -1}, {first = -1, second = -1}, {first = -1, second = -1}}
(gdb) p m_points
$4 = std::vector of length 1, capacity 2 = {{static ECOORD_MAX = 9223372036854775807, static ECOORD_MIN = <optimized out>, x = 114604800, y = 44805600}}
KiCad Version
Application: KiCad PCB Editor
Version: (6.99.0-1948-gef4f0b49fc), debug build
Libraries:
wxWidgets 3.0.5
FreeType 2.12.1
HarfBuzz 4.3.0
FontConfig 2.14.0
libcurl/7.83.1 OpenSSL/1.1.1o zlib/1.2.12 brotli/1.0.9 zstd/1.5.2 libidn2/2.3.2 libpsl/0.21.1 (+libidn2/2.3.0) libssh2/1.10.0 nghttp2/1.47.0
Platform: Linux 5.17.7-arch1-2 x86_64, 64 bit, Little endian, wxGTK, Regolith:GNOME-Flashback:GNOME, x11
Build Info:
Date: May 25 2022 12:43:22
wxWidgets: 3.0.5 (wchar_t,wx containers,compatible with 2.8) GTK+ 3.24
Boost: 1.78.0
OCC: 7.5.3
Curl: 7.83.1
ngspice: 35
Compiler: Clang 13.0.1 with C++ ABI 1002
Build settings:
KICAD_USE_OCC=ON
KICAD_SPICE=ON
KICAD_STDLIB_DEBUG=OFF
KICAD_STDLIB_LIGHT_DEBUG=OFF
KICAD_SANITIZE_ADDRESS=OFF
KICAD_SANITIZE_THREADS=OFF