horizon-eda / horizon

Horizon is a free EDA package
https://horizon-eda.org/
GNU General Public License v3.0
1.08k stars 79 forks source link

Board Editor and Pool Manager crash, possible project pool corruption #743

Closed alex-fu27 closed 9 months ago

alex-fu27 commented 9 months ago

I closed Horizon yesterday, and when I re-opened it today to work on the same project, the Board Editor would not open any more. Horizon will tell me it exited with status 139. When I open the Project Pool and click "remove unused", then Horizon will segfault. So probably my project pool is corrupted.

This is a commit to my project that introduces the problem, however my versioning was sloppy so this commit is rather large :frowning_face:

Edit: This is with 2.4.0 and I am currently building 2.5 to try it out

Edit: Removed a log that turned out not to be related to this.

alex-fu27 commented 9 months ago

Okay I have confirmed this also happens with 49973c6ed1fb68b48dffa9645e5aa515d8596af1 which is newer than 2.5.0

alex-fu27 commented 9 months ago

I have a plane with an uuid_ptr to a Net that has an UUID but not pointer, leading to the segfault:

(gdb) bt
#0  0x00007f78d05f8299 in __memcmp_avx2_movbe () from /nix/store/46m4xx889wlhsdj72j38fnlyyvvvvbyb-glibc-2.37-8/lib/libc.so.6
#1  0x00000000013acd6a in horizon::operator== (self=..., other=...) at ../src/util/uuid.cpp:58
#2  0x00000000010f707b in horizon::Board::update_airwire (this=0x29dd1b8, fast=false, net=...) at ../src/board/airwires.cpp:241
#3  0x00000000010f6361 in horizon::Board::update_all_airwires (this=0x29dd1b8) at ../src/board/airwires.cpp:136
#4  0x00000000011144f0 in horizon::Board::expand_some (this=0x29dd1b8) at ../src/board/board.cpp:945
#5  0x000000000074d792 in horizon::CoreBoard::rebuild_internal (this=0x29dccc8, from_undo=false, comment="init")
    at ../src/core/core_board.cpp:760
#6  0x0000000000741b1a in horizon::Core::rebuild (this=0x29dccc8, comment="init") at ../src/core/core.cpp:214
#7  0x0000000000749b11 in horizon::CoreBoard::CoreBoard (this=0x29dccc8, fns=..., pool=..., pool_caching=..., __in_chrg=<optimized out>, 
    __vtt_parm=<optimized out>) at ../src/core/core_board.cpp:59
#8  0x0000000000a3dc85 in horizon::ImpBoard::ImpBoard (this=0x29dc3a0, filenames=..., pool_params=...) at ../src/imp/imp_board.cpp:31
#9  0x0000000000aa4b78 in main (argc=1, argv=0x7fffd6e423d8) at ../src/imp/imp_main.cpp:147
(gdb) frame 2
#2  0x00000000010f707b in horizon::Board::update_airwire (this=0x29dd1b8, fast=false, net=...) at ../src/board/airwires.cpp:241
241             if (plane->net->uuid == net) {
(gdb) p plane->net
$2 = {ptr = 0x0, uuid = {static size = 16, uu = "PUm\346\246\366C\277\217o\203\fp\315e\242"}}

But I dont see how this relates to the Pool Manager crashing. Maybe I have two separate problems.

alex-fu27 commented 9 months ago

Well, cleaning up the pool cache also updates the airwires, even if the board is not open:

...
#5  0x00000000009bab5e in horizon::Board::expand (this=0x7ffc8fb04a00) at ../src/board/board.cpp:838
#6  0x00000000007770e1 in horizon::PoolProjectManagerAppWindow::cleanup_pool_cache (this=0x392ef00, parent=0x4228bf0)
    at ../src/pool-prj-mgr/pool-prj-mgr-app_win.cpp:1755
...
alex-fu27 commented 9 months ago

Okay I think I have understood the problem, and as all the things here could be a bit confusing, I have summed it up in a new issue #745.