eeschema segfault on cut-and-pasting a hierarchical child sheet

Bug #1841801 reported by Dino Ghilardi on 2019-08-28
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Jeff Young

Bug Description

eeschema segfaults on cut-and-paste of a child hierarchical sheet.

An "error" dialog pops up saying:
Error occurred loading schematic file "/home/dinoghi/file5D668DAB.sch"

Unable to open filename "/home/dinoghi/file5D668DAB.sch" for reading.

After clicking "ok" I get a segmetation fault and kicad exits.

Note that the file it is looking for is still on the disk, but the path is truncated to my user's home and it is not the full path to the file (that is /home/dinoghi/tmp/testkicad/selectMulti/select/file5D668DAB.sch).

If at least one copy of that block is present in the schematic there is no error. It seems that on the "cut" operation on the last block the path to the file is not correct anymore.

To re-create the behaviour:
1) Create a new project
2) in eeschema add a hierarchical sheet
3) ctrl-x to cut
4) ctrl-v to paste and here you get the error and the segfault exiting the error dialog.

In master branch I get the error.
In Stable 5.1.4 and 5.1.2 I don't get it.

Application: Eeschema
Version: (5.99.0-24-g494d0de9b), release build
    wxWidgets 3.0.2
    libcurl/7.52.1 OpenSSL/1.0.2s zlib/1.2.8 libidn2/0.16 libpsl/0.17.0 (+libidn2/0.16) libssh2/1.7.0 nghttp2/1.18.1 librtmp/2.3
Platform: Linux 4.9.0-8-amd64 x86_64, 64 bit, Little endian, wxGTK
Build Info:
    wxWidgets: 3.0.2 (wchar_t,wx containers,compatible with 2.8) GTK+ 2.24
    Boost: 1.69.0
    OpenCASCADE Community Edition: 6.8.0
    Curl: 7.52.1
    Compiler: GCC 6.3.0 with C++ ABI 1010

Build settings:

Jeff Young (jeyjey) on 2019-08-29
Changed in kicad:
assignee: nobody → Jeff Young (jeyjey)
importance: Undecided → Critical
status: New → In Progress
milestone: none → 6.0.0-rc1
KiCad Janitor (kicad-janitor) wrote :

Fixed in revision 02a7a79e0d033cf8b4f2ccd822d6e8f2920463e2

Changed in kicad:
status: In Progress → Fix Committed
Dino Ghilardi (dino-ghilardi) wrote :

The program does not crash anymore, but there is still an error dialog popping up: To reproduce:
-create an empty child sheet,
-cut and paste it (without saving it before)
Now you get the error window (this time the path is correct but since the file does not exist on disk until you save the schematic you get the same error pop-up saying "Error occurred loading schematic file... ").

Moreover, if you put some components in the child sheet (without saving it),go back to parent sheet and cut and paste the child sheet block you loose the child sheet content (as above: it was not saved during the cut operation and was not on disk). May be saving the child sheet content on a temp file on cut operation could be a solution).


Jeff Young (jeyjey) wrote :

I think we have to presume the user will take a bit of care. Even if we fixed the second part, you could still copy and paste the sheet, edit both copies so that they're now different, and then save. Since they're using the same file, one set of your changes will be lost.

Dino Ghilardi (dino-ghilardi) wrote :

Hi Jeff,
I'm thinking mostly at someone that just wants to move a child sheet from one page to another, does it with a cut-n-paste without saving the child sheet before and looses some data without a warning from the program.
 May be a warning pop-up during the "cut" when the child sheet has not been saved (or a request for an explicit save) can save from this situation.

By the way, If you put back the sheet after the "cut" using an undo, the child sheet (correctly) still has all of its data, that means that somewhere in memory there is still a copy of the data we need to perform the paste operation. Wouldn't it be possible to use that data instead of loading a possibly outdated copy from the file system? (I don't know how complex this could be, but can be an option that could potentially solve also the "first part")

P.S.: Also in the example you just reported (copy, modify the original, paste) a warning about possible data lost would be appreciated (well... as a user I would like being warned about any possible data lost)


Jeff Young (jeyjey) wrote :

@Dino, OK, I'll buy the using cut/paste as a move operation argument.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers