GLib assertion on constrained zone creation

Bug #1846431 reported by Ian McInerney
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
KiCad
Fix Released
High
Seth Hillbrand

Bug Description

When you try to create a zone that is constrained to H/V/45 from the start, glibc++ throws an assertion

/usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/stl_vector.h:1060: std::vector::const_reference std::vector<VECTOR2<int>, std::allocator<VECTOR2<int> > >::operator[](std::vector::size_type) const [_Tp = VECTOR2<int>, _Alloc = std::allocator<VECTOR2<int> >]: Assertion '__builtin_expect(__n < this->size(), true)' failed.

Steps to reproduce:
1) Start zone tool
2) Click to start zone
3) In dialog, check the "constrain outline to H, V, 45 degrees" flag
4) Click OK

It appears this is happening because there is only 1 point in the zone to start with, and a test is trying to create a segment using two points of the zone. This causes the indexing at shape_line_chain.h:251 to go outside the vector bounds (accessing place 1 when there is only place 0).access

The backtrace of the event is below.

* thread #1, name = 'pcbnew', stop reason = signal SIGABRT
  * frame #0: 0x00007f75ac527e75 libc.so.6`.annobin_raise.c + 325
    frame #1: 0x00007f75ac512895 libc.so.6`.annobin_loadmsgcat.c_end.unlikely + 295
    frame #2: 0x00007f75a4b89537 _pcbnew.kiface`std::__replacement_assert(__file=<unavailable>, __line=<unavailable>, __function=<unavailable>, __condition=<unavailable>) at c++config.h:2533:5
    frame #3: 0x00007f75a4cfe945 _pcbnew.kiface`std::vector<VECTOR2<int>, std::allocator<VECTOR2<int> > >::operator[](this=0x00007f7593c439b0, __n=1) const at stl_vector.h:1060:2
    frame #4: 0x00007f75a4e8ffa7 _pcbnew.kiface`SHAPE_LINE_CHAIN::CSegment(this=<unavailable>, aIndex=0) const at shape_line_chain.h:0
    frame #5: 0x00007f75a5cdf004 _pcbnew.kiface`POLYGON_GEOM_MANAGER::updateLeaderPoints(this=<unavailable>, aEndPoint=0x00007f7593c44250, aModifier=-1815858336) at polygon_geom_manager.cpp:157:39
    frame #6: 0x00007f75a5cdeca9 _pcbnew.kiface`POLYGON_GEOM_MANAGER::SetCursorPosition(this=<unavailable>, aPos=<unavailable>, aModifier=<unavailable>) at polygon_geom_manager.cpp:102:5
    frame #7: 0x00007f75a5175fdd _pcbnew.kiface`DRAWING_TOOL::DrawZone(this=0x0000617000583680, aEvent=0x00007f7593c44160) at drawing_tool.cpp:1548:25
    frame #8: 0x00007f75a518a47a _pcbnew.kiface`int std::__invoke_impl<int, int (DRAWING_TOOL::*&)(TOOL_EVENT const&), DRAWING_TOOL*&, TOOL_EVENT const&>((null)=<unavailable>, __f=<unavailable>, __t=<unavailable>, __args=0x00007ffe129b9908)(TOOL_EVENT const&), DRAWING_TOOL*&, TOOL_EVENT const&) at invoke.h:73:14
    frame #9: 0x00007f75a518a399 _pcbnew.kiface`std::__invoke_result<int (DRAWING_TOOL::*&)(TOOL_EVENT const&), DRAWING_TOOL*&, TOOL_EVENT const&>::type std::__invoke<int (__fn=<unavailable>, __args=<unavailable>, __args=<unavailable>)(TOOL_EVENT const&), DRAWING_TOOL*&, TOOL_EVENT const&>(int (DRAWING_TOOL::*&)(TOOL_EVENT const&), DRAWING_TOOL*&, TOOL_EVENT const&) at invoke.h:95:14
    frame #10: 0x00007f75a518a306 _pcbnew.kiface`int std::_Bind<int (DRAWING_TOOL::* (DRAWING_TOOL*, std::_Placeholder<1>))(TOOL_EVENT const&)>::__call<int, TOOL_EVENT const&, 0ul, 1ul>(this=0x0000603002179b70, __args=0x00007f7593c446e0, (null)=<unavailable>) at functional:400:11
    frame #11: 0x00007f75a518a1ac _pcbnew.kiface`int std::_Bind<int (DRAWING_TOOL::* (DRAWING_TOOL*, std::_Placeholder<1>))(TOOL_EVENT const&)>::operator(this=0x0000603002179b70, __args=<unavailable>)<TOOL_EVENT const&, int>(TOOL_EVENT const&) at functional:482:17
    frame #12: 0x00007f75a5189e45 _pcbnew.kiface`std::_Function_handler<int (TOOL_EVENT const&), std::_Bind<int (DRAWING_TOOL::* (DRAWING_TOOL*, std::_Placeholder<1>))(TOOL_EVENT const&)> >::_M_invoke(__functor=<unavailable>, __args=<unavailable>) at std_function.h:285:9
    frame #13: 0x00007f75a5f17162 _pcbnew.kiface`std::function<int (TOOL_EVENT const&)>::operator(this=0x00006080000df430, __args=0x00007ffe129b9908)(TOOL_EVENT const&) const at std_function.h:690:14
    frame #14: 0x00007f75a5f16e2f _pcbnew.kiface`COROUTINE<int, TOOL_EVENT const&>::callerStub(aData=<unavailable>) at coroutine.h:350:25
    frame #15: 0x00007f75a5f1b731 _pcbnew.kiface`make_fcontext + 33

