KiCad Nightly 7.99 crashes if you try to run simulator when a transistor spice model is missing

Has anyone had the problem that KiCad crashes when you have drawn a simple schematic with voltage source, two resistors, LED and a transistor, and you forgot to define a model for the transistor?

In 7.0 it opens the simulator window, and when you try to run an operating point simulation you get some error message in the spice output field (lower left), but at least it doesn’t crash.

This is an example circuit I did just to test this out. I discovered it in another schematic before that.
It simulates just fine if I go to properties for the transistor and choose a spice model file.
If not, crash of the whole KiCad application as soon as you klick the simulation button in the upper toolbar or choose simulte from the Inspect menu.

(I know that it is development version etc. and developers can choose whether to leave the bugs for the last minute or fix earlier. But I’m still curious to hear if someone else has the same problem.)

bild

There isn’t anything interesting on the left outside the screenshot, just a connector that is excluded from the simulation.

Todays and yesterdays nightly both crash the same way.

Application: KiCad Schematic Editor x86_64 on x86_64

Version: 7.99.0-1.20230308git74a9d79.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 8 2023 18:16:47
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

It is a known issue in KiCad that if you don’t define a model for a transistor and try to run a simulation, it can cause the application to crash. This is because the simulator needs to have the parameters for the transistor defined in order to run a simulation.

To avoid this issue, always make sure to define a model for each transistor you use in your schematic before running a simulation.

Obviously the “workaround” is to have all models defined correctly, but there is no good reason that the application should crash if a model is missing. Instead it should give a message like “the simulation cannot be run because symbol(s) XYZ do not have SPICE models defined”.

If it is a known issue, do you know if there is an issue about it in gitlab?

The ones that could be remotely related that I found in gitlab were:
#9756 - here a general isolation of the KiCad process from the ngspice process is suggested, to protect the former from crashing if the later one crashes. This has not been implemented yet and the issue is open.

Closed issues:
#7180 - here ngspice was fixed in version 34 to not crash on a heatsink symbol

#7901 - same issue as #7180 with heatsink etc. and fixed by upgrading to ngspice 34

#8224 - also fixed by updating to ngspice 34

#8336 - fixed by packaging ngspice 34 on MacOS

I’m on ngspice 39, so this seems to be a different issue than the closed ones.
I anticipate that #9756 would solve it at least partly, and have upvoted the issue. But it seems they don’t have a crash report attached to that since ngspice 34, and here I do have a crash…

Please zip and post your project here. I will have a look.

1 Like

Here is an example project that crashes both 7.0.1 and 7.99 nightly from yesterday as well as the build mentioned above in my original post.
Note that the behaviour is a little different between 7.0.1 which crashes when you press the play button in the simulator window trying to make an operating point simulation, and 7.99 which crashes as soon as you press the simulate icon in schematic editor.

See also issue #14295
Sim_crash_missing_model_test-1.zip (4.8 KB)
in gitlab.

This is now fixed in 7.99 nightly with commit 6d296038 by @JeffYoung that gives an error message and doesn’t send erroneous data to ngspice, and another fix by @holger in ngspice which will come in version 40, and make ngspice not crash on erroneous model definition input.

Thanks to both Jeff and Holger for the fixes!

1 Like

Now there is also a fix in commit 70e86434 for 7.0 stable, which will appear in the 7.0.2 release (and can be “test driven” in the next testing build for those OS:es that have those).

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.