KiCad crashes when using a `PXXXXX` component in simulation

I am using

Application: KiCad x86_64 on x86_64

Version: 9.0.5, release build

Libraries:
	wxWidgets 3.2.8
	FreeType 2.14.1
	HarfBuzz 11.4.5
	FontConfig 2.17.1
	libcurl/8.15.0 OpenSSL/3.5.4 zlib/1.3.1 zstd/1.5.7 libidn2/2.3.8 libpsl/0.21.5 nghttp2/1.66.0

Platform: Freedesktop SDK 25.08 (Flatpak runtime), 64 bit, Little endian, wxGTK, X11, gnome, wayland

Build Info:
	Date: Nov 11 2011 11:11:11
	wxWidgets: 3.2.8 (wchar_t,wx containers) GTK+ 3.24
	Boost: 1.89.0
	OCC: 7.9.1
	Curl: 8.15.0
	ngspice: 45.2
	Compiler: GCC 15.2.0 with C++ ABI 1020
	KICAD_IPC_API=ON

Locale: 
	Lang: en_US
	Enc: UTF-8
	Num: 1,234.5
	Encoded кΩ丈: D0BACEA9E4B888 (sys), D0BACEA9E4B888 (utf8)

I have the following simulation model in twinax.sub file which I copy-pasted from the ngspice manual:

.subckt twinax in1 in2 gnd1 out1 out2 gnd2
P1 in1 in2 gnd1 out1 out2 gnd2 PLINE
.model PLINE CPL length={Len}
+R=1 0 1
+L={L11} {L12} {L22}
+G=0 0 0
+C={C11} {C12} {C22}
.param Len=1 Rs=0
+ C11=9.143579E-11 C12=-9.78265E-12 C22=9.143578E-11
+ L11=3.83572E-7 L12=8.26253E-8 L22=3.83572E-7
.ends

and the following symbol:

(kicad_symbol_lib
	(version 20241209)
	(generator "kicad_symbol_editor")
	(generator_version "9.0")
	(symbol "TLINE_twinax"
		(pin_numbers
			(hide yes)
		)
		(pin_names
			(hide yes)
		)
		(exclude_from_sim no)
		(in_bom no)
		(on_board no)
		(property "Reference" "T"
			(at 0 7.62 0)
			(effects
				(font
					(size 1.27 1.27)
				)
			)
		)
		(property "Value" "TLINE_twinax"
			(at 0 5.08 0)
			(effects
				(font
					(size 1.27 1.27)
				)
			)
		)
		(property "Footprint" ""
			(at 0 0 0)
			(effects
				(font
					(size 1.27 1.27)
				)
				(hide yes)
			)
		)
		(property "Datasheet" "https://ngspice.sourceforge.io/docs/ngspice-html-manual/manual.xhtml#sec_Lossless_Transmission_Lines"
			(at 0 5.08 0)
			(effects
				(font
					(size 1.27 1.27)
				)
				(hide yes)
			)
		)
		(property "Description" "Lossless transmission line, for simulation only"
			(at 0 0 0)
			(effects
				(font
					(size 1.27 1.27)
				)
				(hide yes)
			)
		)
		(property "ki_keywords" "lossless transmission line characteristic impedance"
			(at 0 0 0)
			(effects
				(font
					(size 1.27 1.27)
				)
				(hide yes)
			)
		)
		(symbol "TLINE_twinax_0_1"
			(rectangle
				(start -5.08 1.27)
				(end 5.08 -3.81)
				(stroke
					(width 0)
					(type default)
				)
				(fill
					(type none)
				)
			)
		)
		(symbol "TLINE_twinax_1_1"
			(pin passive line
				(at -7.62 0 0)
				(length 2.54)
				(name "NI1"
					(effects
						(font
							(size 1.27 1.27)
						)
					)
				)
				(number "1"
					(effects
						(font
							(size 1.27 1.27)
						)
					)
				)
			)
			(pin passive line
				(at -7.62 -2.54 0)
				(length 2.54)
				(name "NI2"
					(effects
						(font
							(size 1.27 1.27)
						)
					)
				)
				(number "2"
					(effects
						(font
							(size 1.27 1.27)
						)
					)
				)
			)
			(pin passive line
				(at -5.08 -6.35 90)
				(length 2.54)
				(name "GND1"
					(effects
						(font
							(size 1.27 1.27)
						)
					)
				)
				(number "5"
					(effects
						(font
							(size 1.27 1.27)
						)
					)
				)
			)
			(pin passive line
				(at 5.08 -6.35 90)
				(length 2.54)
				(name "GND2"
					(effects
						(font
							(size 1.27 1.27)
						)
					)
				)
				(number "6"
					(effects
						(font
							(size 1.27 1.27)
						)
					)
				)
			)
			(pin passive line
				(at 7.62 0 180)
				(length 2.54)
				(name "NO1"
					(effects
						(font
							(size 1.27 1.27)
						)
					)
				)
				(number "3"
					(effects
						(font
							(size 1.27 1.27)
						)
					)
				)
			)
			(pin passive line
				(at 7.62 -2.54 180)
				(length 2.54)
				(name "NO2"
					(effects
						(font
							(size 1.27 1.27)
						)
					)
				)
				(number "4"
					(effects
						(font
							(size 1.27 1.27)
						)
					)
				)
			)
		)
		(embedded_fonts no)
	)
)