This seems to happen on both the 5.1 and master branches.

Application: Pcbnew
Version: (5.99.0-189-gc3175b45a), debug build
Libraries:
    wxWidgets 3.0.4
    libcurl/7.65.3 OpenSSL/1.1.1c-fips zlib/1.2.11 brotli/1.0.7 libidn2/2.2.0 libpsl/0.20.2 (+libidn2/2.0.5) libssh/0.9.0/openssl/zlib nghttp2/1.38.0
Platform: Linux 5.1.18-300.fc30.x86_64 x86_64, 64 bit, Little endian, wxGTK
Build Info:
    Build date: Sep 27 2019 19:04:14
    wxWidgets: 3.0.4 (wchar_t,wx containers,compatible with 2.8) GTK+ 3.24
    Boost: 1.69.0
    OpenCASCADE Community Edition: 6.9.1
    Curl: 7.65.3
    Compiler: Clang 8.0.0 with C++ ABI 1002

Build settings:
    KICAD_SCRIPTING=ON
    KICAD_SCRIPTING_MODULES=ON
    KICAD_SCRIPTING_PYTHON3=ON
    KICAD_SCRIPTING_WXPYTHON=ON
    KICAD_SCRIPTING_WXPYTHON_PHOENIX=ON
    KICAD_SCRIPTING_ACTION_MENU=ON
    BUILD_GITHUB_PLUGIN=ON
    KICAD_USE_OCE=ON
    KICAD_USE_OCC=OFF
    KICAD_SPICE=ON
    KICAD_STDLIB_DEBUG=OFF
    KICAD_STDLIB_LIGHT_DEBUG=OFF
    KICAD_SANITIZE=OFF

Tags: pcbnew
description: updated
Revision history for this message
Ian McInerney (imcinerney) wrote :

I'm going to put this to high for 5.1.5 since it can cause the entire program to crash on Fedora (due to their enabling of the GLib assertions for all programs).

Changed in kicad:
milestone: none → 5.1.5
importance: Undecided → High
Seth Hillbrand (sethh)
Changed in kicad:
assignee: nobody → Seth Hillbrand (sethh)
status: New → In Progress
Revision history for this message
KiCad Janitor (kicad-janitor) wrote :

Fixed in revision 70c64d93e441ca1af9d61aeac3fac6323f970ac7
https://git.launchpad.net/kicad/patch/?id=70c64d93e441ca1af9d61aeac3fac6323f970ac7

Changed in kicad:
status: In Progress → Fix Committed
Changed in kicad:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.