crash when trying to run simulator

Bug #1841752 reported by Jonatan Liljedahl
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
KiCad
New
Critical
Unassigned

Bug Description

The whole application crashes when trying to simulate a simple subcircuit of a TL072 chip. I'll attach a project that demonstrates the bug in a comment.

See attached crash log. The crash seems to happen in ngspice itself.

Application: KiCad
Version: (5.1.4-0-10_14), release build
Libraries:
    wxWidgets 3.0.4
    libcurl/7.54.0 LibreSSL/2.6.5 zlib/1.2.11 nghttp2/1.24.1
Platform: Mac OS X (Darwin 18.5.0 x86_64), 64 bit, Little endian, wxMac
Build Info:
    wxWidgets: 3.0.4 (wchar_t,STL containers,compatible with 2.8)
    Boost: 1.69.0
    OpenCASCADE Community Edition: 6.9.1
    Curl: 7.54.0
    Compiler: Clang 9.0.0 with C++ ABI 1002

Build settings:
    USE_WX_GRAPHICS_CONTEXT=ON
    USE_WX_OVERLAY=ON
    KICAD_SCRIPTING=ON
    KICAD_SCRIPTING_MODULES=ON
    KICAD_SCRIPTING_PYTHON3=OFF
    KICAD_SCRIPTING_WXPYTHON=ON
    KICAD_SCRIPTING_WXPYTHON_PHOENIX=OFF
    KICAD_SCRIPTING_ACTION_MENU=ON
    BUILD_GITHUB_PLUGIN=ON
    KICAD_USE_OCE=ON
    KICAD_USE_OCC=OFF
    KICAD_SPICE=ON

Revision history for this message
Jonatan Liljedahl (kymatica) wrote :
Revision history for this message
Jonatan Liljedahl (kymatica) wrote :

Here's an example project. The TL072.lib file is included as well.

Revision history for this message
Jonatan Liljedahl (kymatica) wrote :

If I swap out

kicad.app/Contents/Frameworks/libngspice.0.dylib

and

kicad.app/Contents/PlugIns/sim/

from 5.1.0 stable release, it fixes the problem. So again, the issue seems to be ngspice-30.

BTW, on Mac OS there's two copies of libngspice.0.dylib in the bundle:

kicad.app/Contents/Frameworks/libngspice.0.dylib
kicad.app/Contents/PlugIns/sim/libngspice.0.dylib

removing any of them breaks the app and/or simulator.

Revision history for this message
Jonatan Liljedahl (kymatica) wrote :

So, is this a bug in ngspice-30 that is out of our control? If so, I think the only sensible thing is to roll back to 26 until they fix ngspice. I understand that 5.1.4 was meant to bundle ngspice-26, but it actually came with ngspice-30.

Or is the code calling ngspice in KiCad doing something wrong? In that case, hopefully someone of you can fix it :)

As it is now, bundling ngspice-30 makes simulation unusable on macOS.

Revision history for this message
Nick Østergaard (nickoe) wrote :

Do you see the same crash using the recent nightlies of the master branch? I have a hard time to keep track of there being changes or not.

Revision history for this message
Nick Østergaard (nickoe) wrote :

Please add the following in a text box in the schematic to make it print the version and make sure it is ngpsice-30 it runs.

.control
version
.endc

Revision history for this message
Jonatan Liljedahl (kymatica) wrote :

Yes, I did print the ngspice version for the official 5.1.4 release and it's ngspice-30, not 26.

I'll try to find the time to build from latest source and see if there's any improvements.

Revision history for this message
Nick Østergaard (nickoe) wrote :

You should be able to test the nightly from https://kicad-downloads.s3.cern.ch/index.html?prefix=osx/nightly/

Revision history for this message
Jonatan Liljedahl (kymatica) wrote :

Good news! I tried kicad-unified-20190829-183215-bbb4c66cb-10_14.dmg, and ngspice-30 works fine there!

I suggest rolling back to ngspice-26 for 5.1.5, maybe that was already your intention.

Revision history for this message
Nick Østergaard (nickoe) wrote :

Ok, cool, could you test the soon to be 5.1.5? Take the latest build from

https://kicad-downloads.s3.cern.ch/index.html?prefix=osx/testing/5.1/