When I try to assign the simulation model it crashes when I select the file (see screenshot below). What happens is that KiCad freezes and one CPU core goes to 100 % usage. Only solution is killall kicad (I waited about 2 minutes).

Any ideas?


”dous not exist”. is “not a crash”, but if it is, I think you can find the cause more quickly by attaching the results of the crash dump.

No, that is not the problem I am having, that is the normal behavior when the file does not exist and it does what is expected. But when I choose that particular model I posted, it crashes.

Where is the crash dump located?

Please check & search keyword “Freedesktop crash dump”. It is not a KiCAD issue but a Freedesktop community topic. Normally, if you set the environment variable and start KiCAD, the crash dump size limiter of 0 will be released and a crash dump file should be generated.

Seems to be a bug in how KiCad is parsing the twinax.sub file because:

  1. If I modify it to the following:
    ;* Twinax transmission line model using CPL
    ;* Parameters: Zeven, Zodd, k (coupling coefficient), Time (propagation delay in seconds)
    ;
    ;.subckt twinax in1 in2 gnd1 out1 out2 gnd2
    ;	+PARAMS:
    ;		+Zeven=100
    ;		+Zodd=50
    ;		+k=0.1
    ;		+td=5n
    ;
    ;	.param v = 2e8 ; propagation velocity
    ;	.param Len = v * td
    ;
    ;	* Calculate L and C values from characteristic impedances
    ;	.param C_even = 1/(Zeven*v)
    ;	.param C_odd  = 1/(Zodd*v)
    ;	.param C12    = -k * sqrt(C_even * C_odd)
    ;
    ;	.param L_even = Zeven * C_even
    ;	.param L_odd  = Zodd * C_odd
    ;	.param L12    = k * sqrt(L_even * L_odd)
    ;
    ;	.model TWINAX CPL length={Len}
    ;	+ R=0 0
    ;	+ L={L_even} {L12} {L_odd}
    ;	+ G=0 0
    ;	+ C={C_even} {C12} {C_odd}
    ;
    ;	* Instance of the CPL line
    ;	P1 in1 in2 gnd1 out1 out2 gnd2 TWINAX LEN={Len}
    ;
    ;.ends
    
    
    .subckt twinax a b c d e f
    R1 a d 100
    R2 b e 100
    .ends
    
    then it fails but does not crash. It just does not recognize any model in the file.
  2. If I modify it to
    .subckt twinax a b c d e f
    R1 a d 100
    R2 b e 100
    .ends
    
    it works as expected.

Is * a valid comment line and ; a specific Dialects provided by specific vendors.
Did this produce a core dump?

I refined more my search after doing several tests and found that the problem is when using a PXXXXXX element. If I copy-paste the example from ngspice manual into the twinax.sub file:

.subckt twinax in1 in2 gnd1 out1 out2 gnd2
P1 in1 in2 gnd1 out1 out2 gnd2 PLINE
.model PLINE CPL length={Len}
+R=1 0 1
+L={L11} {L12} {L22}
+G=0 0 0
+C={C11} {C12} {C22}
.param Len=1 Rs=0
+ C11=9.143579E-11 C12=-9.78265E-12 C22=9.143578E-11
+ L11=3.83572E-7 L12=8.26253E-8 L22=3.83572E-7
.ends

this makes KiCad to freeze. I will update the original question with this info.

Any ideas on how to simulate a PXXXX in KiCad?

1 Like

https://gitlab.com/kicad/code/kicad/-/issues/17824
It may be different, but is it relevant to this?

1 Like

Yes, I think I am facing the same exact issue, thanks for pointing it out. Will try with the workaround from there.

and the project: KiCAD_now_working.zip
cpl_subc_orig.lib → cpl_subc.lib & cpl_subc2.lib ← split(.include) try?!?

Yes, with that trick it works. I opened a new issue reporting this is happening again in the new KiCad version.

The issue opened on gitlab is:

This is not exactly true.

Eeschema does not understand

.model PLINE CPL length={Len} R=1 0 1 L={L11} {L12} {L22} G=0 0 0 C={C11} {C12} {C22}

It wants to read

.model PLINE CPL length={Len} R={R11} {R12} {R22} L={L11} {L12} {L22} G={G11} {G12} {G22} C={C11} {C12} {C22}

which is working only after the bug fix in Parsing of multi parameter fails for the Coupled Multiconductor Line (CPL) (#17824) · Issues · KiCad / KiCad Source Code / kicad · GitLab . So R=1 0 1 is not supported.

2 Likes