[SRU] ngspice-36 crashes in various ways
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
ngspice (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
Jammy |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
[ Impact ]
ngspice will sometimes crash on some trivial circuits and will result in Segmentation fault.
Though upstream mentioned these types of circuits causing the segfault as "strange input".
[ Test Plan ]
* create a test file named "test.netlist" with the following content:
.title KiCad schematic
.save all
.probe alli
.end
* execute "ngspice" command
* run this command: "source test.netlist" on the ngspice prompt.
With the fixed package it will print:
Circuit: KiCad schematic
[ Where problems could occur ]
It is an upstream patch which only adds an check for a pointer before dereferencing it and there is a little chance of any regression because of this patch.
[racb] The modprobenames function will now do nothing under some circumstances. This seems OK and is the intention of this change, but if there's a regression then it is likely to be because of a consequence of this. It always needs to dereference a pointer, and a null pointer deference is always bad, so in the worst case it seems like it would be that the bug isn't really fixed, eg. some kind of silent failure or logic error.
[ Other Info ]
The patch in the debdiff looks quite big due to the indentation changes but the real change is only:
@@ -1130,6 +1130,7 @@ static char* get_terminal_
Called from inp.c*/
void modprobenames(
GENinstance* GENinst;
+ if (tab->defVmod) {
for (GENinst = tab->defVmod-
char* name = GENinst->GENname;
/* Do not inlude the x in the new name, XU1 -> U1 */
@@ -1159,4 +1160,5 @@ void modprobenames(
}
}
}
+ }
}
[ Original Bug Description ]
$ lsb_release -rd
Description: Ubuntu 22.04.3 LTS
Release: 22.04
ngspice version: 36+ds-1
The following happens:
=======
ngspice is used by KiCad to simulate circuits.
I have noticed that ngspice tends to crash or fail on relatively simple circuits.
Taking KiCad out of equation I can see that even trivialities lead to crashes.
For example, create a text file "test.netlist" with the following content:
--- CUT ---
.title KiCad schematic
.save all
.probe alli
.end
--- CUT ---
Then start ngspice command line tool and run this command: "source test.netlist".
The results would be this:
--- CUT ---
No compatibility mode selected!
Circuit: KiCad schematic
Segmentation fault (core dumped)
--- CUT ---
Other than segmentation faults, sometimes ngspice attempts to allocate a negative amount of memory (which also results in crashes).
The following is expected:
=======
I expect that ngspice would not crash and would instead either do what it is asked to do or report errors.
Suggested change:
=======
Update ngspice from version 3.6 to version 4.2: I have built v4.2 myself and checked - it appears to work or report genuine errors in all cases where the old ngspice simply crashes with no apparent reason.
ProblemType: Bug
DistroRelease: Ubuntu 22.04
Package: ngspice 36+ds-1
ProcVersionSign
Uname: Linux 6.2.0-35-generic x86_64
NonfreeKernelMo
ApportVersion: 2.20.11-0ubuntu82.5
Architecture: amd64
CasperMD5CheckR
CurrentDesktop: GNOME
Date: Wed Jan 10 14:32:41 2024
InstallationDate: Installed on 2021-07-03 (921 days ago)
InstallationMedia: Ubuntu-MATE 20.04.2.0 LTS "Focal Fossa" - Release amd64 (20210209.1)
RebootRequiredPkgs: Error: path contained symlinks.
SourcePackage: ngspice
UpgradeStatus: Upgraded to jammy on 2023-09-12 (119 days ago)
Changed in ngspice (Ubuntu Jammy): | |
status: | New → Confirmed |
Changed in ngspice (Ubuntu): | |
status: | New → Fix Released |
Changed in ngspice (Ubuntu Jammy): | |
assignee: | nobody → Sudip Mukherjee (sudipmuk) |
Changed in ngspice (Ubuntu Jammy): | |
status: | Confirmed → In Progress |
I have tested and can confirm that I can reproduce the segfault with the "test.netlist". I have also tested and confirmed Focal and Mantic are not affected.