kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #34380
Re: [PATCH] Don't use the RTREE in UpdateAllLayersOrder() / UpdateAllLayersColor()
Jon,
With this patch applied, any layer switching in pcbnew leads to a crash,
even with no layout loaded. Can anyone else confirm this? See the the
attached address sanitizer report for details.
Regards,
Orson
On 02/25/2018 10:01 PM, Jon Evans wrote:
> This patch uses simple iteration instead of the RTREE search to update the
> layer order and color in VIEW. On my Linux system, this results in a ~50%
> speedup in release build (less in debug build) and is most noticeable when
> switching layers in GerbView with large Gerber files loaded (i.e. high
> number of items in the view).
>
> -Jon
>
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help : https://help.launchpad.net/ListHelp
>
10:57:55: Warning: Mismatch between the program and library build versions detected.
The library used 3.0 (wchar_t,compiler with C++ ABI 1011,wx containers,compatible with 2.8),
and your program used 3.0 (wchar_t,compiler with C++ ABI 1002,wx containers,compatible with 2.8).
10:57:55: Debug: Adding locale lookup path: /usr/local/share/kicad/internat
10:57:56 AM: Debug: Failed to connect to session manager: SESSION_MANAGER environment variable not defined
=================================================================
==24147==ERROR: AddressSanitizer: heap-use-after-free on address 0x6040001df714 at pc 0x7fb608f95423 bp 0x7ffd1f1e92a0 sp 0x7ffd1f1e9298
READ of size 4 at 0x6040001df714 thread T0
#0 0x7fb608f95422 in EDA_ITEM::IsBrightened() const /home/orson/workspace/kicad-master/include/base_struct.h:253:47
#1 0x7fb608f825ac in KIGFX::PCB_RENDER_SETTINGS::GetColor(KIGFX::VIEW_ITEM const*, int) const /home/orson/workspace/kicad-master/pcbnew/pcb_painter.cpp:220:19
#2 0x7fb6094d6c85 in KIGFX::VIEW::UpdateAllLayersColor() /home/orson/workspace/kicad-master/common/view/view.cpp:688:61
#3 0x7fb608f632d0 in PCB_DRAW_PANEL_GAL::SetHighContrastLayer(PCB_LAYER_ID) /home/orson/workspace/kicad-master/pcbnew/pcb_draw_panel_gal.cpp:237:13
#4 0x7fb60899e73a in PCB_DRAW_PANEL_GAL::SetHighContrastLayer(int) /home/orson/workspace/kicad-master/pcbnew/./pcb_draw_panel_gal.h:73:9
#5 0x7fb6086dad06 in PCB_EDIT_FRAME::SetActiveLayer(PCB_LAYER_ID) /home/orson/workspace/kicad-master/pcbnew/pcb_edit_frame.cpp:943:25
#6 0x7fb6086cd2b7 in PCB_LAYER_WIDGET::OnLayerSelect(int) /home/orson/workspace/kicad-master/pcbnew/pcb_layer_widget.cpp:615:14
#7 0x7fb608631b2c in LAYER_WIDGET::OnLeftDownLayers(wxMouseEvent&) /home/orson/workspace/kicad-master/pcbnew/layer_widget.cpp:118:9
#8 0x7fb61c2ded4d in wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) (/usr/lib/libwx_baseu-3.0.so.0+0x1efd4d)
#9 0x7fb61c2df16a in wxEvtHandler::SearchDynamicEventTable(wxEvent&) (/usr/lib/libwx_baseu-3.0.so.0+0x1f016a)
#10 0x7fb61c2df1ff in wxEvtHandler::TryHereOnly(wxEvent&) (/usr/lib/libwx_baseu-3.0.so.0+0x1f01ff)
#11 0x7fb61c2df2b3 in wxEvtHandler::ProcessEventLocally(wxEvent&) (/usr/lib/libwx_baseu-3.0.so.0+0x1f02b3)
#12 0x7fb61c2df315 in wxEvtHandler::ProcessEvent(wxEvent&) (/usr/lib/libwx_baseu-3.0.so.0+0x1f0315)
#13 0x7fb61c2e04b3 in wxEvtHandler::ProcessPendingEvents() (/usr/lib/libwx_baseu-3.0.so.0+0x1f14b3)
#14 0x7fb61c159387 in wxAppConsoleBase::ProcessPendingEvents() (/usr/lib/libwx_baseu-3.0.so.0+0x6a387)
#15 0x7fb61ca0557d in wxApp::DoIdle() (/usr/lib/libwx_gtk2u_core-3.0.so.0+0x23c57d)
#16 0x7fb61ca056a3 (/usr/lib/libwx_gtk2u_core-3.0.so.0+0x23c6a3)
#17 0x7fb6178bc8c4 in g_main_context_dispatch (/usr/lib/libglib-2.0.so.0+0x4a8c4)
#18 0x7fb6178bcc87 (/usr/lib/libglib-2.0.so.0+0x4ac87)
#19 0x7fb6178bcfa1 in g_main_loop_run (/usr/lib/libglib-2.0.so.0+0x4afa1)
#20 0x7fb61896d3a6 in gtk_main (/usr/lib/libgtk-x11-2.0.so.0+0x12e3a6)
#21 0x7fb61ca25865 in wxGUIEventLoop::DoRun() (/usr/lib/libwx_gtk2u_core-3.0.so.0+0x25c865)
#22 0x7fb61c194783 in wxEventLoopBase::Run() (/usr/lib/libwx_baseu-3.0.so.0+0xa5783)
#23 0x7fb61c15b246 in wxAppConsoleBase::MainLoop() (/usr/lib/libwx_baseu-3.0.so.0+0x6c246)
#24 0x55aaecc4ab17 in APP_SINGLE_TOP::OnRun() /home/orson/workspace/kicad-master/common/single_top.cpp:165:26
#25 0x7fb61c1e8577 in wxEntry(int&, wchar_t**) (/usr/lib/libwx_baseu-3.0.so.0+0xf9577)
#26 0x55aaecc40686 in main /home/orson/workspace/kicad-master/common/single_top.cpp:239:1
#27 0x7fb618e9f4c9 in __libc_start_main (/usr/lib/libc.so.6+0x204c9)
#28 0x55aaecb4d6b9 in _start (/home/orson/workspace/kicad-master/build_debug_clang/pcbnew/pcbnew+0x836b9)
0x6040001df714 is located 4 bytes inside of 36-byte region [0x6040001df710,0x6040001df734)
freed by thread T0 here:
#0 0x55aaecc02ed0 in __interceptor_cfree.localalias.1 (/home/orson/workspace/kicad-master/build_debug_clang/pcbnew/pcbnew+0x138ed0)
#1 0x7fb607efd7e1 in wxPrivate::UntypedBufferData::~UntypedBufferData() /usr/include/wx-3.0/wx/buffer.h:44:13
#2 0x7fb607efd744 in wxScopedCharTypeBuffer<wchar_t>::Data::~Data() /usr/include/wx-3.0/wx/buffer.h:164:12
#3 0x7fb607efd6e8 in wxScopedCharTypeBuffer<wchar_t>::DecRef() /usr/include/wx-3.0/wx/buffer.h:197:13
#4 0x7fb607efd374 in wxScopedCharTypeBuffer<wchar_t>::~wxScopedCharTypeBuffer() /usr/include/wx-3.0/wx/buffer.h:127:9
#5 0x7fb607ef8573 in wxString::wxString(char const*) /usr/include/wx-3.0/wx/string.h:1242:7
#6 0x7fb6084328de in operator==(wxString const&, char const*) /usr/include/wx-3.0/wx/string.h:4079:593
#7 0x7fb608da5cf6 in NETCLASSES::Find(wxString const&) const /home/orson/workspace/kicad-master/pcbnew/netclass.cpp:146:15
#8 0x7fb6090aeac7 in PNS_PCBNEW_RULE_RESOLVER::PNS_PCBNEW_RULE_RESOLVER(BOARD*, PNS::ROUTER*) /home/orson/workspace/kicad-master/pcbnew/router/pns_kicad_iface.cpp:123:68
#9 0x7fb6090bc697 in PNS_KICAD_IFACE::SyncWorld(PNS::NODE*) /home/orson/workspace/kicad-master/pcbnew/router/pns_kicad_iface.cpp:991:26
#10 0x7fb6091709f3 in PNS::ROUTER::SyncWorld() /home/orson/workspace/kicad-master/pcbnew/router/pns_router.cpp:96:14
#11 0x7fb6090694a0 in PNS::TOOL_BASE::Reset(TOOL_BASE::RESET_REASON) /home/orson/workspace/kicad-master/pcbnew/router/pns_tool_base.cpp:108:15
#12 0x7fb609094eaa in ROUTER_TOOL::Reset(TOOL_BASE::RESET_REASON) /home/orson/workspace/kicad-master/pcbnew/router/router_tool.cpp:380:16
#13 0x7fb60955fa62 in TOOL_MANAGER::ResetTools(TOOL_BASE::RESET_REASON) /home/orson/workspace/kicad-master/common/tool/tool_manager.cpp:431:15
#14 0x7fb608cfa60f in PCB_BASE_FRAME::UseGalCanvas(bool) /home/orson/workspace/kicad-master/pcbnew/pcb_base_frame.cpp:1037:28
#15 0x7fb6086bd16e in PCB_BASE_EDIT_FRAME::UseGalCanvas(bool) /home/orson/workspace/kicad-master/pcbnew/pcb_base_edit_frame.cpp:44:21
#16 0x7fb6086d98e1 in PCB_EDIT_FRAME::UseGalCanvas(bool) /home/orson/workspace/kicad-master/pcbnew/pcb_edit_frame.cpp:763:26
#17 0x7fb6086d5154 in PCB_EDIT_FRAME::PCB_EDIT_FRAME(KIWAY*, wxWindow*) /home/orson/workspace/kicad-master/pcbnew/pcb_edit_frame.cpp:523:13
#18 0x7fb607efc4bb in PCB::IFACE::CreateWindow(wxWindow*, int, KIWAY*, int) /home/orson/workspace/kicad-master/pcbnew/pcbnew.cpp:113:52
#19 0x55aaecc631b1 in KIWAY::Player(FRAME_T, bool, wxTopLevelWindow*) /home/orson/workspace/kicad-master/common/kiway.cpp:329:45
#20 0x55aaecc41733 in PGM_SINGLE_TOP::OnPgmInit() /home/orson/workspace/kicad-master/common/single_top.cpp:322:33
#21 0x55aaecc49dad in APP_SINGLE_TOP::OnInit() /home/orson/workspace/kicad-master/common/single_top.cpp:128:28
#22 0x55aaecc49b20 in wxAppConsoleBase::CallOnInit() /usr/include/wx-3.0/wx/app.h:93:40
#23 0x7fb61c1e85c1 in wxEntry(int&, wchar_t**) (/usr/lib/libwx_baseu-3.0.so.0+0xf95c1)
#24 0x7fb618e9f4c9 in __libc_start_main (/usr/lib/libc.so.6+0x204c9)
previously allocated by thread T0 here:
#0 0x55aaecc03088 in __interceptor_malloc (/home/orson/workspace/kicad-master/build_debug_clang/pcbnew/pcbnew+0x139088)
#1 0x7fb61c2136f3 in wxMBConv::cMB2WC(char const*, unsigned long, unsigned long*) const (/usr/lib/libwx_baseu-3.0.so.0+0x1246f3)
SUMMARY: AddressSanitizer: heap-use-after-free /home/orson/workspace/kicad-master/include/base_struct.h:253:47 in EDA_ITEM::IsBrightened() const
Shadow bytes around the buggy address:
0x0c0880033e90: fa fa fd fd fd fd fd fd fa fa fd fd fd fd fd fd
0x0c0880033ea0: fa fa 00 00 00 00 00 02 fa fa fd fd fd fd fd fd
0x0c0880033eb0: fa fa fd fd fd fd fd fd fa fa fd fd fd fd fd fd
0x0c0880033ec0: fa fa 00 00 00 00 00 01 fa fa fd fd fd fd fd fd
0x0c0880033ed0: fa fa 00 00 00 00 00 00 fa fa 00 00 00 00 00 00
=>0x0c0880033ee0: fa fa[fd]fd fd fd fd fa fa fa fd fd fd fd fd fa
0x0c0880033ef0: fa fa fd fd fd fd fd fa fa fa fd fd fd fd fd fa
0x0c0880033f00: fa fa 00 00 00 00 05 fa fa fa fd fd fd fd fd fa
0x0c0880033f10: fa fa fd fd fd fd fd fa fa fa fd fd fd fd fd fa
0x0c0880033f20: fa fa 00 00 00 00 02 fa fa fa fd fd fd fd fd fd
0x0c0880033f30: fa fa fd fd fd fd fd fd fa fa fd fd fd fd fd fd
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
==24147==ABORTING
Attachment:
signature.asc
Description: OpenPGP digital signature
Follow ups
References