Legacy canvas should be disabled in GTK3 based builds

Bug #1803156 reported by John Beard on 2018-11-13
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
KiCad
Undecided
John Beard

Bug Description

Whenever I start gerbview, it asserts endlessly (or at least very many times!):

./include/wx/math.h(151): assert "x > INT_MIN - 0.5 && x < INT_MAX + 0.5" failed in wxRound(): argument out of supported range

This is with wx-gtk3.

Stack (I can't see exactly what is going on as I don't have the debug symbols to hand):

#0 0x00007f1716b5a25f in raise () at /usr/lib/libpthread.so.0
#1 0x00007f171841acfe in wxGUIAppTraits::ShowAssertDialog(wxString const&) () at /usr/lib/libwx_gtk3u_core-3.0.so.0
#2 0x00007f1717f15282 in () at /usr/lib/libwx_baseu-3.0.so.0
#3 0x00007f1717f154a9 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
#4 0x00007f17183e9021 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
#5 0x00007f1717f1577b in () at /usr/lib/libwx_baseu-3.0.so.0
#6 0x00007f1717f1216b in wxOnAssert(char const*, int, char const*, char const*, wchar_t const*) ()
    at /usr/lib/libwx_baseu-3.0.so.0
#7 0x00007f17184d1e33 in wxDCImpl::DeviceToLogicalYRel(int) const () at /usr/lib/libwx_gtk3u_core-3.0.so.0
#8 0x00007f17184d6fa9 in wxGCDCImpl::Clear() () at /usr/lib/libwx_gtk3u_core-3.0.so.0
#9 0x00007f170dd55db7 in wxDC::Clear() (this=0x7ffd519d1db0) at /usr/include/wx-3.0/wx/dc.h:973
#10 0x00007f170dd54781 in GBR_LAYOUT::Draw(EDA_DRAW_PANEL*, wxDC*, GR_DRAWMODE, wxPoint const&, GBR_DISPLAY_OPTIONS*) (this=
    0x564a870112e0, aPanel=0x564a85e90bd0, aDC=0x7ffd519d2220, aDrawMode=GR_OR, aOffset=..., aDisplayOptions=0x564a86f36330) at /home/john/src/kicad/gerbview/gbr_layout.cpp:161
#11 0x00007f170dd708d9 in GERBVIEW_FRAME::RedrawActiveWindow(wxDC*, bool) (this=
    0x564a86f35aa0, DC=0x7ffd519d2220, EraseBg=true) at /home/john/src/kicad/gerbview/draw_gerber_screen.cpp:74
#12 0x00007f170dfaea3a in EDA_DRAW_PANEL::ReDraw(wxDC*, bool) (this=0x564a85e90bd0, DC=0x7ffd519d2220, erasebg=true)
    at /home/john/src/kicad/common/legacy_wx/eda_draw_panel.cpp:640
#13 0x00007f170dfae7c4 in EDA_DRAW_PANEL::OnPaint(wxPaintEvent&) (this=0x564a85e90bd0, event=...)
    at /home/john/src/kicad/common/legacy_wx/eda_draw_panel.cpp:607
#14 0x00007f171808089e in wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) () at /usr/lib/libwx_baseu-3.0.so.0
#15 0x00007f17180809a4 in wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*) () at /usr/lib/libwx_baseu-3.0.so.0
#16 0x00007f1718080cde in wxEvtHandler::TryHereOnly(wxEvent&) () at /usr/lib/libwx_baseu-3.0.so.0
#17 0x00007f1718080d64 in wxEvtHandler::ProcessEventLocally(wxEvent&) () at /usr/lib/libwx_baseu-3.0.so.0
#18 0x00007f1718080e02 in wxEvtHandler::ProcessEvent(wxEvent&) () at /usr/lib/libwx_baseu-3.0.so.0
#19 0x00007f171862467d in wxScrollHelperEvtHandler::ProcessEvent(wxEvent&) () at /usr/lib/libwx_gtk3u_core-3.0.so.0
#20 0x00007f1718080ba7 in wxEvtHandler::SafelyProcessEvent(wxEvent&) () at /usr/lib/libwx_baseu-3.0.so.0
#21 0x00007f171842aa6b in wxWindow::GTKSendPaintEvents(_cairo*) () at /usr/lib/libwx_gtk3u_core-3.0.so.0
#22 0x00007f171842af6c in () at /usr/lib/libwx_gtk3u_core-3.0.so.0
#23 0x00007f171660973c in () at /usr/lib/libgtk-3.so.0
#24 0x00007f17165b2c22 in () at /usr/lib/libgtk-3.so.0
#25 0x00007f17161083d5 in g_closure_invoke () at /usr/lib/libgobject-2.0.so.0
#26 0x00007f17160f5195 in () at /usr/lib/libgobject-2.0.so.0
#27 0x00007f17160f85ed in g_signal_emit_valist () at /usr/lib/libgobject-2.0.so.0
#28 0x00007f17160f9a80 in g_signal_emit () at /usr/lib/libgobject-2.0.so.0
#29 0x00007f17165bfca3 in () at /usr/lib/libgtk-3.so.0
#30 0x00007f171639c55f in gtk_container_propagate_draw () at /usr/lib/libgtk-3.so.0
#31 0x00007f171639c62e in () at /usr/lib/libgtk-3.so.0
#32 0x00007f17164f200e in () at /usr/lib/libgtk-3.so.0
#33 0x00007f17163a18dd in () at /usr/lib/libgtk-3.so.0
#34 0x00007f17163a6717 in () at /usr/lib/libgtk-3.so.0
#35 0x00007f17164f02d2 in () at /usr/lib/libgtk-3.so.0
#36 0x00007f17165bfb3a in () at /usr/lib/libgtk-3.so.0
#37 0x00007f171639c55f in gtk_container_propagate_draw () at /usr/lib/libgtk-3.so.0
#38 0x00007f171640f6b2 in () at /usr/lib/libgtk-3.so.0
#39 0x00007f171660973c in () at /usr/lib/libgtk-3.so.0
#40 0x00007f17165b2c22 in () at /usr/lib/libgtk-3.so.0
#41 0x00007f17161083d5 in g_closure_invoke () at /usr/lib/libgobject-2.0.so.0
#42 0x00007f17160f499f in () at /usr/lib/libgobject-2.0.so.0
#43 0x00007f17160f85ed in g_signal_emit_valist () at /usr/lib/libgobject-2.0.so.0
#44 0x00007f17160f9a80 in g_signal_emit () at /usr/lib/libgobject-2.0.so.0
#45 0x00007f17165bfca3 in () at /usr/lib/libgtk-3.so.0
#46 0x00007f171639c55f in gtk_container_propagate_draw () at /usr/lib/libgtk-3.so.0
#47 0x00007f171639c62e in () at /usr/lib/libgtk-3.so.0
#48 0x00007f171634c5e5 in () at /usr/lib/libgtk-3.so.0
#49 0x00007f17163a18dd in () at /usr/lib/libgtk-3.so.0
#50 0x00007f17163a6717 in () at /usr/lib/libgtk-3.so.0
#51 0x00007f171634eed2 in () at /usr/lib/libgtk-3.so.0
#52 0x00007f17165bfb3a in () at /usr/lib/libgtk-3.so.0