Revision history for this message
Jonatan Liljedahl (kymatica) wrote :

Great, I tried kicad-5.1-unified-20190830-121212-c1f9abc98-10_14.dmg and it works as well! It does use ngspice-30. So something must have been fixed in kicad since 1.5.4.

Changed in kicad:
status: New → Fix Committed
Revision history for this message
Jonatan Liljedahl (kymatica) wrote :

(I meant to say, since 5.1.4, of course)

Changed in kicad:
milestone: none → 5.1.5
importance: Undecided → Critical
tags: added: macos
tags: added: eeschema
Revision history for this message
Jonatan Liljedahl (kymatica) wrote :

Downloaded kicad-5.1-nightly-20190916-062617-cb0764a9a-10_14 and now it's crashing again with the example project attached above (SimCrash.zip)

stack trace:

* thread #12, stop reason = EXC_BAD_ACCESS (code=1, address=0x1d0)
  * frame #0: 0x00000001233b7c5d libngspice.0.dylib`MIFsetup + 109
    frame #1: 0x00000001237963d6 libngspice.0.dylib`CKTsetup + 214
    frame #2: 0x00000001237901b1 libngspice.0.dylib`CKTdoJob + 961
    frame #3: 0x000000012339f050 libngspice.0.dylib`if_run + 1296
    frame #4: 0x000000012339c13e libngspice.0.dylib`dosim + 894
    frame #5: 0x000000012336b8cb libngspice.0.dylib`docommand + 299
    frame #6: 0x000000012336aece libngspice.0.dylib`doblock + 126
    frame #7: 0x000000012336aca3 libngspice.0.dylib`cp_evloop + 2547
    frame #8: 0x0000000123361531 libngspice.0.dylib`_thread_run + 65
    frame #9: 0x00007fff763d32eb libsystem_pthread.dylib`_pthread_body + 126
    frame #10: 0x00007fff763d6249 libsystem_pthread.dylib`_pthread_start + 66
    frame #11: 0x00007fff763d240d libsystem_pthread.dylib`thread_start + 13

Application: KiCad
Version: (5.1.4-82-gcb0764a9a), debug build
Libraries:
    wxWidgets 3.0.4
    libcurl/7.54.0 LibreSSL/2.6.5 zlib/1.2.11 nghttp2/1.24.1
Platform: Mac OS X (Darwin 18.5.0 x86_64), 64 bit, Little endian, wxMac
Build Info:
    wxWidgets: 3.0.4 (wchar_t,STL containers,compatible with 2.8)
    Boost: 1.69.0
    OpenCASCADE Community Edition: 6.9.1
    Curl: 7.54.0
    Compiler: Clang 9.0.0 with C++ ABI 1002

Build settings:
    USE_WX_GRAPHICS_CONTEXT=ON
    USE_WX_OVERLAY=ON
    KICAD_SCRIPTING=ON
    KICAD_SCRIPTING_MODULES=ON
    KICAD_SCRIPTING_PYTHON3=OFF
    KICAD_SCRIPTING_WXPYTHON=ON
    KICAD_SCRIPTING_WXPYTHON_PHOENIX=OFF
    KICAD_SCRIPTING_ACTION_MENU=ON
    BUILD_GITHUB_PLUGIN=ON
    KICAD_USE_OCE=ON
    KICAD_USE_OCC=OFF
    KICAD_SPICE=ON

Changed in kicad:
status: Fix Committed → New
Revision history for this message
Jonatan Liljedahl (kymatica) wrote :

A really weird thing is that now when trying my old copy of kicad-5.1-unified-20190830-121212-c1f9abc98-10_14.dmg, which was working before, it also crashes! But the official 5.1.0 release does not.

Revision history for this message
Jonatan Liljedahl (kymatica) wrote :

