KiCad Nightly 7.99 and 7.0.1 crashes if you try to run simulator when a transistor spice model is missing
Description
KiCad crashes when you have drawn a simple schematic with voltage source, two resistors and a transistor, and you forgot to define a model for the transistor, and then press the icon for simulator or klick simulate from the Inspect menu (7.99 nightly) or when you have opened the simulation window and try to run an operating point simulation (7.0.1).
Sim_crash_missing_model_test-1.zip
Expected behaviour: Do not crash the entire KiCad application, but instead give an error message that simulation cannot be run because the model of the transistor is not defined.
Note: This will probably apply for at least some other symbols besides the transistor, which do not automatically have built in models defined for them, like resistors, capacitors etc.
$ kicad-nightly
/usr/bin/kicad-nightly: rad 5: 169414 Segmenteringsfel (minnesutskrift skapad) /usr/lib64/kicad-nightly/bin/kicad "$@"
$
Stack trace of thread 169414:
#0 0x00007f81568a905b cieq (libngspice.so.0 + 0x8a905b)
#1 0x00007f815615993b pspice_compat.lto_priv.0 (libngspice.so.0 + 0x15993b)
#2 0x00007f8156149dd5 inp_readall (libngspice.so.0 + 0x149dd5)
#3 0x00007f815614bc1a inp_spsource (libngspice.so.0 + 0x14bc1a)
#4 0x00007f815614e575 create_circbyline (libngspice.so.0 + 0x14e575)
#5 0x00007f8156124161 ngSpice_Circ (libngspice.so.0 + 0x124161)
#6 0x00007f8199d9b14c _ZN7NGSPICE11LoadNetlistERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE (_eeschema.kiface + 0xb9b14c)
#7 0x00007f8199d9b654 _ZN7NGSPICE6AttachERKSt10shared_ptrI16SIMULATION_MODELER8REPORTER (_eeschema.kiface + 0xb9b654)
#8 0x00007f8199d9fd36 _ZN15SIMULATOR_FRAME13LoadSimulatorEv (_eeschema.kiface + 0xb9fd36)
#9 0x00007f8199da6a78 _ZN15SIMULATOR_FRAME12initWorkbookEv (_eeschema.kiface + 0xba6a78)
#10 0x00007f8199daa271 _ZN15SIMULATOR_FRAMEC2EP5KIWAYP8wxWindow (_eeschema.kiface + 0xbaa271)
#11 0x00007f81997983eb _ZN3SCH5IFACE14CreateKiWindowEP8wxWindowiP5KIWAYi (_eeschema.kiface + 0x5983eb)
#12 0x000055c4fc062f67 _ZN5KIWAY6PlayerE7FRAME_TbP16wxTopLevelWindow (kicad + 0x176f67)
#13 0x00007f8199cc7361 _ZN18EE_INSPECTION_TOOL13RunSimulationERK10TOOL_EVENT (_eeschema.kiface + 0xac7361)
#14 0x00007f8199f38e20 _ZNKSt8functionIFiRK10TOOL_EVENTEEclES2_ (_eeschema.kiface + 0xd38e20)
#15 0x00007f819a232301 make_fcontext (_eeschema.kiface + 0x1032301)
ELF object binary architecture: AMD x86-64
This could possibly be related to the open issue #9756 (open). There are some closed issues #7180 (closed), #7901 (closed), #8224 (closed) and #8336 (closed) that look somewhat similar, but these seem to all be solved with ngspice 34, and as I am on ngspice 39 they obviously didn't solve this issue.
Also mentioned in forum thread: https://forum.kicad.info/t/kicad-nightly-7-99-crashes-if-you-try-to-run-simulator-when-a-transistor-spice-model-is-missing/40800/3
Steps to reproduce
- Load the example project provided above, or draw your own equivalent schematic in KiCad 7.0.1 or 7.99.
- Klick simulate icon in the top toolbar. KiCad 7.99 now crashes immediately (an you have lost your work unless you remembered to save it just before you tried to simulate..). See stack trace above. For KiCad 7.0.1 proceed to step 3.
- In the simulator window that opens, choose menu Simulation -> Settings... -> Tab "Operating Point" -> Klick OK (for default settings)
- Now press the play button to run simulation: KiCad crashes.
KiCad Version
Application: KiCad Schematic Editor x86_64 on x86_64
Version: 7.99.0-1.20230313git664e562.fc37, release build
Libraries:
wxWidgets 3.2.1
FreeType 2.12.1
HarfBuzz 5.2.0
FontConfig 2.14.1
libcurl/7.85.0 OpenSSL/3.0.8 zlib/1.2.12 brotli/1.0.9 libidn2/2.3.4 libpsl/0.21.1 (+libidn2/2.3.3) libssh/0.10.4/openssl/zlib nghttp2/1.51.0
Platform: Fedora release 37 (Thirty Seven), 64 bit, Little endian, wxGTK, KDE, wayland
Build Info:
Date: Mar 13 2023 18:16:46
wxWidgets: 3.2.1 (wchar_t,wx containers) GTK+ 3.24
Boost: 1.78.0
OCC: 7.6.3
Curl: 7.85.0
ngspice: 39
Compiler: GCC 12.2.1 with C++ ABI 1017
Build settings:
KICAD_SPICE=ON
Application: KiCad Schematic Editor x86_64 on x86_64
Version: 7.0.1-1.fc37, release build
Libraries:
wxWidgets 3.2.1
FreeType 2.12.1
HarfBuzz 5.2.0
FontConfig 2.14.1
libcurl/7.85.0 OpenSSL/3.0.8 zlib/1.2.12 brotli/1.0.9 libidn2/2.3.4 libpsl/0.21.1 (+libidn2/2.3.3) libssh/0.10.4/openssl/zlib nghttp2/1.51.0
Platform: Fedora release 37 (Thirty Seven), 64 bit, Little endian, wxGTK, KDE, wayland
Build Info:
Date: Mar 10 2023 00:00:00
wxWidgets: 3.2.1 (wchar_t,wx containers) GTK+ 3.24
Boost: 1.78.0
OCC: 7.6.3
Curl: 7.85.0
ngspice: 39
Compiler: GCC 12.2.1 with C++ ABI 1017
Build settings:
KICAD_SPICE=ON