----

Application: kicad
Version: (6.0.0-rc1-dev-1184-g86273e86b), debug build
Libraries:
    wxWidgets 3.0.4
    libcurl/7.62.0 OpenSSL/1.1.1 zlib/1.2.11 libidn2/2.0.5 libpsl/0.20.2 (+libidn2/2.0.4) libssh2/1.8.0 nghttp2/1.34.0
Platform: Linux 4.18.16-arch1-1-ARCH x86_64, 64 bit, Little endian, wxGTK
Build Info:
    wxWidgets: 3.0.4 (wchar_t,wx containers,compatible with 2.8) GTK+ 3.24
    Boost: 1.68.0
    OpenCASCADE Community Edition: 6.9.1
    Curl: 7.62.0
    Compiler: GCC 8.2.1 with C++ ABI 1013

Build settings:
    USE_WX_GRAPHICS_CONTEXT=OFF
    USE_WX_OVERLAY=OFF
    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

description: updated
Changed in kicad:
milestone: none → 5.1.0

@John,

I am guessing you are using the legacy canvas on GTK3.

If you are trying to use the legacy canvas on GTK3, it just does not work.
If you have this issue on GTK2, please send the gerber file that creates this issue.

John Beard (john-j-beard) wrote :

Aha! I changed 'canvas_type' to '1' (was '0') in my gerbview config and it worked (since I couldn't get into the program, I couldn't use the menu!) Thanks!

I was just running plain gerbview, with no arguments, btw.

If 5.1 will ship with the legacy canvas enabled, should this be guarded against? Touching F9 is a poke of death and then you can't run the program up again to change it back.

Hi John
This issue exists only in Debug mode.
So "normal" users should not see this issue.

To answer your question, if Kicad is compiled using GTK3 (obviously on Linux) the legacy canvas should be disabled in Pcbnew and Gerbview.

Nick Østergaard (nickoe) wrote :

Is this something we should change for now? If not I guess we can mark this bug as invalid.

I guess what was seen here was that John had a config where legacy canvas was used for gerbview from his gtk2 build days, and now he migrated to gtk3 builds and the conf stayed the same.

Should we make sure legacy is not used when using gtk3 or ignore?

I guess after 5.1.0 is is probably a good idea to ifdef or directly remove all the legacy only stuff such that we can easily remove it?

tags: added: gtk3 legacy
John Beard (john-j-beard) wrote :

We could have a CMake flag like DISABLE_LEGACY_CANVAS (which is, if not given, set automatically by the condition of HAVE_GTK3 (which implies Linux).

Then this can be use to mark out simple areas of code that can be culled later on. At least:

* Disable F9 hotkey
* Disable menu items
* On config read, convert canvas_type=0 to 1
* Any other ways to get a user into trouble with legacy + GTK3

And a stretch goal:

* any obvious areas that can be ifdeff'ed out without spending major effort to untangle (if it needs extensive refactoring, but doesn't actively cause harm in 5.1, perhaps it's a 6 thing)

I think on 5.1 release, quite a few distros will be using gtk3, so we don't want the bugs in legacy to be able to poke through too easily.

Wayne Stambaugh (stambaughw) wrote :

@John, this makes sense to me. I think once the legacy canvas is disabled, non of legacy tool code will get called so it shouldn't be necessary to #ifdef out all legacy tool code. We may not want to enable the cairo canvas rather than the opengl canvas just in case the user has a system with buggy opengl.

summary: - Out-of-range asserts on Gerbview startup
+ Legacy canvas should be disabled in GTK3 based builds
Changed in kicad:
assignee: nobody → John Beard (john-j-beard)
status: New → In Progress
KiCad Janitor (kicad-janitor) wrote :

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

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  Edit
Everyone can see this information.

Other bug subscribers