segfault when dragging a PCB trace in OpenGL or Canvas mode

Bug #1657226 reported by tijuca
26
This bug affects 2 people
Affects Status Importance Assigned to Milestone
KiCad
Fix Released
Critical
Unassigned

Bug Description

Debian KiCad version 4.0.4 and 4.0.5 is segfaulting if I try to move a trace if I'm in OpenGL (F11) or Canvas (F12) mode and the Interactive Routing is enabled with Interactive Drag.

Please see further information in the respective Debian bug report:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=841539

I tried to create a GDB log (see linked report) of the behaviour but the log may missing some debugging symbols. But it looks like the source is not respecting some platform depended environments?

Let me know if I can provide more information.

Regards
Carsten

Changed in kicad:
importance: Undecided → Critical
Revision history for this message
tijuca (c-schoenert) wrote :

This issue doesn't happen in current nightly builds.

tags: added: cern gal pns
Revision history for this message
Nick Østergaard (nickoe) wrote :

Maybe try to build a debu build with -DCMAKE_BUILD_TYPE=Debug and get a new backtrace.

Revision history for this message
Nick Østergaard (nickoe) wrote :

This might be related to
[Kicad-developers] [PATCH] Fix crash when switching from dragging to routine (PNS router)
https://lists.launchpad.net/kicad-developers/msg28510.html

Revision history for this message
Hannes Diethelm (hennes) wrote :
Download full text (4.1 KiB)

Hello,

I found the line of code which is responsible for the segfault. With the attached patch, KiCad doesn't crash any more and dragging works. However, the GUI looks a bit funny because the selection is not cleared.

It is not a real bug-fix, but it is a starting point.

When the line router_tool.cpp:798 m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true ); in ROUTER_TOOL::InlineDrag() is commented out, there is no segfault any more.

When m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true ); is executed, the program continues to tool_manager.cpp:551 in TOOL_MANAGER::dispatchInternal() and crashes at line st->cofunc->Call( aEvent ); before the corresponding event function selection_tool.cpp:753 SELECTION_TOOL::clearSelection() is executed.

To me, it seams that the problem is that InlineDrag() is already a coroutine which starts a new coroutine. However, because on other systems KiCad does not crash, it could have to do something with different boost versions. Looking at coroutine.h, many things there compiled depending on the boost version.

What I did to find the line:

1.

Program received signal SIGSEGV, Segmentation fault.
0x00005555571885e0 in ?? ()
(gdb) list
165 * MacOSX requires it for file association.
166 * @see http://wiki.wxwidgets.org/WxMac-specific_topics
167 */
168 void MacOpenFile( const wxString& aFileName ) // overload wxApp virtual
169 {
170 Pgm().MacOpenFile( aFileName );
171 }
172 };
173
174 IMPLEMENT_APP( APP_SINGLE_TOP );
(gdb) bt
#0 0x00005555571885e0 in ?? ()
#1 0x00007fffe0dec5c2 in operator() (__args#0=..., this=0x5555571c3d40) at /usr/include/c++/4.9/functional:2439
#2 COROUTINE<int, TOOL_EVENT const&>::callerStub (aData=93825022049600) at /home/hannes/kicad/kicad-4.0.5+dfsg1/include/tool/coroutine.h:271
#3 0x00007ffff59aa75e in make_fcontext () from /usr/lib/x86_64-linux-gnu/libboost_context.so.1.55.0
#4 0x0000000000000000 in ?? ()

2.

(gdb) br /home/hannes/kicad/kicad-4.0.5+dfsg1/include/tool/coroutine.h:271
Breakpoint 1 at 0x7fffe0dec5b9: file /home/hannes/kicad/kicad-4.0.5+dfsg1/include/tool/coroutine.h, line 271.
(gdb) c
Continuing.
[Thread 0x7fffcd652700 (LWP 14757) exited]

Breakpoint 1, COROUTINE<int, TOOL_EVENT const&>::callerStub (aData=93825019588768)
    at /home/hannes/kicad/kicad-4.0.5+dfsg1/include/tool/coroutine.h:271
271 cor->m_retVal = cor->m_func( *( cor->m_args ) );
(gdb) c
Continuing.

Breakpoint 1, COROUTINE<int, TOOL_EVENT const&>::callerStub (aData=93825019291056)
    at /home/hannes/kicad/kicad-4.0.5+dfsg1/include/tool/coroutine.h:271
271 cor->m_retVal = cor->m_func( *( cor->m_args ) );
(gdb) c
Continuing.

Breakpoint 1, COROUTINE<int, TOOL_EVENT const&>::callerStub (aData=93825011058528)
    at /home/hannes/kicad/kicad-4.0.5+dfsg1/include/tool/coroutine.h:271
271 cor->m_retVal = cor->m_func( *( cor->m_args ) );
(gdb) c
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0x0000555556f1d920 in ?? ()

3.

COROUTINE<int, TOOL_EVENT const&> is used in common/tool/tool_manager.cpp:545
Add:
tool_manager.cpp:551
std::cout << aEvent.Format() << std::endl;

4.

Out...

Read more...

Revision history for this message
Eldar Khayrullin (eldar) wrote :

This test file contain 3 segments of tracks.
If try to drag (key D) middle track then pcbnew crash.
It is true for a real board with nets too.

Application: pcbnew
Version: no-vcs-found-feba091~58~ubuntu16.10.1, release build
Libraries: wxWidgets 3.0.2
           libcurl/7.50.1 OpenSSL/1.0.2g zlib/1.2.8 libidn/1.33 librtmp/2.3
Platform: Linux 4.8.0-41-generic x86_64, 64 bit, Little endian, wxGTK
- Build Info -
wxWidgets: 3.0.2 (wchar_t,wx containers,compatible with 2.8)
Boost: 1.61.0
Curl: 7.50.1
KiCad - Compiler: GCC 6.2.0 with C++ ABI 1010
        Settings: USE_WX_GRAPHICS_CONTEXT=OFF
                  USE_WX_OVERLAY=OFF
                  KICAD_SCRIPTING=ON
                  KICAD_SCRIPTING_MODULES=ON
                  KICAD_SCRIPTING_WXPYTHON=ON
                  KICAD_SCRIPTING_ACTION_MENU=ON
                  BUILD_GITHUB_PLUGIN=ON
                  KICAD_USE_OCE=ON

Changed in kicad:
status: New → Confirmed
Eldar Khayrullin (eldar)
tags: added: pcbnew
tags: added: stable
Changed in kicad:
status: Confirmed → Fix Committed
tags: added: 4.0.4 4.0.5 4.0.6
removed: stable
Revision history for this message
Hannes Diethelm (hennes) wrote :

Hello,

Thanks for the fix! I tested 4.0.7 and it works!

Regards,
Hannes

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.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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