Bug 1577065 - Crash when running DRC in pcbnew
Summary: Crash when running DRC in pcbnew
Status: NEW
Alias: None
Product: Fedora
Classification: Fedora
Component: kicad   
(Show other bugs)
Version: 28
Hardware: x86_64 Linux
Target Milestone: ---
Assignee: Chitlesh GOORAH
QA Contact: Fedora Extras Quality Assurance
Depends On:
TreeView+ depends on / blocked
Reported: 2018-05-11 06:49 UTC by davidk
Modified: 2018-11-25 14:30 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

External Trackers
Tracker ID Priority Status Summary Last Updated
Launchpad 1770414 None None None Never

Description davidk 2018-05-11 06:49:20 UTC
Description of problem: When running design rules check (DRC) in KiCAD's pcbnew tool, the application crashes completely.

Version-Release number of selected component (if applicable): kicad-4.0.7-3.fc28.x86_64

How reproducible: Always

Steps to Reproduce:

1. Open a board in pcbnew
2. Go to Tools -> DRC
3. Click Start DRC

Actual results: Crashes and exits to desktop.

Expected results: DRC runs and shows error messages.

Additional info:

I retrieved a core from the crashed application:

--- core ---
(gdb) backtrace
#0  0x00007f735398bf4b in raise () from /lib64/libc.so.6
#1  0x00007f7353976591 in abort () from /lib64/libc.so.6
#2  0x00007f73274135e8 in std::__replacement_assert (
    __file=__file@entry=0x7f7327adcee0 "/usr/include/c++/8/bits/stl_vector.h", __line=__line@entry=932, 
    __function=__function@entry=0x7f7327af6c60 <_ZZNSt6vectorIP5D_PADSaIS1_EEixEmE19__PRETTY_FUNCTION__> "std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = D_PAD*; _Alloc = std::allocator<D_PAD*>; std::vector<_Tp, _Alloc>::reference ="..., 
    __condition=__condition@entry=0x7f7327adceb0 "__builtin_expect(__n < this->size(), true)")
    at /usr/include/c++/8/x86_64-redhat-linux/bits/c++config.h:2389
#3  0x00007f7327623487 in std::vector<D_PAD*, std::allocator<D_PAD*> >::operator[] (
    __n=<optimized out>, this=0x7ffe360720f0)
    at /usr/src/debug/kicad-4.0.7-3.fc28.x86_64/pcbnew/drc.cpp:456
#4  DRC::testPad2Pad() () at /usr/src/debug/kicad-4.0.7-3.fc28.x86_64/pcbnew/drc.cpp:456
--- core ---

The relevant code section is here (being around the build date for this RPM): https://github.com/KiCad/kicad-source-mirror/blob/3b16d3cffe683ef556556c9242db6ccafc8ce65a/pcbnew/drc.cpp#L456

I believe that this crash is traceable to the new hardening flags introduced in F28 ( https://fedoraproject.org/wiki/Changes/HardeningFlags28 ), specifically "-D_GLIBCXX_ASSERTIONS"

To test, I rebuilt the RPM with the macro removed from /usr/lib/rpm/redhat/macros. When built without that flag, KiCAD appears to run DRC without crashing.

Additional Note:

In order to build a working test RPM, I had to run `rm ./rpmbuild/SOURCES/kicad-4.0.7/CMakeModules/CheckCXXSymbolExists.cmake`. Please see https://www.mail-archive.com/kicad-developers@lists.launchpad.net/msg29834.html for a more through explanation.

Comment 1 Sean Happel 2018-06-13 17:44:35 UTC
Verified that this problem exists on my system as well.  Inspection of the code shows frame 3 in the listed stack <pcbnew/drc.cpp:456> is: 

455:   // Test the pads
456:    D_PAD** listEnd = &sortedPads[ sortedPads.size() ];

This is an error in the source code, and SHOULD cause the static assert to abort.
A recommended patch would be to replace this line with:
:  D_PAD** listEnd = 0;
:  if(!sortedPads.empty())
:    listEnd = sortedPads.data() + sortedPads.size();
OR (if kicad doesn't use C++11)
:  D_PAD** listEnd = 0;
:  if(!sortedPads.empty())
:    listEnd = (&sortedPads[0]) + sortedPads.size();

This should be fixed in the kicad source.  In the meantime, Fedora might want to add this patch to the rpm so that kicad is a usable tool - without a DRC, kicad cannot be used for design work.

Comment 2 davidk 2018-06-13 23:53:05 UTC
As a workaround, i've begun using the Kicad nightlies, which have the upstream fix: https://copr.fedorainfracloud.org/coprs/g/kicad/kicad/

Comment 3 Rob Riggs 2018-11-25 00:01:44 UTC
Any chance this will be fixed in F28?

Comment 4 Steven A. Falco 2018-11-25 14:30:51 UTC
It doesn't look like the KiCad team is planning to release a 4.0.8.  In https://launchpad.net/bugs/1770414 they recommend using their official KiCad 5.x copr builds instead.  Upstream development effort is focused on the 5.x and 6.0 branches, and building 4.x releases for all the different platforms (Mac, Windows, multiple Linuxes, etc.) would take more effort than they can spare.

For Fedora 27 and 28, I recommend using their copr.  I've run it myself and it seems quite solid.

Additionally, in Fedora 29, you can now install a production build of KiCad 5.  The current release in F29 is kicad-5.0.1-1.fc29.x86_64.  I just released a little 4-layer board to mfg using that release and the boards came back perfect.

Note You need to log in before you can comment on or make changes to this bug.