| rif |
I've just tried for the first time to execute spice on a command line and can't seem to get it to work even for trivial netlists (including known good examples).
Any idea where to start to troubleshoot?
I use the command:
spice test1.net -r test1.out
or
spice3 test1.net -r test1.out
It begins and states the circuit title (from the title in the netlist), but then always gives a "Segmentation Fault".
I searched the manuals I could find online, but to no avail. |
|
|
| tlf9999 |
| no linux expert but "segmentation error" is not a spice error message rather a linux/unix error message. likely the program isn't correctly compiled / linked. |
|
|
| wes-ninja250 |
Segmentation fault literally means that the program tried to access memory outside of the regions (segments) that have been allocated to the program by the operating system. Roughly equivalent to a general protection fault under Windows.
In 98% of cases, this is caused by dereferencing NULL (address 0) -- probably because something wasn't set/loaded/configured properly.
If you have some programming experience, you can read the core dump with gdb, or follow the program's "work" with strace. These may provide clues.
It's a little more difficult under Linux to guess at these types of problems, due to things like the 58 versions of LibC, blah blah blah that that platform has.
My immediate recommendation -- if you installed from a package, try building from sources instead.
Wes |
|
|
| rif |
I'll give that a try tonight. I did install from a package -- I'm running gentoo. But that means it actually compiles the source and doesn't just install pre-existing binaries.
Hopefully it's just a config file issue somewhere.
If not, I'll give ngspice a try -- I'm not doing anything too fancy |
|
|
| wes-ninja250 |
If you're one of those Gentoo guys with a 48-line CPPFLAGS (and have no clue what any of the settings do ) -- do yourself a favour and turn everything off that is not essential for building the program.
Wes |
|
|
| rif |
I am one of those gentoo guys, but recently scaled down the flags :)
I think I only use 2 or 3 (besides the standard m64, pipe, and O2). I'll try removing those extra ones and re-emerging.
Thanks!
BTW -- just for reference, simetrix is available on linux (intro version only). My goal is to use simetrix as a schem. capture/netlist generator and spice as the number cruncher |
|
|
| wes-ninja250 |
Neat -- I didn't know Symmetrix was available on a real OS. I've been using it under Windows occasionally for a few years now.
What kind of workstation are you using? If it's an Intel-compatible box, I'd strongly recommend disabling -m64 and popping in -m32 for this type of problem. No need to insist that the SPICE authors wrote 64-bit clean code. (For example, your problem could be triggered if the code inadvertenly stored a pointer in an int, where an int is 32bits long always, but a pointer can be 64 bits in a 64-bit AMD environment.)
For that matter, if you're running SPARC, I'd make the same recommendation, and use SPARC v7 instructions for now. Also, if you're running SPARC, Alpha, POWER, etc, you may be in for some endian issues as well, depending on how well tested that codebase is. And, of course, alignment errors (but those will trigger SIGBUS, not SIGSEGV).
-pipe is irrelevant; -O2 shouldn't cause any trouble, although specifying -O0 may help, depending upon the underlying cause (esp. if you have certain versions of gcc 3.x).
Wes |
|
|
| rif |
It's just a home built amd64, 1gig ram, nvidia 5500 video -- really nothing extraodinary given that they have those dual core/sli/pci-x stuff out there now.
The m64 flag shouldn't cause any issues -- the gentoo docs say to use it to allow both 64 and 32 bit code. But I wouldn't bet much on that ;) .
The problem is that gentoo doesn't allow (at least as I know) package dependent C-flags.
Come to think of it, I think I did use a ~amd64 (means testing version) which is almost always OK to use :bawling: |
|
|
| rif |
If someone doesn't mid, can you provide a simple, even trivial, deck that is known to work. I'm trying to eliminate sources of this error.
Here's what I'm using:
TEST
V1 1 0 SIN(0.5 0.5 1000)
R1 1 2 1000
R2 2 0 1000
.TRAN 0.01m 2m
.END |
|
|
| wes-ninja250 |
> The m64 flag shouldn't cause any issues -- the gentoo docs say to
> use it to allow both 64 and 32 bit code. But I wouldn't bet much on
> that .
| quote: |
-m32
-m64
Generate code for a 32-bit or 64-bit environment. The 32-bit environment sets int, long and pointer to 32 bits and generates code that runs on any i386 system. The 64-bit environment sets int to 32 bits and long and pointer to 64 bits and generates code for AMD's x86-64 architecture.
|
The way I read this, pointers will be 64 bits long when the m64 flag is set. That means that this type of code will break:
| code: |
const char *hello = "world";
int foo = hello + 3;
printf("%s\n", (char *)foo);
|
This code is plainly wrong, but it will execute fine on a 32bit platform, and break miserably on a 64-bit platform. Unless you get really lucky, and your pointers all happen to fall below the 2 GB mark (of virtual memory -- and static pointers are usually allocated near the top of address space IME).
This example is also contrived, however that pattern -- using an integer to hold a pointer -- is not all that uncommon. It usually happens as a result of pointer arithmetic, "optimizations", etc done by junior programmers who have only experience with one architecture. (And x86-32 are the worst of the lot, since the chip is SO forgiving). It can also happen when a packed data structure is written to disk or network (or IPC) -- again, these types of problems are common to junior programmers trying to do a really good job, but still wind up missing the boat. :)
Actually, that reminds me of another example:
| code: |
const char *s = hello;
char *w;
w = (int)s + 5;
printf("%s\n", w);
|
The int cast in this case could be used to mask the const compiler warning, and would also execute on 32-bit, while breaking on 64-bit. That is the sort of subtlety which tends to elude inexperienced C programmers -- they get their code to work, get rid of their warnings, but sometimes don't understand what their doing to get rid of them. The correct solution above is actually to get rid of the int cast and make w a const char *.
So -- my advice -- build with -m32 at least until you get it working.
> The problem is that gentoo doesn't allow (at least as I know) package dependent C-flags
It must. Are you using Gentoo "emerge", or are you building from [true] sources? I'd suggest downloading the source package, running "./configure" on it, and seeing what flags you wind up with. Actually, before you run ./configure, "export CFLAGS=-m32" -- GNU autoconf will pick that up from your environment. Or is it EXTRA_CFLAGS? I forget.
If the package doesn't use GNU Autoconf, you can just hand-hack the Makefile without much worry. As long as it's written with sane rules (either specifying CFLAGS everywhere, or relying on default rules), you can probably just add "CFLAGS += -m32" immediately above the first rule (probably "all:").
If it still barfs on you once you've built from the main site's source package, I can have a (quick!) look at it for you if you can PM me an SSH account. The only condition is -- if I get it working, you have to package up and fire my diffs at the package authors. I won't have time to do that myself, but it'd sure be a shame to not share.
Oh -- and make sure GCC, GDB, and strace are installed on your box; I'll need 'em. GCC 2.95.3 would be a good option, as well (in addition to GCC3.x).
Wes
PS: This assumes that SPICE is written in C. That's my core area of expertise! |
|
|
| rif |
AAAaaaaaaaaaah!
Ugh!
It's worse than I thought! But a solution is probable...
I tried to re-emerge gcc and it fails :(
But it fails b/c it cannot execute 32 bit code it compiles. I'm working on a few solutions over at a gentoo forum now -- makes sense to get that working before trying too much with spice specifics. |
|
|
| wes-ninja250 |
Yup. I'll bet if you can solve your GCC problem -- ESPECIALLY if you can get GCC 2.95.3 to coexist on your box -- that you will have a really good shot at SPICE working properly.
This is actually one reason I refuse to use Gentoo -- issues like this can quickly become nightmares! I prefer binary distributions for OS and usually for apps; while I might not get that last 10% out of my CPU, I'll get packages that work on the first try. ;) I used to run RedHat; now I run a custom Knoppix distro regularly updated from debian-stable.
Of course -- your requirements are VERY different from mine! First of all, you're (presumably) a home user while I make my living doing this **** (I'm a UNIX Systems Programmer). We run Linux *only* for iptables [it's great], and will throw a few other apps on board while we're at it (e.g. RTG, tethereal and some custom stuff...). Everything else gets done under Solaris on SPARC hardware (which certainly has its own pros and cons -- biggest pro is backwards ABI compatibility.... I last built my Window manager (FVWM 1.24) in early 1998, under Solaris 2.5.1, 32-bit sun4m CPU... it runs just fine under Solaris 9 64-bit sun4u..)
Wes |
|
|
| rif |
Cool -- first time I used a Sun Sparc was over ten years ago. I think it was a Sparc LX -- the lunchbox format, not the pizza box. No CD-ROM -- they were too expensive! IIRC it was a 50Mhz SuperSparc (don't know if I or II). This was about the same time that the pentium addition problem was in the news. I thought the windows manager it had was sooo much better than the windows for workgroups I was accustomed to!
I now own 2 or 3 (depending how you count computers) SparcStations (think it's 2 SS5s and an SS20). I couldn't resist buying them off ebay for around $20 when my last memory of them was $20,000.
I installed Solaris 9 on them (this is maybe a year or two ago) -- took something like 48 hours! It's a testament to Sun that it can even be installed on such old machines. I can't even imagine installing XP Pro or Mac OSX and the computers available back then.
Now they're in many parts, waiting for a good project idea. |
|
|
| rif |
Got it working!!!!!!
Needed to set a few flags I had never heard of before.
But... spice still bombs.
So I tried ngspice and that seems to work fine -- even has a script to read in the raw file to octave (a MatLab clone).
thanks for the help everyone! |
|
|
| heater |
If your 64 bit machine can run wine why not try SwitcherCAD (LT Spice) from linear technolgy http://www.linear.com/company/software.jsp
Runs a treat on my Gentoo box, an old old old AMD K6 (266MHz) machine.
SwitcherCAD is free and unrestricted, amazing ! |
|
|
| rif |
I was holding off on that and some others just b/c I don't know how to use wine. I barely know linux for now! In fact I've spent more time (much more) trying to get it working than actually using it! But I like it -- kinda fun.
Did you need to customize wine at all to get it to work? |
|
|
| heater |
I know the pain of getting into linux but I've been at it for a few years now.
I have just brought up gentoo on this old box again following a hard drive crash and replacement. I thought I'd give up on gentoo and be lazy with Centos, a RedHat Enterprise clone. Did it work? no way, crashed all the time. So back to gentoo, takes a while to compile from scratch following the install docs to the letter almost. But works fine.
No I did not customize anything in wine to get switcher working.
On my previous install it was only download the swcadiii.exe from linear. Then
# emerge wine
# wine swcadiii.exe
Lo, the installer just works :)
I'm about to do this again when wine is built, I'll let you know what happens. |
|
|
| rif |
I had no idea, that when wine works properly, it's that easy -- one command to execute and exe.....
This is great! Maybe now I can totally drop xp -- there are only a few things I use it for.
Still -- I think I'll stick with the Simetrix as schematic capture/ngspice to simulate/octave to view way. I want to learn octave and using it is the best way. |
|
|
| hypersonix |
hi,
for very simple projects "ng-spice" works well.
"emerge -pv sci-electronics/ng-spice-rework"
it allows powerful scripts to parsing the results of simulation.
ng-spice is compatible with WinSpice simulator scripts.
Schematic editor is Oregano 0.40
"emerge oregano -pv"
but it's very unstable....sorry.
if you use "wine" you try WinSpice.
other Free solution I don't know for Linux... |
|
|
| heater |
My wine on gentoo just finished compiling so just to show SwitcherCad runs here is screen shot.
Sadly there is a problem, I cannot zoom into the trace window anymore. Zooming into an area on the schematic is fine though. Strange.
This is using the Enlightenment window manager, under twm the menus don't work either dammit. |
|
|
| annex666 |
| quote: | Originally posted by rif
I've just tried for the first time to execute spice on a command line... |
I've been looking for a Spice system to run on Linux and came across this thread.
Where abouts can I obtain Spice for Linux? Is there a graphical interface available?
(sorry to thread jack) |
|
|
|