wrcad / xictools

XicTools: Xic graphical editor, WRspice circuit simulator, and accessories. for electronic design.
http://wrcad.com
146 stars 42 forks source link

Buffer overflow for print and plot commands #26

Open AdroitErudite opened 2 weeks ago

AdroitErudite commented 2 weeks ago

Description

Using the print more than one line causes a buffer overflow error. And attempting to plot more than one vector at a time causes a buffer overflow error. Unsure if this is two separate issues or one issue.

Version

WRspice Version 4.3.21, (tested in GTK2, QT5) System Ubuntu 24.04

Steps to replicate print buffer overflow.

In case of print command, open WRspice command line interface and either print something twice or simply enter some math expressions. Using print pi produces identical results.

WRspice 1 -> pi

pi = 3.141593

WRspice 2 -> pi

*** buffer overflow detected ***: terminated

Received signal 6, exiting.

Printing something that is a single digit, 0-9, gives buffer overflow after three times instead of two. Additionally, printing any statement that is two lines or more like printing a whole vector also causes the crash. If you have vector v(1) from a transient analysis.

WRspice 4 -> print v(1)

CKT2
Transient analysis                                  Fri Nov  8 15:24:26 2024
------------------------------------------------------------------------------
Index   time            v(1)            
------------------------------------------------------------------------------
*** buffer overflow detected ***: terminated

Received signal 6, exiting.

Steps to replicate plot buffer overflow.

For the plot command, run any example circuit file that plots multiple vectors with a single line. The modified example sfq.cir will run without issue:

V0 1 0 gpulse(0 0 20p 2p 0 40p)
L0 1 2 10p
B0 2 0 100 jj3 ics=0.2mA
R0 2 0 2

.model jj3 jj(level=1)

.control
tran .1p 100p uic
plot v(1)
plot v(2)
.endc

The following will crash with buffer overflow:

V0 1 0 gpulse(0 0 20p 2p 0 40p)
L0 1 2 10p
B0 2 0 100 jj3 ics=0.2mA
R0 2 0 2

.model jj3 jj(level=1)

.control
tran .1p 100p uic
plot v(1) v(2)
.endc

This was tested in GTK2 and QT5 builds with identical results to ensure the plot command was not failing due to GUI issues.