Bug 1577065

Summary: Crash when running DRC in pcbnew
Product: [Fedora] Fedora Reporter: davidk <kdavid>
Component: kicadAssignee: Chitlesh GOORAH <chitlesh>
Status: CLOSED EOL QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 28CC: chitlesh, dkonigsberg, gwync, rob+redhat, sean.happel, stevenfalco, thibault.north
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-05-28 23:20:20 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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.

Comment 5 Ben Cotton 2019-05-02 19:22:47 UTC
This message is a reminder that Fedora 28 is nearing its end of life.
On 2019-May-28 Fedora will stop maintaining and issuing updates for
Fedora 28. It is Fedora's policy to close all bug reports from releases
that are no longer maintained. At that time this bug will be closed as
EOL if it remains open with a Fedora 'version' of '28'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 28 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 6 Ben Cotton 2019-05-02 20:15:59 UTC
This message is a reminder that Fedora 28 is nearing its end of life.
On 2019-May-28 Fedora will stop maintaining and issuing updates for
Fedora 28. It is Fedora's policy to close all bug reports from releases
that are no longer maintained. At that time this bug will be closed as
EOL if it remains open with a Fedora 'version' of '28'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 28 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 7 Ben Cotton 2019-05-28 23:20:20 UTC
Fedora 28 changed to end-of-life (EOL) status on 2019-05-28. Fedora 28 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.