Latest OSX nightly (https://kicad-downloads.s3.cern.ch/osx/testing/5.1/kicad-5.1-nightly-20190929-164904-2d386a2df-10_14.dmg) still crashes for me when trying to run the simulator.

Can anyone on MacOS confirm this bug, or see if it works for them? Maybe something else on my system is messing with ngspice? I'm on MacOS 10.14.4 (18E226)

(lldb) run
Process 4895 launched: '/Applications/KiCad/kicad.app/Contents/MacOS/kicad' (x86_64)
LoadAllLibraries: lib_names:
14:25:39: Debug: Disabling glCopyBuffer() on intel GPU

ShowQuasiModal: optimal parent: 14SCH_EDIT_FRAME
ShowQuasiModal: optimal parent: 14SCH_EDIT_FRAME
ShowQuasiModal: optimal parent: 14SCH_EDIT_FRAME
ShowQuasiModal: optimal parent: 14SCH_EDIT_FRAME
ShowQuasiModal: optimal parent: 14SCH_EDIT_FRAME
Process 4895 stopped
* thread #11, stop reason = EXC_BAD_ACCESS (code=1, address=0x1d0)
    frame #0: 0x000000012351ac5d libngspice.0.dylib`MIFsetup + 109
libngspice.0.dylib`MIFsetup:
-> 0x12351ac5d <+109>: movq (%rcx,%rdx,8), %rcx
    0x12351ac61 <+113>: movq 0x68(%rcx), %r14
    0x12351ac65 <+117>: leaq (%r13,%r13,2), %r15
    0x12351ac6a <+122>: shlq $0x6, %r15
Target 0: (kicad) stopped.
(lldb) bt
* thread #11, stop reason = EXC_BAD_ACCESS (code=1, address=0x1d0)
  * frame #0: 0x000000012351ac5d libngspice.0.dylib`MIFsetup + 109
    frame #1: 0x00000001238f93d6 libngspice.0.dylib`CKTsetup + 214
    frame #2: 0x00000001238f31b1 libngspice.0.dylib`CKTdoJob + 961
    frame #3: 0x0000000123502050 libngspice.0.dylib`if_run + 1296
    frame #4: 0x00000001234ff13e libngspice.0.dylib`dosim + 894
    frame #5: 0x00000001234ce8cb libngspice.0.dylib`docommand + 299
    frame #6: 0x00000001234cdece libngspice.0.dylib`doblock + 126
    frame #7: 0x00000001234cdca3 libngspice.0.dylib`cp_evloop + 2547
    frame #8: 0x00000001234c4531 libngspice.0.dylib`_thread_run + 65
    frame #9: 0x00007fff7890e2eb libsystem_pthread.dylib`_pthread_body + 126
    frame #10: 0x00007fff78911249 libsystem_pthread.dylib`_pthread_start + 66
    frame #11: 0x00007fff7890d40d libsystem_pthread.dylib`thread_start + 13
(lldb)

Application: KiCad
Version: (5.1.4-88-g2d386a2df), debug build
Libraries:
    wxWidgets 3.0.4
    libcurl/7.54.0 LibreSSL/2.6.5 zlib/1.2.11 nghttp2/1.24.1
Platform: Mac OS X (Darwin 18.5.0 x86_64), 64 bit, Little endian, wxMac
Build Info:
    wxWidgets: 3.0.4 (wchar_t,STL containers,compatible with 2.8)
    Boost: 1.69.0
    OpenCASCADE Community Edition: 6.9.1
    Curl: 7.54.0
    Compiler: Clang 9.0.0 with C++ ABI 1002

Build settings:
    USE_WX_GRAPHICS_CONTEXT=ON
    USE_WX_OVERLAY=ON
    KICAD_SCRIPTING=ON
    KICAD_SCRIPTING_MODULES=ON
    KICAD_SCRIPTING_PYTHON3=OFF
    KICAD_SCRIPTING_WXPYTHON=ON
    KICAD_SCRIPTING_WXPYTHON_PHOENIX=OFF
    KICAD_SCRIPTING_ACTION_MENU=ON
    BUILD_GITHUB_PLUGIN=ON
    KICAD_USE_OCE=ON
    KICAD_USE_OCC=OFF
    KICAD_SPICE=ON

Revision history for this message
Holger Vogt (h+vogt) wrote :

Please see https://bugs.launchpad.net/kicad/+bug/1835296 with the activities to fix this bug.

Revision history for this message
Wayne Stambaugh (stambaughw) wrote :

Holger, are both these reports due to the same bug?

Revision history for this message
Holger Vogt (h+vogt) wrote :

Yes, the same bug.

We might clos this one.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.