simulating laser_driver on macos nightly causes segfault

Bug #1835296 reported by Christian Conkle
22
This bug affects 2 people
Affects Status Importance Assigned to Milestone
KiCad
Fix Committed
Critical
Unassigned

Bug Description

Running the 20190703 nightly MacOS build (which I believe has the new ngspice-30 library, although I don't know how to check), simulating the laser_driver or sallen_key demo project causes a hard crash of the entire KiCad application. In particular, pressing "Run/Stop Simulation" causes a segmentation fault in libngspice.0.dylib. Stack trace and version information below.

The other two demo simulation projects (rectifier, pspice) do not crash, and seem to give sensible simulation results.

The most obvious difference between the crashing (laser_driver, sallen_key) and working (rectifier, pspice) projects is that the crashing projects include external spice model libraries (e.g. ad8009.lib in laser_driver) and the working projects use only internal models. My own projects seem to crash if they include external models, but I haven't systematically tested.

Please let me know if I can provide any additional information.

Stack trace:

Crashed Thread: 13

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00000000000001d0
Exception Note: EXC_CORPSE_NOTIFY

...

Thread 13 Crashed:
0 libngspice.0.dylib 0x000000011a962c5d MIFsetup + 109
1 libngspice.0.dylib 0x000000012623f3d6 CKTsetup + 214
2 libngspice.0.dylib 0x00000001262391b1 CKTdoJob + 961
3 libngspice.0.dylib 0x0000000125e48050 if_run + 1296
4 libngspice.0.dylib 0x0000000125e4513e dosim + 894
5 libngspice.0.dylib 0x0000000125e148cb docommand + 299
6 libngspice.0.dylib 0x0000000125e13ece doblock + 126
7 libngspice.0.dylib 0x0000000125e13ca3 cp_evloop + 2547
8 libngspice.0.dylib 0x0000000125e0a531 _thread_run + 65
9 libsystem_pthread.dylib 0x00007fff71c342eb _pthread_body + 126
10 libsystem_pthread.dylib 0x00007fff71c37249 _pthread_start + 66
11 libsystem_pthread.dylib 0x00007fff71c3340d thread_start + 13

Version information:

Application: Eeschema
Version: (5.1.0-1195-g72308fe16), 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.6.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:
    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

description: updated
tags: added: macos
Changed in kicad:
importance: Undecided → Critical
milestone: none → 6.0.0-rc1
Revision history for this message
Adam Wolf (adamwolf) wrote : Re: [Bug 1835296] [NEW] simulating laser_driver on macos nightly causes segfault
Download full text (3.4 KiB)

Did this happen on previously nightlies?

On Thu, Jul 4, 2019, 2:42 AM Launchpad Bug Tracker <
<email address hidden>> wrote:

> You have been subscribed to a public bug by Nick Østergaard (nickoe):
>
> Running the 20190703 nightly MacOS build (which I believe has the new
> ngspice-30 library, although I don't know how to check), simulating the
> laser_driver or sallen_key demo project causes a hard crash of the
> entire KiCad application. In particular, pressing "Run/Stop Simulation"
> causes a segmentation fault in libngspice.0.dylib. Stack trace and
> version information below.
>
> The other two demo simulation projects (rectifier, pspice) do not crash,
> and seem to give sensible simulation results.
>
> The most obvious difference between the crashing (laser_driver,
> sallen_key) and working (rectifier, pspice) projects is that the
> crashing projects include external spice model libraries (e.g.
> ad8009.lib in laser_driver) and the working projects use only internal
> models. My own projects seem to crash if they include external models,
> but I haven't systematically tested.
>
> Please let me know if I can provide any additional information.
>
> Stack trace:
>
> Crashed Thread: 13
>
> Exception Type: EXC_BAD_ACCESS (SIGSEGV)
> Exception Codes: KERN_INVALID_ADDRESS at 0x00000000000001d0
> Exception Note: EXC_CORPSE_NOTIFY
>
> ...
>
> Thread 13 Crashed:
> 0 libngspice.0.dylib 0x000000011a962c5d MIFsetup + 109
> 1 libngspice.0.dylib 0x000000012623f3d6 CKTsetup + 214
> 2 libngspice.0.dylib 0x00000001262391b1 CKTdoJob + 961
> 3 libngspice.0.dylib 0x0000000125e48050 if_run + 1296
> 4 libngspice.0.dylib 0x0000000125e4513e dosim + 894
> 5 libngspice.0.dylib 0x0000000125e148cb docommand + 299
> 6 libngspice.0.dylib 0x0000000125e13ece doblock + 126
> 7 libngspice.0.dylib 0x0000000125e13ca3 cp_evloop + 2547
> 8 libngspice.0.dylib 0x0000000125e0a531 _thread_run + 65
> 9 libsystem_pthread.dylib 0x00007fff71c342eb _pthread_body +
> 126
> 10 libsystem_pthread.dylib 0x00007fff71c37249 _pthread_start
> + 66
> 11 libsystem_pthread.dylib 0x00007fff71c3340d thread_start +
> 13
>
> Version information:
>
> Application: Eeschema
> Version: (5.1.0-1195-g72308fe16), 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.6.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:
> 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
>
> ** Affects: kicad
> Importance: Critical
> ...

Read more...

tags: added: eeschema ngspice
Revision history for this message
ocb-hd-ccb (ocb-hd-ccb) wrote :

I had sallen_key demo crash on 7-01 and 7-02 and 7-03 nightly builds. I did not try the other demos on previous builds but I am having the same results as chri7tian on 7-03.

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

It is unclear to me if this is an issue with kicad, ngspice or the packaging. How can we narrow this down?

Changed in kicad:
status: New → Confirmed
Revision history for this message
Adam Wolf (adamwolf) wrote : Re: [Bug 1835296] Re: simulating laser_driver on macos nightly causes segfault

Do these issues happen with 5.2 or other nightlies from before the
ngspice-30 change?

On Thu, Jul 4, 2019, 1:25 PM Nick Østergaard <email address hidden>
wrote:

> It is unclear to me if this is an issue with kicad, ngspice or the
> packaging. How can we narrow this down?
>
> ** Changed in: kicad
> Status: New => Confirmed
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1835296
>
> Title:
> simulating laser_driver on macos nightly causes segfault
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/kicad/+bug/1835296/+subscriptions
>

Revision history for this message
Christian Conkle (conklech) wrote :
Download full text (4.2 KiB)

The current stable release did not have this crash. I can test other builds
if you point me at them. Is there a way to get ngspice to produce debug
output?

On Thu, Jul 4, 2019, 14:20 Adam Wolf <email address hidden> wrote:

> Do these issues happen with 5.2 or other nightlies from before the
> ngspice-30 change?
>
> On Thu, Jul 4, 2019, 1:25 PM Nick Østergaard <email address hidden>
> wrote:
>
> > It is unclear to me if this is an issue with kicad, ngspice or the
> > packaging. How can we narrow this down?
> >
> > ** Changed in: kicad
> > Status: New => Confirmed
> >
> > --
> > You received this bug notification because you are subscribed to the bug
> > report.
> > https://bugs.launchpad.net/bugs/1835296
> >
> > Title:
> > simulating laser_driver on macos nightly causes segfault
> >
> > To manage notifications about this bug go to:
> > https://bugs.launchpad.net/kicad/+bug/1835296/+subscriptions
> >
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1835296
>
> Title:
> simulating laser_driver on macos nightly causes segfault
>
> Status in KiCad:
> Confirmed
>
> Bug description:
> Running the 20190703 nightly MacOS build (which I believe has the new
> ngspice-30 library, although I don't know how to check), simulating
> the laser_driver or sallen_key demo project causes a hard crash of the
> entire KiCad application. In particular, pressing "Run/Stop
> Simulation" causes a segmentation fault in libngspice.0.dylib. Stack
> trace and version information below.
>
> The other two demo simulation projects (rectifier, pspice) do not
> crash, and seem to give sensible simulation results.
>
> The most obvious difference between the crashing (laser_driver,
> sallen_key) and working (rectifier, pspice) projects is that the
> crashing projects include external spice model libraries (e.g.
> ad8009.lib in laser_driver) and the working projects use only internal
> models. My own projects seem to crash if they include external models,
> but I haven't systematically tested.
>
> Please let me know if I can provide any additional information.
>
> Stack trace:
>
> Crashed Thread: 13
>
> Exception Type: EXC_BAD_ACCESS (SIGSEGV)
> Exception Codes: KERN_INVALID_ADDRESS at 0x00000000000001d0
> Exception Note: EXC_CORPSE_NOTIFY
>
> ...
>
> Thread 13 Crashed:
> 0 libngspice.0.dylib 0x000000011a962c5d MIFsetup + 109
> 1 libngspice.0.dylib 0x000000012623f3d6 CKTsetup + 214
> 2 libngspice.0.dylib 0x00000001262391b1 CKTdoJob + 961
> 3 libngspice.0.dylib 0x0000000125e48050 if_run + 1296
> 4 libngspice.0.dylib 0x0000000125e4513e dosim + 894
> 5 libngspice.0.dylib 0x0000000125e148cb docommand + 299
> 6 libngspice.0.dylib 0x0000000125e13ece doblock + 126
> 7 libngspice.0.dylib 0x0000000125e13ca3 cp_evloop + 2547
> 8 libngspice.0.dylib 0x0000000125e0a531 _thread_run + 65
> 9 libsystem_pthread.dylib 0x00007fff71c342eb _pthread...

Read more...

Revision history for this message
Adam Wolf (adamwolf) wrote :
Download full text (5.6 KiB)

Thanks! I don't know if there is a way to get ngspice to produce debug
output. I am considering pulling the ngspice-28 to ngspice-30 "upgrade"
into it's own build again rather than putting this broken thing into
nightlies for all macos users. Nick, other folks, what do you think?

On the packaging side, all I did is change an include path and which tag to
pull from. I need to review the build logs.

If someone could double check that this isn't an issue introduced by the
latest macOS OS update, and check on the latest stable KiCad, that would be
great. It could possibly be related to notarization/sandbox changes, and
not actually related to ngspice! (Doubtful, but possible!)

Adam

On Thu, Jul 4, 2019, 8:20 PM Christian Conkle <email address hidden> wrote:

> The current stable release did not have this crash. I can test other builds
> if you point me at them. Is there a way to get ngspice to produce debug
> output?
>
> On Thu, Jul 4, 2019, 14:20 Adam Wolf <email address hidden> wrote:
>
> > Do these issues happen with 5.2 or other nightlies from before the
> > ngspice-30 change?
> >
> > On Thu, Jul 4, 2019, 1:25 PM Nick Østergaard <<email address hidden>
> >
> > wrote:
> >
> > > It is unclear to me if this is an issue with kicad, ngspice or the
> > > packaging. How can we narrow this down?
> > >
> > > ** Changed in: kicad
> > > Status: New => Confirmed
> > >
> > > --
> > > You received this bug notification because you are subscribed to the
> bug
> > > report.
> > > https://bugs.launchpad.net/bugs/1835296
> > >
> > > Title:
> > > simulating laser_driver on macos nightly causes segfault
> > >
> > > To manage notifications about this bug go to:
> > > https://bugs.launchpad.net/kicad/+bug/1835296/+subscriptions
> > >
> >
> > --
> > You received this bug notification because you are subscribed to the bug
> > report.
> > https://bugs.launchpad.net/bugs/1835296
> >
> > Title:
> > simulating laser_driver on macos nightly causes segfault
> >
> > Status in KiCad:
> > Confirmed
> >
> > Bug description:
> > Running the 20190703 nightly MacOS build (which I believe has the new
> > ngspice-30 library, although I don't know how to check), simulating
> > the laser_driver or sallen_key demo project causes a hard crash of the
> > entire KiCad application. In particular, pressing "Run/Stop
> > Simulation" causes a segmentation fault in libngspice.0.dylib. Stack
> > trace and version information below.
> >
> > The other two demo simulation projects (rectifier, pspice) do not
> > crash, and seem to give sensible simulation results.
> >
> > The most obvious difference between the crashing (laser_driver,
> > sallen_key) and working (rectifier, pspice) projects is that the
> > crashing projects include external spice model libraries (e.g.
> > ad8009.lib in laser_driver) and the working projects use only internal
> > models. My own projects seem to crash if they include external models,
> > but I haven't systematically tested.
> >
> > Please let me know if I can provide any additional information.
> >
> > Stack trace:
> >
> > Crashed Thread: 13
> >
> > Exception Type: EXC_BAD_ACCESS (SIGS...

Read more...

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

Hi Adam

Don't you have the pull request builds running? I would rather have you keep ngspice 30 on master and do the revert to ngspice 28 on a separate branch and build-job and make sure it does not upload to the normal nightly location. Make it upload to osx/testing/patched/.

I don't think a lot of people have even tested these edge cases earlier on macos and it seems to only for the specific ngspice cases described in this bug.

Revision history for this message
Adam Wolf (adamwolf) wrote :

This seems backwards to me but I will defer to you. We have a
confirmation that this didn't happen before, and now it does since we
upgraded to ngspice 30. Folks can just use an older nightly or stable
if they need the working behavior, I guess?

On Fri, Jul 5, 2019 at 7:50 AM Nick Østergaard
<email address hidden> wrote:
>
> Hi Adam
>
> Don't you have the pull request builds running? I would rather have you
> keep ngspice 30 on master and do the revert to ngspice 28 on a separate
> branch and build-job and make sure it does not upload to the normal
> nightly location. Make it upload to osx/testing/patched/.
>
> I don't think a lot of people have even tested these edge cases earlier
> on macos and it seems to only for the specific ngspice cases described
> in this bug.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1835296
>
> Title:
> simulating laser_driver on macos nightly causes segfault
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/kicad/+bug/1835296/+subscriptions

Revision history for this message
Christian Conkle (conklech) wrote :

Running either 5.1.2 release or 20190624 nightly, the laser_driver simulation runs fine. But on both builds I get a different error running sallen_key. The sallen_key error is apparently an unrelated issue, so I hesitate to derail this bug by posting details here, except to note that the error message indicates that it's running ngspice-26:

Error: ngspice.dll cannot recover and awaits to be detached
Note: can't find init file.
******
** ngspice-26 shared library
** Creation Date: Mon Jun 24 10:38:22 PDT 2019
******

Version information (same results for both):

Application: Eeschema
Version: (5.1.0-1094-g8a22963e9), 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.6.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:
    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

Application: kicad
Version: (5.1.2-1)-1, 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.6.0 x86_64), 64 bit, Little endian, wxMac
Build Info:
    wxWidgets: 3.0.4 (UTF-8,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
Adam Wolf (adamwolf) wrote :

Thanks! Wanna open a new bug for the sallen_key one?

On Fri, Jul 5, 2019 at 3:40 PM Christian Conkle <email address hidden> wrote:
>
> Running either 5.1.2 release or 20190624 nightly, the laser_driver
> simulation runs fine. But on both builds I get a different error running
> sallen_key. The sallen_key error is apparently an unrelated issue, so I
> hesitate to derail this bug by posting details here, except to note that
> the error message indicates that it's running ngspice-26:
>
> Error: ngspice.dll cannot recover and awaits to be detached
> Note: can't find init file.
> ******
> ** ngspice-26 shared library
> ** Creation Date: Mon Jun 24 10:38:22 PDT 2019
> ******
>
> Version information (same results for both):
>
> Application: Eeschema
> Version: (5.1.0-1094-g8a22963e9), 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.6.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:
> 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
>
> Application: kicad
> Version: (5.1.2-1)-1, 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.6.0 x86_64), 64 bit, Little endian, wxMac
> Build Info:
> wxWidgets: 3.0.4 (UTF-8,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
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1835296
>
> Title:
> simulating laser_driver on macos nightly causes segfault
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/kicad/+bug/1835296/+subscriptions

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

Testing for the ngspice version:

Add a text box to the eeschema circuit diagram containing

.control
version
.endc

Run the simulation.

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

Where to find the build logs for ngspice dlll on macOS?

Revision history for this message
Adam Wolf (adamwolf) wrote :

Hi Holger,

They are in here:

https://builder.wayneandlayne.com/job/kicad-mac-builder-10.14-upload/261/consoleText

On Sat, Jul 6, 2019 at 3:25 AM Holger Vogt <email address hidden> wrote:
>
> Where to find the build logs for ngspice dlll on macOS?
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1835296
>
> Title:
> simulating laser_driver on macos nightly causes segfault
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/kicad/+bug/1835296/+subscriptions

Revision history for this message
Christian Conkle (conklech) wrote :

Adam,

I don't think there's a separate sallen_key problem; both laser_driver and sallen_key crash in the same way. (I hadn't noticed that yet when I initially wrote the bug report.)

Revision history for this message
Adam Wolf (adamwolf) wrote :

One bug is better than two :) Just so I make sure I'm understanding
right, the July 5th message is not correct?

On Mon, Jul 8, 2019 at 1:51 PM Christian Conkle <email address hidden> wrote:
>
> Adam,
>
> I don't think there's a separate sallen_key problem; both laser_driver
> and sallen_key crash in the same way. (I hadn't noticed that yet when I
> initially wrote the bug report.)
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1835296
>
> Title:
> simulating laser_driver on macos nightly causes segfault
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/kicad/+bug/1835296/+subscriptions

Revision history for this message
Christian Conkle (conklech) wrote :

Oh! THAT sallen_key crash. I had completely forgotten about my own July 5 message. Sorry for the confusion. I will open a second bug next time I'm at my Mac.

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

The original post says that a seg fault ocurred in ngspice function MIFsetup.

0 libngspice.0.dylib 0x000000011a962c5d MIFsetup + 109

This function is responsible for setting up XSPICE models. These are used for example in polynomial voltage sources (the ones applying the POLY statement), often used by OpAmp models. OpAmps are used in the sallen-key and laser driver examples, but not with rectifier.

Unfortunately the crash info does not tell me where exactly the crash happened. There have been some changes to MIFsetup between ngspice-26 and ngspice-30, but they seem to be syntax changes, not functional changes. For example a macro has been used to hide some list processing.

Might it be possible to obtain a debugger output telling me which line in the mifsetup.c file is causing the crash? Obviously this does not happen with the Windows builds, and I haven't heard about complaints from the Linux community.

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

However, posting #9 tells me that even with ngspice-26 there is a crash in sallen_key?!

Revision history for this message
Seth Hillbrand (sethh) wrote :

@devs- What do folks think about spinning an RPC program off while simulating? It would take the netlist in, run the simulation and return the results over a local port. Crashes in libngspice would prevent simulation but not take down KiCad and we could handle errors gracefully.

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

@Seth, I'm not opposed to this. Once you make the simulator a stand alone application, the expectation will be that you can open any spice netlist file not just one passed from Eeschema. It's one of those cases where I would question if the effort is worth it. In order to get stack traces, you would have to run the simulator from the debugger rather than KiCad. It may also complicated Tom's debug reporter work.

Revision history for this message
Seth Hillbrand (sethh) wrote :

@Wayne-

True. I suppose the alternative would be to just use the ngspice application as a server or in pipe mode.

Revision history for this message
Christian Conkle (conklech) wrote :

Separate bug opened for the ngspice-26 sallen_key crash: https://bugs.launchpad.net/kicad/+bug/1836104

I'd be more than happy to capture debugger output. If anybody happens to know how to do that on MacOS, let me know; otherwise it'll take me a little while for me to figure out how. (I'm not primarily a Mac user.)

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

@Seth, I would think getting debug information form ngspice running as a separate application or server would be even more problematic. @Tom, do you have any thoughts on this since the simulator is you code. You might want to check with Holger as well to determine the implications of doing this.

Revision history for this message
Adam Wolf (adamwolf) wrote :

When I get debugger output, I typically do it with CLion for macOS. I do
not know how to make the packaged applications make debugger output.

I unfortunately cannot devote any time this week to digging into this.
Does someone else with a debugger on macOS want to get Holger the
information he needs? I still kinda suspect it's macOS not actually
opening the file due to some sort of sandboxing, but that is a wild guess.

On Wed, Jul 10, 2019, 2:55 PM Wayne Stambaugh <email address hidden>
wrote:

> @Seth, I would think getting debug information form ngspice running as a
> separate application or server would be even more problematic. @Tom, do
> you have any thoughts on this since the simulator is you code. You
> might want to check with Holger as well to determine the implications of
> doing this.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1835296
>
> Title:
> simulating laser_driver on macos nightly causes segfault
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/kicad/+bug/1835296/+subscriptions
>

Revision history for this message
Jeff Young (jeyjey) wrote :
Download full text (3.4 KiB)

I get the following when running the sallen_key demo (note that this is a development build, so it may be some packaging that's missing):

Circuit: KiCad schematic
Original line no.: 5, new internal line no.: 113:
Mismatch: 0 formal but 1 actual params.
Copies=121 Evals=120 Placeholders=0 Symbols=7 Errors=1
Numparam expansion errors: Problem with input file.
Error: ngspice.dll cannot recover and awaits to be detached
******
** ngspice-26 shared library
** Creation Date: Mon Jan 22 15:04:02 GMT 2018
******
dlopen(/Users/jeff/kicad_dev/kicad/bin/kicad.app/Contents/PlugIns/sim/ngspice/scripts/ciderinit, 2): no suitable image found. Did find:
/Users/jeff/kicad_dev/kicad/bin/kicad.app/Contents/PlugIns/sim/ngspice/scripts/ciderinit: file too short
/Users/jeff/kicad_dev/kicad/bin/kicad.app/Contents/PlugIns/sim/ngspice/scripts/ciderinit: file too short
Error: Library /Users/jeff/kicad_dev/kicad/bin/kicad.app/Contents/PlugIns/sim/ngspice/scripts/ciderinit couldn't be loaded!
dlopen(/Users/jeff/kicad_dev/kicad/bin/kicad.app/Contents/PlugIns/sim/ngspice/scripts/spinit, 2): no suitable image found. Did find:
/Users/jeff/kicad_dev/kicad/bin/kicad.app/Contents/PlugIns/sim/ngspice/scripts/spinit: file too short
/Users/jeff/kicad_dev/kicad/bin/kicad.app/Contents/PlugIns/sim/ngspice/scripts/spinit: file too short
Error: Library /Users/jeff/kicad_dev/kicad/bin/kicad.app/Contents/PlugIns/sim/ngspice/scripts/spinit couldn't be loaded!
dlopen(/Users/jeff/kicad_dev/kicad/bin/kicad.app/Contents/PlugIns/sim/ngspice/scripts/devaxis, 2): no suitable image found. Did find:
/Users/jeff/kicad_dev/kicad/bin/kicad.app/Contents/PlugIns/sim/ngspice/scripts/devaxis: file too short
/Users/jeff/kicad_dev/kicad/bin/kicad.app/Contents/PlugIns/sim/ngspice/scripts/devaxis: file too short
Error: Library /Users/jeff/kicad_dev/kicad/bin/kicad.app/Contents/PlugIns/sim/ngspice/scripts/devaxis couldn't be loaded!
dlopen(/Users/jeff/kicad_dev/kicad/bin/kicad.app/Contents/PlugIns/sim/ngspice/scripts/devload, 2): no suitable image found. Did find:
/Users/jeff/kicad_dev/kicad/bin/kicad.app/Contents/PlugIns/sim/ngspice/scripts/devload: file too short
/Users/jeff/kicad_dev/kicad/bin/kicad.app/Contents/PlugIns/sim/ngspice/scripts/devload: file too short
Error: Library /Users/jeff/kicad_dev/kicad/bin/kicad.app/Contents/PlugIns/sim/ngspice/scripts/devload couldn't be loaded!
dlopen(/Users/jeff/kicad_dev/kicad/bin/kicad.app/Contents/PlugIns/sim/ngspice/scripts/spectrum, 2): no suitable image found. Did find:
/Users/jeff/kicad_dev/kicad/bin/kicad.app/Contents/PlugIns/sim/ngspice/scripts/spectrum: unknown file type, first eight bytes: 0x2A 0x20 0x46 0x6F 0x75 0x72 0x69 0x65
/Users/jeff/kicad_dev/kicad/bin/kicad.app/Contents/PlugIns/sim/ngspice/scripts/spectrum: unknown file type, first eight bytes: 0x2A 0x20 0x46 0x6F 0x75 0x72 0x69 0x65
Error: Library /Users/jeff/kicad_dev/kicad/bin/kicad.app/Contents/PlugIns/sim/ngspice/scripts/spectrum couldn't be loaded!
dlopen(/Users/jeff/kicad_dev/kicad/bin/kicad.app/Contents/PlugIns/sim/ngspice/scripts/setplot, 2): no suitable image found. Did find:
/Users/jeff/kicad_dev/kicad/bin/kicad.app/Contents/PlugIns/sim/ngspice/scripts/setplot: file too short
/U...

Read more...

Revision history for this message
Jeff Young (jeyjey) wrote :

The laser_driver demo runs fine for me.

Application: Eeschema
Version: (5.1.0-1246-g67573128a-dirty), debug build
Libraries:
    wxWidgets 3.0.4
    libcurl/7.54.0 LibreSSL/2.0.20 zlib/1.2.11 nghttp2/1.24.0
Platform: Mac OS X (Darwin 17.7.0 x86_64), 64 bit, Little endian, wxMac
Build Info:
    wxWidgets: 3.0.4 (wchar_t,STL containers,compatible with 2.8)
    Boost: 1.65.1
    Curl: 7.57.0
    Compiler: Clang 10.0.0 with C++ ABI 1002

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

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

@Jeff, unfortunately our version info does not print the ngspice version info. What version do you use?

Revision history for this message
Adam Wolf (adamwolf) wrote :

Nick, it looks like version 26 from the output.

On Wed, Jul 10, 2019 at 6:11 PM Nick Østergaard
<email address hidden> wrote:
>
> @Jeff, unfortunately our version info does not print the ngspice version
> info. What version do you use?
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1835296
>
> Title:
> simulating laser_driver on macos nightly causes segfault
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/kicad/+bug/1835296/+subscriptions

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

@Holger, I am going to add the ngspice version to the KiCad build info so users wont have to look it up. The only place I can find the version string for ngspice is in the <ngspice/config.h> header file under the PACKAGE_VERSION definition. Is this correct for all versions of ngspice and is there any plan to change this in the future? I want to be sure I don't break builds with different versions of ngspice. Thanks in advance for the help.

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

@Wyne,

yes, that's the source of the version info (if you are not compiling with MSVC). You may read it at compile time.

But what about users who upgrade their ngspice by just changing the dll?

If you send the command 'version' to ngspice, you will get back

******
** ngspice-30 : Circuit level simulation program
** The U. C. Berkeley CAD Group
** Copyright 1985-1994, Regents of the University of California.
** Please get your ngspice manual from http://ngspice.sourceforge.net/docs.html
** Please file your bug-reports at http://ngspice.sourceforge.net/bugrep.html
** Creation Date: Thu Feb 21 08:59:50 UTC 2019
******

Well, you have to figure out the ngspice-XX string, but this may be a better way.

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

@Wayne, excuse me for having misspelled your name

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

@Holger, no problem. Typos happen. I will take your advice and send a "version" command to get the version information for ngspice. Thanks for the tip.

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

@Holger, it doesn't look like I will be able to use the "version" command because ngspice is only build as part of the schematic editor and the about dialog is built in common so ngspice may not be available so I will have to use the static version defined in <ngspice/config.h>. My guess is that in most cases this will be the correct runtime version but obviously this may not always be the case.

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

Before moving on here, please for whatever simulation run, add an additional textbox to the eeschema circuit diagram window, as described in https://bugs.launchpad.net/kicad/+bug/1835296/comments/11

Without the information on what ngspice you are running, thinking about debugging is difficult.

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

This bug does not occur on OS Windows. Linux is to be tested (over the weekend).

The bug probably results from intruducing a call back function into the spice2poly code model for XSPICE (used in the OpAmp model with its POLY voltage source), done after ngspice-29, made to reduce a memory leak. I will have to dig a little more into details.

I would appreciate if someone with macOS and ngspice (plus code models) compiled in debug mode would give me some support.

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

To be a little bit more precise:

I can provoke a crash bug similar to the one mentioned by Christian (at least somewhere around setting up XSPICE) on Windows OS (as described in my previous post) by running ngspice-26 with XSPICE code models made from ngspice-30 sources. If ngspice-30 is called with the ngspice-30 code models, it is o.k. under Windows OS. If ngspice-26 is called with modified code models by commenting out the Callback line ( ngspice\src\xspice\icm\spice2poly\icm_spice2poly\cfunc.mod, line 115), it is o.k. again.

I will check this on Linux as well, but I don't have access to a macOS machine.

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

If you have something specific you tjink we should do for the mac packaging, could you raise an issue on https://github.com/KiCad/kicad-mac-builder/issues

This discussion is getting complicated for me to follow wit all those platform, kicad and ngspice versions.

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

For me the same!

What I would like to suggest:

Revert commit
https://git.launchpad.net/kicad/commit/?h=5.1&id=216573bf4827e8ca98635e1b95efa0c02c94b53f
for KiCad 5.1.3

Package macOS with ngspice-26 for 5.1.3

Investigate why there is a seg fault on macOS when using 5.1.3 and ngspice-30 (help needed!)

Revision history for this message
Adam Wolf (adamwolf) wrote :

Alright. Can we get that commit reverted in kicad itself on the 5.1
branch, and then I'll set the mac package to build with 26 for the
upcoming release?

On Fri, Jul 19, 2019 at 3:15 AM Holger Vogt <email address hidden> wrote:
>
> For me the same!
>
> What I would like to suggest:
>
> Revert commit
> https://git.launchpad.net/kicad/commit/?h=5.1&id=216573bf4827e8ca98635e1b95efa0c02c94b53f
> for KiCad 5.1.3
>
> Package macOS with ngspice-26 for 5.1.3
>
> Investigate why there is a seg fault on macOS when using 5.1.3 and
> ngspice-30 (help needed!)
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1835296
>
> Title:
> simulating laser_driver on macos nightly causes segfault
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/kicad/+bug/1835296/+subscriptions

Revision history for this message
jean-pierre charras (jp-charras) wrote :

I reverted this commit in 5.1 branch.

Revision history for this message
jean-pierre charras (jp-charras) wrote :

I also reverted the similar commit in master branch.

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

Linus is o.k. as well with 5.1.3 and ngspice-30. So this for now seems to be macOS specific.

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

@Christian, please retest on the latest macos nightlies and report back.

Changed in kicad:
status: Confirmed → Incomplete
Revision history for this message
Christian Conkle (conklech) wrote :
Download full text (3.4 KiB)

Sorry for the delay. Currently release 5.1.4 and kicad-5.1-unified-20190911-052317-ff80747ca-10_14.dmg both crashes under the same circumstances and with apparently the same results as in the original report.

Process: kicad [59326]
Path: /private/var/folders/*/kicad.app/Contents/MacOS/kicad
Identifier: org.kicad-pcb.kicad
Version: 5.1.4-br-unknown (???)
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: kicad [59326]
User ID: 502

Date/Time: 2019-09-11 17:57:14.911 -0700
OS Version: Mac OS X 10.14.5 (18F132)
Report Version: 12
Bridge OS Version: 3.5 (16P5125)
Anonymous UUID: 2F535EFB-DC41-6579-093D-77E72102AE39

Sleep/Wake UUID: F9391440-829B-4A43-A77B-547DBC272F66

Time Awake Since Boot: 690000 seconds
Time Since Wake: 6900 seconds

System Integrity Protection: enabled

Notes: Translocated Process

Crashed Thread: 10

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00000000000001d0
Exception Note: EXC_CORPSE_NOTIFY

Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [59326]

***

Thread 10 Crashed:
0 libngspice.0.dylib 0x000000011f6d4c5d MIFsetup + 109
1 libngspice.0.dylib 0x000000012b3da3d6 CKTsetup + 214
2 libngspice.0.dylib 0x000000012b3d41b1 CKTdoJob + 961
3 libngspice.0.dylib 0x000000012afe3050 if_run + 1296
4 libngspice.0.dylib 0x000000012afe013e dosim + 894
5 libngspice.0.dylib 0x000000012afaf8cb docommand + 299
6 libngspice.0.dylib 0x000000012afaeece doblock + 126
7 libngspice.0.dylib 0x000000012afaeca3 cp_evloop + 2547
8 libngspice.0.dylib 0x000000012afa5531 _thread_run + 65
9 libsystem_pthread.dylib 0x00007fff75de62eb _pthread_body + 126
10 libsystem_pthread.dylib 0x00007fff75de9249 _pthread_start + 66
11 libsystem_pthread.dylib 0x00007fff75de540d thread_start + 13

Thread 10 crashed with X86 Thread State (64-bit):
  rax: 0x0000600003e10d40 rbx: 0x000000012b4fcc90 rcx: 0x0000000000000000 rdx: 0x000000000000003a
  rdi: 0x00007f95433521f0 rsi: 0x00006000024c2b40 rbp: 0x000070000a09d870 rsp: 0x000070000a09d7e0
   r8: 0x0000000000000000 r9: 0x00007f952f9082a0 r10: 0x000000012b4fce10 r11: 0xffffeffff9d0c230
  r12: 0x00006000024c2b40 r13: 0x0000000000000000 r14: 0x000000000000003a r15: 0x00007f9543311530
  rip: 0x000000011f6d4c5d rfl: 0x0000000000010202 cr2: 0x00000000000001d0

***

Application: KiCad
Version: (5.1.4-79-gff80747ca), 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.6.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_...

Read more...

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

So nothing has changed and improved, even if https://bugs.launchpad.net/kicad/+bug/1841752/comments/11 gave some hope.

It is macOS specific. It is not yet decided if ngspice receaves wrong input from Eeschema or if ngspice has a bug.

Anyway ngspice should not crash, even with wrong input.

I do not have access to a macOS machine. So let's team up. Is there anybody around with interest to compile ngspice in debug mode, run it from Eeschema and attach the debugger to check for the details of the crash?

Thread 10 Crashed:
0 libngspice.0.dylib 0x000000011f6d4c5d MIFsetup + 109
1 libngspice.0.dylib 0x000000012b3da3d6 CKTsetup + 214
2 libngspice.0.dylib 0x000000012b3d41b1 CKTdoJob + 961
3 libngspice.0.dylib 0x000000012afe3050 if_run + 1296
...

from above provides a hint, but is not precise enough as to where exactly and why it crashes.

I would then try to provide a fix, may be with some further iteration with the macOS partner.

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

Would one of our macos devs help Holger? This bug affects the 5.1 branch so we should try to get it fixed as soon as possible. I would rather not have another stable 5.1 release with a known crash bug.

Changed in kicad:
milestone: 6.0.0-rc1 → 5.1.5
status: Incomplete → Confirmed
Revision history for this message
Jeff Young (jeyjey) wrote :

While I do really like the SPICE integration, I'm beyond *awful* at tooling, build scripts, etc. So it would be great if someone else could pick this up.

Alternatively, if someone wants to give me 3rd-grader-level instructions on setting it up (with CLion) then that could work too.

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

I'm not sure how difficult it is on macos but you should just be able to build the ngspice library with debugging symbols enabled. ngspice uses autotools for configuration so adding --enable-debug=yes to the build configuration should do the trick. I'm not sure how you would install this on macos.

Revision history for this message
Adam Wolf (adamwolf) wrote :

Jeff, does your clion setup support ngspice? Do you know if it builds
ngspice, or if you're using system ngspice?

On Thu, Sep 12, 2019 at 12:21 PM Wayne Stambaugh
<email address hidden> wrote:
>
> I'm not sure how difficult it is on macos but you should just be able to
> build the ngspice library with debugging symbols enabled. ngspice uses
> autotools for configuration so adding --enable-debug=yes to the build
> configuration should do the trick. I'm not sure how you would install
> this on macos.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1835296
>
> Title:
> simulating laser_driver on macos nightly causes segfault
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/kicad/+bug/1835296/+subscriptions

Revision history for this message
Jeff Young (jeyjey) wrote :

I suspect I’m using the system ngspice. (At least the bug doesn’t reproduce for me as I’m running it now.)

My cmake config doesn’t say anything about it:

cmake -DCMAKE_C_COMPILER=clang \
    -DCMAKE_CXX_COMPILER=clang++ \
    -DCMAKE_OSX_DEPLOYMENT_TARGET=10.13 \
    -DwxWidgets_CONFIG_EXECUTABLE=../../wxWidgets/wx-bin/bin/wx-config \
    -DPYTHON_SITE_PACKAGE_PATH=/Users/jeff/kicad_dev/wxWidgets/wx-bin/lib/python2.7/site-packages \
    -DKICAD_SCRIPTING=ON \
    -DKICAD_SCRIPTING_MODULES=OFF \
    -DKICAD_SCRIPTING_WXPYTHON=OFF \
    -DKICAD_USE_OCE=OFF \
    -DCMAKE_INSTALL_PREFIX=./bin \
    -DCMAKE_BUILD_TYPE=Debug \
     ../

Revision history for this message
Adam Wolf (adamwolf) wrote :

I should be able to do this in kicad-mac-builder. I do not have time
to test this, but I can look at getting this to happen this weekend.

Adam

On Thu, Sep 12, 2019 at 1:20 PM Jeff Young <email address hidden> wrote:
>
> I suspect I’m using the system ngspice. (At least the bug doesn’t
> reproduce for me as I’m running it now.)
>
> My cmake config doesn’t say anything about it:
>
> cmake -DCMAKE_C_COMPILER=clang \
> -DCMAKE_CXX_COMPILER=clang++ \
> -DCMAKE_OSX_DEPLOYMENT_TARGET=10.13 \
> -DwxWidgets_CONFIG_EXECUTABLE=../../wxWidgets/wx-bin/bin/wx-config \
> -DPYTHON_SITE_PACKAGE_PATH=/Users/jeff/kicad_dev/wxWidgets/wx-bin/lib/python2.7/site-packages \
> -DKICAD_SCRIPTING=ON \
> -DKICAD_SCRIPTING_MODULES=OFF \
> -DKICAD_SCRIPTING_WXPYTHON=OFF \
> -DKICAD_USE_OCE=OFF \
> -DCMAKE_INSTALL_PREFIX=./bin \
> -DCMAKE_BUILD_TYPE=Debug \
> ../
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1835296
>
> Title:
> simulating laser_driver on macos nightly causes segfault
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/kicad/+bug/1835296/+subscriptions

Revision history for this message
Adam Wolf (adamwolf) wrote :

Actually, drats, I'm not sure this is going to be easy. I'll build
ngspice with debugging symbols, but that doesn't mean that everything
can be debugged.

On Thu, Sep 12, 2019 at 2:49 PM Adam Wolf <email address hidden> wrote:
>
> I should be able to do this in kicad-mac-builder. I do not have time
> to test this, but I can look at getting this to happen this weekend.
>
> Adam
>
> On Thu, Sep 12, 2019 at 1:20 PM Jeff Young <email address hidden> wrote:
> >
> > I suspect I’m using the system ngspice. (At least the bug doesn’t
> > reproduce for me as I’m running it now.)
> >
> > My cmake config doesn’t say anything about it:
> >
> > cmake -DCMAKE_C_COMPILER=clang \
> > -DCMAKE_CXX_COMPILER=clang++ \
> > -DCMAKE_OSX_DEPLOYMENT_TARGET=10.13 \
> > -DwxWidgets_CONFIG_EXECUTABLE=../../wxWidgets/wx-bin/bin/wx-config \
> > -DPYTHON_SITE_PACKAGE_PATH=/Users/jeff/kicad_dev/wxWidgets/wx-bin/lib/python2.7/site-packages \
> > -DKICAD_SCRIPTING=ON \
> > -DKICAD_SCRIPTING_MODULES=OFF \
> > -DKICAD_SCRIPTING_WXPYTHON=OFF \
> > -DKICAD_USE_OCE=OFF \
> > -DCMAKE_INSTALL_PREFIX=./bin \
> > -DCMAKE_BUILD_TYPE=Debug \
> > ../
> >
> > --
> > You received this bug notification because you are subscribed to the bug
> > report.
> > https://bugs.launchpad.net/bugs/1835296
> >
> > Title:
> > simulating laser_driver on macos nightly causes segfault
> >
> > To manage notifications about this bug go to:
> > https://bugs.launchpad.net/kicad/+bug/1835296/+subscriptions

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

Acquired a MacBook Air.
Installed KiCad from https://kicad-downloads.s3.cern.ch/index.html?prefix=osx/testing/5.1/
Can reproduce the bug.
Set up ngspice to compile (with or without debug info).
Not yet happy with the debug environment (may switch to XCode?).
Will check the issue over next weekend.

Due to being close before a new ngspice release (ngspice-31), if there is some ngspice bug, we may consider it immediately.

Revision history for this message
Jeff Young (jeyjey) wrote :
Download full text (3.9 KiB)

@Holger, if you want to try out JetBrains’ CLion, we got an extra license floating around. (Although it may need to be renewed at this point.)

Cheers,
Jeff.

> On 17 Sep 2019, at 09:02, Holger Vogt <email address hidden> wrote:
>
> Acquired a MacBook Air.
> Installed KiCad from https://kicad-downloads.s3.cern.ch/index.html?prefix=osx/testing/5.1/
> Can reproduce the bug.
> Set up ngspice to compile (with or without debug info).
> Not yet happy with the debug environment (may switch to XCode?).
> Will check the issue over next weekend.
>
> Due to being close before a new ngspice release (ngspice-31), if there
> is some ngspice bug, we may consider it immediately.
>
> --
> You received this bug notification because you are a member of KiCad Bug
> Squad, which is subscribed to KiCad.
> https://bugs.launchpad.net/bugs/1835296
>
> Title:
> simulating laser_driver on macos nightly causes segfault
>
> Status in KiCad:
> Confirmed
>
> Bug description:
> Running the 20190703 nightly MacOS build (which I believe has the new
> ngspice-30 library, although I don't know how to check), simulating
> the laser_driver or sallen_key demo project causes a hard crash of the
> entire KiCad application. In particular, pressing "Run/Stop
> Simulation" causes a segmentation fault in libngspice.0.dylib. Stack
> trace and version information below.
>
> The other two demo simulation projects (rectifier, pspice) do not
> crash, and seem to give sensible simulation results.
>
> The most obvious difference between the crashing (laser_driver,
> sallen_key) and working (rectifier, pspice) projects is that the
> crashing projects include external spice model libraries (e.g.
> ad8009.lib in laser_driver) and the working projects use only internal
> models. My own projects seem to crash if they include external models,
> but I haven't systematically tested.
>
> Please let me know if I can provide any additional information.
>
> Stack trace:
>
> Crashed Thread: 13
>
> Exception Type: EXC_BAD_ACCESS (SIGSEGV)
> Exception Codes: KERN_INVALID_ADDRESS at 0x00000000000001d0
> Exception Note: EXC_CORPSE_NOTIFY
>
> ...
>
> Thread 13 Crashed:
> 0 libngspice.0.dylib 0x000000011a962c5d MIFsetup + 109
> 1 libngspice.0.dylib 0x000000012623f3d6 CKTsetup + 214
> 2 libngspice.0.dylib 0x00000001262391b1 CKTdoJob + 961
> 3 libngspice.0.dylib 0x0000000125e48050 if_run + 1296
> 4 libngspice.0.dylib 0x0000000125e4513e dosim + 894
> 5 libngspice.0.dylib 0x0000000125e148cb docommand + 299
> 6 libngspice.0.dylib 0x0000000125e13ece doblock + 126
> 7 libngspice.0.dylib 0x0000000125e13ca3 cp_evloop + 2547
> 8 libngspice.0.dylib 0x0000000125e0a531 _thread_run + 65
> 9 libsystem_pthread.dylib 0x00007fff71c342eb _pthread_body + 126
> 10 libsystem_pthread.dylib 0x00007fff71c37249 _pthread_start + 66
> 11 libsystem_pthread.dylib 0x00007fff71c3340d thread_start + 13
>
> Version information:
>
> Application: Eeschema
> Version: (5.1.0-1195-g72308fe16), debug build
> Libra...

Read more...

Revision history for this message
Adam Wolf (adamwolf) wrote :
Download full text (4.8 KiB)

As of last friday, the nightly packages have ngspice built with debugging.

I can try to debug this today, but are there step by step instructions
on how to trigger the crash? (Although I use KiCad and package it for
macOS, I do not even know where to start with ngspice and kicad.)

Thanks folks! We'll get it!

On Tue, Sep 17, 2019 at 7:35 AM Jeff Young <email address hidden> wrote:
>
> @Holger, if you want to try out JetBrains’ CLion, we got an extra
> license floating around. (Although it may need to be renewed at this
> point.)
>
> Cheers,
> Jeff.
>
> > On 17 Sep 2019, at 09:02, Holger Vogt <email address hidden> wrote:
> >
> > Acquired a MacBook Air.
> > Installed KiCad from https://kicad-downloads.s3.cern.ch/index.html?prefix=osx/testing/5.1/
> > Can reproduce the bug.
> > Set up ngspice to compile (with or without debug info).
> > Not yet happy with the debug environment (may switch to XCode?).
> > Will check the issue over next weekend.
> >
> > Due to being close before a new ngspice release (ngspice-31), if there
> > is some ngspice bug, we may consider it immediately.
> >
> > --
> > You received this bug notification because you are a member of KiCad Bug
> > Squad, which is subscribed to KiCad.
> > https://bugs.launchpad.net/bugs/1835296
> >
> > Title:
> > simulating laser_driver on macos nightly causes segfault
> >
> > Status in KiCad:
> > Confirmed
> >
> > Bug description:
> > Running the 20190703 nightly MacOS build (which I believe has the new
> > ngspice-30 library, although I don't know how to check), simulating
> > the laser_driver or sallen_key demo project causes a hard crash of the
> > entire KiCad application. In particular, pressing "Run/Stop
> > Simulation" causes a segmentation fault in libngspice.0.dylib. Stack
> > trace and version information below.
> >
> > The other two demo simulation projects (rectifier, pspice) do not
> > crash, and seem to give sensible simulation results.
> >
> > The most obvious difference between the crashing (laser_driver,
> > sallen_key) and working (rectifier, pspice) projects is that the
> > crashing projects include external spice model libraries (e.g.
> > ad8009.lib in laser_driver) and the working projects use only internal
> > models. My own projects seem to crash if they include external models,
> > but I haven't systematically tested.
> >
> > Please let me know if I can provide any additional information.
> >
> > Stack trace:
> >
> > Crashed Thread: 13
> >
> > Exception Type: EXC_BAD_ACCESS (SIGSEGV)
> > Exception Codes: KERN_INVALID_ADDRESS at 0x00000000000001d0
> > Exception Note: EXC_CORPSE_NOTIFY
> >
> > ...
> >
> > Thread 13 Crashed:
> > 0 libngspice.0.dylib 0x000000011a962c5d MIFsetup + 109
> > 1 libngspice.0.dylib 0x000000012623f3d6 CKTsetup + 214
> > 2 libngspice.0.dylib 0x00000001262391b1 CKTdoJob + 961
> > 3 libngspice.0.dylib 0x0000000125e48050 if_run + 1296
> > 4 libngspice.0.dylib 0x0000000125e4513e dosim + 894
> > 5 libngspice.0.dylib 0x0000000125e148cb docommand + 299
> > 6 libngspice.0.dylib ...

Read more...

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

Thanks nick!

On Tue, Sep 17, 2019 at 8:25 AM Nick Østergaard
<email address hidden> wrote:
>
> @Adam, please check https://github.com/KiCad/kicad-mac-builder/issues/90
>
> ** Bug watch added: github.com/KiCad/kicad-mac-builder/issues #90
> https://github.com/KiCad/kicad-mac-builder/issues/90
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1835296
>
> Title:
> simulating laser_driver on macos nightly causes segfault
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/kicad/+bug/1835296/+subscriptions

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

We have:

Thread 10 Crashed:
0 libngspice.0.dylib 0x000000011f6d4c5d MIFsetup + 109
1 libngspice.0.dylib 0x000000012b3da3d6 CKTsetup + 214
2 libngspice.0.dylib 0x000000012b3d41b1 CKTdoJob + 961

What I will do next to figure out where exactly in function MIFsetup of file mifsetup.c the crash is happening:

Start eeschema
load sallen-key project
Select Tools-->Simulator

*start debugger in terminal

lldb

*attach debugger lldb to process

process attach --name eeschema

* in eeschema simulator window
Start Simulation

*in terminal watch debugger output
Hopefully it crashes and tells me where the crash happened and what is causing the crash.

Revision history for this message
Adam Wolf (adamwolf) wrote :

This is for sallen_key:

Process 11813 stopped
* thread #23, stop reason = EXC_BAD_ACCESS (code=1, address=0x1c0)
    frame #0: 0x00000001104c65ad
libngspice.0.dylib`MIFsetup(matrix=<unavailable>,
inModel=<unavailable>, ckt=<unavailable>, states=<unavailable>) at
mifsetup.c:148:32 [opt]
   145 if(model->param[i]->is_null) {
   146
   147 /* setup a pointer for quick access */
-> 148 param_info = &(DEVices[mod_type]->DEVpublic.param[i]);
   149
   150 /* determine the size and allocate the
parameter element(s) */
   151 if(! param_info->is_array) {
Target 0: (kicad) stopped.

For laser_driver:

Process 12905 stopped
* thread #22, stop reason = EXC_BAD_ACCESS (code=1, address=0x1c0)
    frame #0: 0x000000011d3b25ad
libngspice.0.dylib`MIFsetup(matrix=<unavailable>,
inModel=<unavailable>, ckt=<unavailable>, states=<unavailable>) at
mifsetup.c:148:32 [opt]
   145 if(model->param[i]->is_null) {
   146
   147 /* setup a pointer for quick access */
-> 148 param_info = &(DEVices[mod_type]->DEVpublic.param[i]);
   149
   150 /* determine the size and allocate the
parameter element(s) */
   151 if(! param_info->is_array) {
Target 0: (kicad) stopped.

Is this helpful?

On Tue, Sep 17, 2019 at 9:52 AM Holger Vogt <email address hidden> wrote:
>
> We have:
>
> Thread 10 Crashed:
> 0 libngspice.0.dylib 0x000000011f6d4c5d MIFsetup + 109
> 1 libngspice.0.dylib 0x000000012b3da3d6 CKTsetup + 214
> 2 libngspice.0.dylib 0x000000012b3d41b1 CKTdoJob + 961
>
> What I will do next to figure out where exactly in function MIFsetup of
> file mifsetup.c the crash is happening:
>
> Start eeschema
> load sallen-key project
> Select Tools-->Simulator
>
> *start debugger in terminal
>
> lldb
>
> *attach debugger lldb to process
>
> process attach --name eeschema
>
> * in eeschema simulator window
> Start Simulation
>
> *in terminal watch debugger output
> Hopefully it crashes and tells me where the crash happened and what is causing the crash.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1835296
>
> Title:
> simulating laser_driver on macos nightly causes segfault
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/kicad/+bug/1835296/+subscriptions

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

I have just run recent testing build: No crash

Application: Eeschema
Version: (5.1.4-82-g004b9d336), 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

In addition I have run the 10_14 build from Sept. 16: No crash.

I have exchanged libngspice.0.dylib with my own ngspice versions, ngspice-30 and 31, debug or release: No crash.

I have re-installed the release version: No crash

Application: Eeschema
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

I am stuck right now because I cannot tell you what I did to my machine to allow running all the builds. I will move on with testing (e.g. installing release and current builds side by side).

System info is:

macOS Mojave 10.14.4
Intel i5
8GB memory

Btw.: What is the difference between *.dmg and *10_14.dmg builds?

Revision history for this message
Adam Wolf (adamwolf) wrote :

The 10_14 builds are built targeting macOS 10.14 and higher. The
builds without it are targeting 10.12 and higher, but there were some
anomalies on 10.14.

Did my debug trace help at all?

Adam

On Wed, Sep 18, 2019 at 7:01 AM Holger Vogt <email address hidden> wrote:
>
> I have just run recent testing build: No crash
>
> Application: Eeschema
> Version: (5.1.4-82-g004b9d336), 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
>
> In addition I have run the 10_14 build from Sept. 16: No crash.
>
> I have exchanged libngspice.0.dylib with my own ngspice versions,
> ngspice-30 and 31, debug or release: No crash.
>
> I have re-installed the release version: No crash
>
> Application: Eeschema
> 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
>
> I am stuck right now because I cannot tell you what I did to my machine
> to allow running all the builds. I will move on with testing (e.g.
> installing release and current builds side by side).
>
> System info is:
>
> macOS Mojave 10.14.4
> Intel i5
> 8GB memory
>
> Btw.: What is the difference between *.dmg and *10_14.dmg builds?
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1835296
>
> Title:
> simulating laser_driver on macos nightly causes segfault
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/kicad/+bug/1835296/+subscriptions

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

It tells as about the exact place, but might be good to know the variables.

Could you execute the command

frame variable

Revision history for this message
Adam Wolf (adamwolf) wrote :

This is for sallen_key.

Do I need to modify the ngspice build in order to get these? Just let
me know, I can rebuild everything and retest pretty quickly.

Process 82432 stopped
* thread #16, stop reason = EXC_BAD_ACCESS (code=1, address=0x1c0)
    frame #0: 0x000000013652e5ad
libngspice.0.dylib`MIFsetup(matrix=<unavailable>,
inModel=<unavailable>, ckt=<unavailable>, states=<unavailable>) at
mifsetup.c:148:32 [opt]
   145 if(model->param[i]->is_null) {
   146
   147 /* setup a pointer for quick access */
-> 148 param_info = &(DEVices[mod_type]->DEVpublic.param[i]);
   149
   150 /* determine the size and allocate the
parameter element(s) */
   151 if(! param_info->is_array) {
Target 0: (kicad) stopped.
(lldb) frame variable
(SMPmatrix *) matrix = <variable not available>
(GENmodel *) inModel = <variable not available>
(CKTcircuit *) ckt = <variable not available>
(int *) states = <variable not available>
(MIFmodel *) model = <variable not available>
(MIFinstance *) here = <variable not available>
(int) i = <variable not available>
(int) max_size = <variable not avaiable>
(int) size = <variable not available>
(int) j = <variable not available>
(int) num_conn = <variable not available>
(int) num_port = <variable not available>
(int) k = <variable not available>
(Mif_Boolean_t) is_input = <variable not available>
(Mif_Boolean_t) is_output = <variable not available>
(Mif_Smp_Ptr_t *) smp_data_out = <variable not available>
(Mif_Port_Type_t) type = <variable not available>
(char *) suffix = <variable not available>
(CKTnode *) tmp = <variable not available>
(int) error = <variable not available>
(Mif_Port_Type_t) out_type = <variable not available>
(int) l = <variable not available>
(Mif_Smp_Ptr_t *) smp_data_cntl = <variable not available>
(Mif_Port_Type_t) in_type = <variable not available>
(Mif_Cntl_Src_Type_t) cntl_src_type = <variable not available>
(int) mod_type = <no location, value may have been optimized out>
(int) num_port_k = <no location, value may have been optimized out>
(Mif_Param_Info_t *) param_info = <no location, value may have been
optimized out>

On Wed, Sep 18, 2019 at 8:51 AM Holger Vogt <email address hidden> wrote:
>
> It tells as about the exact place, but might be good to know the
> variables.
>
> Could you execute the command
>
> frame variable
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1835296
>
> Title:
> simulating laser_driver on macos nightly causes segfault
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/kicad/+bug/1835296/+subscriptions

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

Maybe it is necessary to compile without optimization, e.g. without -O2 and -O3 flags.

Revision history for this message
Adam Wolf (adamwolf) wrote :

Holger, am I supposed to run frame variable after the crash? I
compiled with -O0 and also with -Og and both times I got:

(lldb) frame variable
(SMPmatrix *) matrix = <variable not available>
(GENmodel *) inModel = <variable not available>
(CKTcircuit *) ckt = <variable not available>
(int *) states = <variable not available>
(MIFmodel *) model = <variable not available>
(MIFinstance *) here = <variable not available>
(int) i = <variable not available>
(int) max_size = <variable not available>
(int) size = <variable not available>
(int) j = <variable not available>
(int) num_conn = <variable not available>
(int) num_port = <variable not available>
(int) k = <variable not available>
(Mif_Boolean_t) is_input = <variable not available>
(Mif_Boolean_t) is_output = <variable not available>
(Mif_Smp_Ptr_t *) smp_data_out = <variable not available>
(Mif_Port_Type_t) type = <variable not available>
(char *) suffix = <variable not available>
(CKTnode *) tmp = <variable not available>
(int) error = <variable not available>
(Mif_Port_Type_t) out_type = <variable not available>
(int) l = <variable not available>
(Mif_Smp_Ptr_t *) smp_data_cntl = <variable not available>
(Mif_Port_Type_t) in_type = <variable not available>
(Mif_Cntl_Src_Type_t) cntl_src_type = <variable not available>
(int) mod_type = <no location, value may have been optimized out>
(int) num_port_k = <no location, value may have been optimized out>
(Mif_Param_Info_t *) param_info = <no location, value may have been
optimized out>

Any thoughts?

On Thu, Sep 19, 2019 at 7:45 AM Holger Vogt <email address hidden> wrote:
>
> Maybe it is necessary to compile without optimization, e.g. without -O2
> and -O3 flags.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1835296
>
> Title:
> simulating laser_driver on macos nightly causes segfault
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/kicad/+bug/1835296/+subscriptions

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

I can't give you a concise answer, due to my lack of macOS experience.

Still I cannot reproduce the bug here.

Would you mind to try compiling the new ngspice-31 from https://sourceforge.net/p/ngspice/ngspice/ci/master/tarball ?

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

In the dmg distribution, do we have libngspice-0.dylib twice, in package kicad.app, one in folder Frameworks, and one in folder Plugin/sims?

Revision history for this message
Adam Wolf (adamwolf) wrote :

Yes, it's in there twice. It looks like that was the same with
ngspice-28, though, and this crash doesn't happen then.

I can try compiling ngspice-31 but it will have to wait a day or two.
I am trying to juggle getting this fixed and being ready for the 10.15
macOS release.

On Sun, Sep 22, 2019 at 3:20 AM Holger Vogt <email address hidden> wrote:
>
> In the dmg distribution, do we have libngspice-0.dylib twice, in package
> kicad.app, one in folder Frameworks, and one in folder Plugin/sims?
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1835296
>
> Title:
> simulating laser_driver on macos nightly causes segfault
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/kicad/+bug/1835296/+subscriptions

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

There is a new Ngspice tag Ngspice-31-2. Please use only this new one. Some bugs have been removed. Still in my setup there is no crash any more.

To allow quick tests, I have removed (re-named) the Ngspice dylibs coming with the nightlies. Now I am automatically relying on my own generated lib in /usr/local/libs.

I have attached the script for creating libngspice-0.dylib.

How to proceed? Should I publish my dylib here and you check it out?

Revision history for this message
Adam Wolf (adamwolf) wrote :

Did you say that, on your setup, downloaded nightlies no longer crash?
 Have you checked to see if they're using your system-wide ngspice
rather than their built-in ngspice?

On Sun, Sep 29, 2019 at 2:30 AM Holger Vogt <email address hidden> wrote:
>
> There is a new Ngspice tag Ngspice-31-2. Please use only this new one.
> Some bugs have been removed. Still in my setup there is no crash any
> more.
>
> To allow quick tests, I have removed (re-named) the Ngspice dylibs
> coming with the nightlies. Now I am automatically relying on my own
> generated lib in /usr/local/libs.
>
> I have attached the script for creating libngspice-0.dylib.
>
> How to proceed? Should I publish my dylib here and you check it out?
>
> ** Attachment added: "compile_linux_shared.sh"
> https://bugs.launchpad.net/kicad/+bug/1835296/+attachment/5292448/+files/compile_linux_shared.sh
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1835296
>
> Title:
> simulating laser_driver on macos nightly causes segfault
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/kicad/+bug/1835296/+subscriptions

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

I am using

Application: Eeschema
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.7.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

or recent testing nightly. Both libngspice-0.dylib of this distribution removed.

Compiled my own ngspice shared lib libngspice.0.dylib from actual ngspice-31 distribution into /usr/local/lib

Testing: Open new eeschema window, add text window with

.op
.control
version
.endc

Run simulation with the result that ngspice-31 version info is shown.

No crash with the release build, no crash with the nightly from testing, when simulating laser_driver or sallen_key.

Revision history for this message
Adam Wolf (adamwolf) wrote :

Thanks Holger, I'll keep digging into this. I am still trying to
rally up folks and get the 10.15 "can't create new projects" problem
fixed :(

On Sun, Sep 29, 2019 at 9:10 AM Holger Vogt <email address hidden> wrote:
>
> I am using
>
> Application: Eeschema
> 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.7.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
>
> or recent testing nightly. Both libngspice-0.dylib of this distribution
> removed.
>
> Compiled my own ngspice shared lib libngspice.0.dylib from actual
> ngspice-31 distribution into /usr/local/lib
>
> Testing: Open new eeschema window, add text window with
>
> .op
> .control
> version
> .endc
>
> Run simulation with the result that ngspice-31 version info is shown.
>
> No crash with the release build, no crash with the nightly from testing,
> when simulating laser_driver or sallen_key.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1835296
>
> Title:
> simulating laser_driver on macos nightly causes segfault
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/kicad/+bug/1835296/+subscriptions

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

So is this issue officially fixed in ngspice 31-2? If so, we should close this bug report so we are one bug report closer to getting 5.1.5 released.

Revision history for this message
Adam Wolf (adamwolf) wrote :

I don't think we can say that yet. Holger is compiling and packaging
ngspice differently, and when he does that, ngspice-30-2 works as well.

If it is entirely a packaging problem, I do not understand why the same
packaging works fine for ngspice-28 but not 30-2.

I can build and package KiCad with 31-2 today. Fingers crossed.

On Mon, Sep 30, 2019, 7:20 AM Wayne Stambaugh <email address hidden>
wrote:

> So is this issue officially fixed in ngspice 31-2? If so, we should
> close this bug report so we are one bug report closer to getting 5.1.5
> released.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1835296
>
> Title:
> simulating laser_driver on macos nightly causes segfault
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/kicad/+bug/1835296/+subscriptions
>

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

Holger, have you tried running it without a system-wide ngspice installed?

I just tried installing the ngspice-30.pkg, which installs to /Applications/ngspice/ and now I get no crash! Running it inside lldb shows that it's using the code models from the system-wide ngspice instead of the bundled ones:

[355] 254C4F6B-F42A-3CD1-99D5-9AF1A61FEF0E 0x00000001226c2000 /Applications/KiCad/kicad.app/Contents/Frameworks/libngspice.0.dylib
[365] E7997DE7-F937-360E-B3C9-0F57E4DCFA0F 0x0000000119eed000 /Applications/ngspice/lib/ngspice/table.cm
[366] 4EEEFD30-725D-3B3F-91A8-D6E8BF12684D 0x00000001199f9000 /Applications/ngspice/lib/ngspice/spice2poly.cm
[367] 75C17E83-BBDA-3FE7-BDA4-353C984BCC17 0x00000001209ba000 /Applications/ngspice/lib/ngspice/digital.cm
[368] 94632E46-0EEF-3B23-BCA0-2EB35A65D09E 0x0000000119ef8000 /Applications/ngspice/lib/ngspice/xtraevt.cm
[369] 7F629F05-FBAF-396E-A268-31FE1D560A74 0x000000011a58c000 /Applications/ngspice/lib/ngspice/xtradev.cm
[370] 4CB2DA9D-4D59-3C85-B321-3955D0265959 0x00000001209d6000 /Applications/ngspice/lib/ngspice/analog.cm

If I rename /Applications/ngspice to /Applications/ngspice_old, it crashes. And looking at which images is loaded I get:

[355] 254C4F6B-F42A-3CD1-99D5-9AF1A61FEF0E 0x0000000122ede000 /Applications/KiCad/kicad.app/Contents/Frameworks/libngspice.0.dylib
[365] DDA71EBB-A729-3156-9362-147E658F217B 0x00000001216ef000 /Applications/KiCad/kicad.app/Contents/PlugIns/sim/ngspice/table.cm
[366] 13913E9A-0D12-35A6-BFF5-C8E25824AEFA 0x00000001216fb000 /Applications/KiCad/kicad.app/Contents/PlugIns/sim/ngspice/spice2poly.cm
[367] A98F2D9F-ADB3-330D-906D-C3A65D66C038 0x0000000121701000 /Applications/KiCad/kicad.app/Contents/PlugIns/sim/ngspice/digital.cm
[368] BE45BBAA-4248-3F08-AFBC-47D343251D6E 0x0000000121dc0000 /Applications/KiCad/kicad.app/Contents/PlugIns/sim/ngspice/xtraevt.cm
[369] 2DCF5524-0E84-3DC3-B50D-19A5279488F5 0x0000000121dc9000 /Applications/KiCad/kicad.app/Contents/PlugIns/sim/ngspice/xtradev.cm
[370] 02193AF1-757E-374D-955B-1532737C34C7 0x0000000121dd9000 /Applications/KiCad/kicad.app/Contents/PlugIns/sim/ngspice/analog.cm

And here comes the important part: If I manually replace the code models in /Applications/KiCad/kicad.app/Contents/PlugIns/sim/ngspice/ with the ones that was installed from the ngspice-30.pkg, it works without crashes!

So my conclusion is that the MacOS packaging is breaking those files.

Revision history for this message
Adam Wolf (adamwolf) wrote :

Thanks folks. The packaging for those files looks like its just
./configure, make and make install but I'll keep looking.

On Mon, Sep 30, 2019 at 8:51 AM Jonatan Liljedahl
<email address hidden> wrote:
>
> Holger, have you tried running it without a system-wide ngspice
> installed?
>
> I just tried installing the ngspice-30.pkg, which installs to
> /Applications/ngspice/ and now I get no crash! Running it inside lldb
> shows that it's using the code models from the system-wide ngspice
> instead of the bundled ones:
>
> [355] 254C4F6B-F42A-3CD1-99D5-9AF1A61FEF0E 0x00000001226c2000 /Applications/KiCad/kicad.app/Contents/Frameworks/libngspice.0.dylib
> [365] E7997DE7-F937-360E-B3C9-0F57E4DCFA0F 0x0000000119eed000 /Applications/ngspice/lib/ngspice/table.cm
> [366] 4EEEFD30-725D-3B3F-91A8-D6E8BF12684D 0x00000001199f9000 /Applications/ngspice/lib/ngspice/spice2poly.cm
> [367] 75C17E83-BBDA-3FE7-BDA4-353C984BCC17 0x00000001209ba000 /Applications/ngspice/lib/ngspice/digital.cm
> [368] 94632E46-0EEF-3B23-BCA0-2EB35A65D09E 0x0000000119ef8000 /Applications/ngspice/lib/ngspice/xtraevt.cm
> [369] 7F629F05-FBAF-396E-A268-31FE1D560A74 0x000000011a58c000 /Applications/ngspice/lib/ngspice/xtradev.cm
> [370] 4CB2DA9D-4D59-3C85-B321-3955D0265959 0x00000001209d6000 /Applications/ngspice/lib/ngspice/analog.cm
>
> If I rename /Applications/ngspice to /Applications/ngspice_old, it
> crashes. And looking at which images is loaded I get:
>
> [355] 254C4F6B-F42A-3CD1-99D5-9AF1A61FEF0E 0x0000000122ede000 /Applications/KiCad/kicad.app/Contents/Frameworks/libngspice.0.dylib
> [365] DDA71EBB-A729-3156-9362-147E658F217B 0x00000001216ef000 /Applications/KiCad/kicad.app/Contents/PlugIns/sim/ngspice/table.cm
> [366] 13913E9A-0D12-35A6-BFF5-C8E25824AEFA 0x00000001216fb000 /Applications/KiCad/kicad.app/Contents/PlugIns/sim/ngspice/spice2poly.cm
> [367] A98F2D9F-ADB3-330D-906D-C3A65D66C038 0x0000000121701000 /Applications/KiCad/kicad.app/Contents/PlugIns/sim/ngspice/digital.cm
> [368] BE45BBAA-4248-3F08-AFBC-47D343251D6E 0x0000000121dc0000 /Applications/KiCad/kicad.app/Contents/PlugIns/sim/ngspice/xtraevt.cm
> [369] 2DCF5524-0E84-3DC3-B50D-19A5279488F5 0x0000000121dc9000 /Applications/KiCad/kicad.app/Contents/PlugIns/sim/ngspice/xtradev.cm
> [370] 02193AF1-757E-374D-955B-1532737C34C7 0x0000000121dd9000 /Applications/KiCad/kicad.app/Contents/PlugIns/sim/ngspice/analog.cm
>
> And here comes the important part: If I manually replace the code models
> in /Applications/KiCad/kicad.app/Contents/PlugIns/sim/ngspice/ with the
> ones that was installed from the ngspice-30.pkg, it works without
> crashes!
>
> So my conclusion is that the MacOS packaging is breaking those files.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1835296
>
> Title:
> simulating laser_driver on macos nightly causes segfault
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/kicad/+bug/1835296/+subscriptions

Revision history for this message
Adam Wolf (adamwolf) wrote :

Holger, is there any description of how the .pkg files are built for release?

Revision history for this message
Adam Wolf (adamwolf) wrote :

It still happens with ngspice-31, Wayne, so I've got more debugging to do.

All kicad-mac-builder does is:

include(ExternalProject)

ExternalProject_Add(
        ngspice
        PREFIX ngspice
        GIT_REPOSITORY git://git.code.sf.net/p/ngspice/ngspice
        GIT_TAG ngspice-31-2
        UPDATE_COMMAND ""
        PATCH_COMMAND ""
        CONFIGURE_COMMAND ./autogen.sh
        COMMAND ./configure --with-ngshared --enable-xspice --enable-cider --prefix=${ngspice_INSTALL_DIR} --enable-debug=yes
        BUILD_COMMAND ${MAKE}
        BUILD_IN_SOURCE 1
        INSTALL_COMMAND make install
)

and then we fixup the libngspice library like we do every other library (and like we did on ngspice-28 which worked fine). We do nothing special to the code models.

We had debug disabled, but only recently turned it on per requests in this ticket.

I will try Holger's CFLAGS and LDFLAGs next.

Revision history for this message
Adam Wolf (adamwolf) wrote :

Holger's build script says you *have* to make clean to properly build the codemodels. Let me try that.

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

In between ngspice-26 and ngspice-27 there has been a change in the codemodel interface that retains the ngspice-26 code models incompatible. Could it have happened that the code models of the new KiCad builds were not remade and still were version 26 (therefore the 'make clean' for the code models)?

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

Concerning the pkg files for ngspice: Francesco Lannutti is making these for me (My MAC is just two weeks old). I have to ask him.

Revision history for this message
Adam Wolf (adamwolf) wrote :

All mac releases, nightly or full, are created in a new VM. It then
installs all the dependencies, downloads all the source code, and
builds everything. Then it copies the release artifacts and build log
out, and then deletes itself. (This is a long way of saying there's
no chance that ngspice-26 code models are being reused :) )

On Mon, Sep 30, 2019 at 11:15 AM Holger Vogt <email address hidden> wrote:
>
> In between ngspice-26 and ngspice-27 there has been a change in the
> codemodel interface that retains the ngspice-26 code models
> incompatible. Could it have happened that the code models of the new
> KiCad builds were not remade and still were version 26 (therefore the
> 'make clean' for the code models)?
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1835296
>
> Title:
> simulating laser_driver on macos nightly causes segfault
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/kicad/+bug/1835296/+subscriptions

Revision history for this message
Adam Wolf (adamwolf) wrote :

Thanks! It would be good to find out how they're made. I have a
variety of experimental builds running right now. I think we'll get
this soon.

On Mon, Sep 30, 2019 at 11:15 AM Holger Vogt <email address hidden> wrote:
>
> Concerning the pkg files for ngspice: Francesco Lannutti is making these
> for me (My MAC is just two weeks old). I have to ask him.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1835296
>
> Title:
> simulating laser_driver on macos nightly causes segfault
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/kicad/+bug/1835296/+subscriptions

Revision history for this message
Adam Wolf (adamwolf) wrote :

I have a big matrix of builds running, with a variety of parameters
and source versions. I have found some work fine, so now to let the
rest of them build and see if we can come to a conclusion.

On Mon, Sep 30, 2019 at 12:26 PM Adam Wolf
<email address hidden> wrote:
>
> Thanks! It would be good to find out how they're made. I have a
> variety of experimental builds running right now. I think we'll get
> this soon.
>
>
> On Mon, Sep 30, 2019 at 11:15 AM Holger Vogt <email address hidden> wrote:
> >
> > Concerning the pkg files for ngspice: Francesco Lannutti is making these
> > for me (My MAC is just two weeks old). I have to ask him.
> >
> > --
> > You received this bug notification because you are subscribed to the bug
> > report.
> > https://bugs.launchpad.net/bugs/1835296
> >
> > Title:
> > simulating laser_driver on macos nightly causes segfault
> >
> > To manage notifications about this bug go to:
> > https://bugs.launchpad.net/kicad/+bug/1835296/+subscriptions

Changed in kicad:
status: Confirmed → Fix Committed
status: Fix Committed → Confirmed
Revision history for this message
Adam Wolf (adamwolf) wrote :

Hi folks!

Can people try builds from 2019-10-01 or 2019-10-02 from https://kicad-downloads.s3.cern.ch/index.html?prefix=osx/nightly/? With these, I can simulate both laser driver and sallen key. Please note that if you have ngspice installed on your Mac, you probably won't reproduce the bug reported here regardless of which build you test with.

Please report back.

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

Finally I have got a test setup:
Delete all occurrences of libngspice dylib and code models (analog.cm etc) in /usr and elsewhere except in KiCad installations. Delete installed Ngspice.
Restart the computer (seems to be important, there is some "memory effect").

Now I have KiCad 5.1.4 (most recent release build) and recent KiCad 5.9.9 (your suggestion from above) installed in parallel.

Starting 5.1.4 from eeschema: simulation of Sallen_Key o.k..
Staring 5.1.4 via KiCad app: crash as reported in this thread

Starting 5.9.9 via eeschema: simulation not o.k., code models (spice2poly.cm) are not found
Starting 5.9.9 via KiCad: simulation o.k. for Laser Driver and Sallen_Key!!

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

I tried 2019-10-02 from https://kicad-downloads.s3.cern.ch/index.html?prefix=osx/nightly/ and it works fine for me! Will this be fixed also for the 5.1 branch?

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

BTW, it only works if KiCad is installed in /Applications/KiCad/, otherwise it can't find the code model files. Is this search path a compile time constant, or could it instead look in the actual running app bundle? A user might install it in ~/Applications/KiCad/ instead, or /Applications/KiCad_testing etc..

Revision history for this message
Adam Wolf (adamwolf) wrote :

Hi Jonatan,

That search path is not complied into ngspice at all. It works for me both
inside and outside of Applications, and renamed. I do not have ngspice
installed anywhere on my computer, and those downloaded installs work for
me where ever I place them. I did not test as standalone or not, but I
will test that as well.

Adam

On Thu, Oct 3, 2019, 5:01 AM Jonatan Liljedahl <email address hidden>
wrote:

> BTW, it only works if KiCad is installed in /Applications/KiCad/,
> otherwise it can't find the code model files. Is this search path a
> compile time constant, or could it instead look in the actual running
> app bundle? A user might install it in ~/Applications/KiCad/ instead, or
> /Applications/KiCad_testing etc..
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1835296
>
> Title:
> simulating laser_driver on macos nightly causes segfault
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/kicad/+bug/1835296/+subscriptions
>

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

Eeschema is sending commands 'code model ...' to Ngspice one by one to load all code models. One has to look into the eeschema sources to find out what path is used.

Revision history for this message
Ian McInerney (imcinerney) wrote :

There are some hardcoded code model paths in the ngspice.cpp file (see NGSPICE::findCmPath on line 438) that it will search through. These seem to be the paths it will look at to find spice2poly.cm (if that file exists, it says it found the code model paths).
    const vector<string> cmPaths =
    {
#ifdef __WXMAC__
        "/Applications/ngspice/lib/ngspice",
        "Contents/Frameworks",
        wxStandardPaths::Get().GetPluginsDir() + "/sim/ngspice",
        wxFileName( wxStandardPaths::Get().GetExecutablePath() ).GetPath() + "/../../../../../Contents/PlugIns/sim/ngspice"
#endif /* __WXMAC__ */
        "../lib/ngspice",
        "../../lib/ngspice"
        "lib/ngspice",
        "ngspice"
    };

From my reading of the code, you can override these paths by specifying a spiceinit file that lives on one of the (relative) searched paths:
    const vector<string> spiceinitPaths =
    {
        ".",
#ifdef __WXMAC__
        stdPaths.GetPluginsDir() + "/sim/ngspice/scripts",
        wxFileName( stdPaths.GetExecutablePath() ).GetPath() + "/../../../../../Contents/PlugIns/sim/ngspice/scripts"
#endif /* __WXMAC__ */
        "../share/kicad",
        "../share",
        "../../share/kicad",
        "../../share"
    };

Eeschema will send the code model commands if it didn't find a spiceinit file and if it was able to find the code model path.

Revision history for this message
Adam Wolf (adamwolf) wrote :

Hi folks,

It works for me on those october builds in both standalone eeschema
and in regular kicad, in Applications and outside of Applications.
Please confirm that you are not starting eeschema before opening kicad
one time. It is required that kicad be opened one time before
starting eeschema, due to some macOS technicalities.

I am no longer seeing this issue.

If I build ngspice31-2 with --enable-debug=yes, then the issue comes
back. ngspice 28 works with both debug enabled and disabled, but 31-2
does not. I have switched nightlies to use 31-2 to --disable-debug,
and that's what is in the October nightly builds. Holger--when you
hear from the mac package for ngspice, that would be awesome. I would
love to compile with the same flags as they do for increased
compatibility reasons.

I appreciate everyone's patience around this issue. I have other very
pressing issues with macOS packaging that also need my attention, but
I'm giving most of my attention to this ticket since it is the loudest
:)

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

Small correction: The commands sent by eeschema, to be executed by Ngspice are:

codemodel <path>/analog.cm
codemodel <path>/spice2poly.cm
...

<path> may be absolute or relative. If relative, the question might be: Relative to what reference?

Revision history for this message
Adam Wolf (adamwolf) wrote :

It is possible that we need to investigate NGSPICE::findCmPath() in
https://github.com/KiCad/kicad-source-mirror/blob/e5463b545514ddfc849c6985e8884d1dec5edd3b/eeschema/sim/ngspice.cpp.

On Thu, Oct 3, 2019 at 10:05 AM Adam Wolf <email address hidden> wrote:
>
> Hi folks,
>
> It works for me on those october builds in both standalone eeschema
> and in regular kicad, in Applications and outside of Applications.
> Please confirm that you are not starting eeschema before opening kicad
> one time. It is required that kicad be opened one time before
> starting eeschema, due to some macOS technicalities.
>
> I am no longer seeing this issue.
>
> If I build ngspice31-2 with --enable-debug=yes, then the issue comes
> back. ngspice 28 works with both debug enabled and disabled, but 31-2
> does not. I have switched nightlies to use 31-2 to --disable-debug,
> and that's what is in the October nightly builds. Holger--when you
> hear from the mac package for ngspice, that would be awesome. I would
> love to compile with the same flags as they do for increased
> compatibility reasons.
>
> I appreciate everyone's patience around this issue. I have other very
> pressing issues with macOS packaging that also need my attention, but
> I'm giving most of my attention to this ticket since it is the loudest
> :)

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

> That search path is not complied into ngspice at all. It works for me both
> inside and outside of Applications, and renamed. I do not have ngspice
> installed anywhere on my computer, and those downloaded installs work for
> me where ever I place them. I did not test as standalone or not, but I
> will test that as well.

This is weird. I tried again running kicad.app from
"/Applications/KiCad 5.99/" and now it worked as expected. I'm 99%
sure I did exactly as before. Maybe some other random bug, or some OS
caching mystery?

--
/Jonatan
http://kymatica.com

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

> > That search path is not complied into ngspice at all. It works for me both
> > inside and outside of Applications, and renamed. I do not have ngspice
> > installed anywhere on my computer, and those downloaded installs work for
> > me where ever I place them. I did not test as standalone or not, but I
> > will test that as well.
>
> This is weird. I tried again running kicad.app from
> "/Applications/KiCad 5.99/" and now it worked as expected. I'm 99%
> sure I did exactly as before. Maybe some other random bug, or some OS
> caching mystery?

Update: now I see the difference. When running via lldb:

lijon-mbp:Applications lijon$ cd KiCad\ 5.99/
lijon-mbp:KiCad 5.99 lijon$ lldb kicad.app
(lldb) target create "kicad.app"
Current executable set to 'kicad.app' (x86_64).
(lldb) run

It does not find the cm files:

Error on line 0 :
a$poly$e.xu1.x1.egnd %vd [ +12v 0 -12v 0 ] %vd ( xu1.x1.99 0 )
a$poly$e.xu1.x1.egnd
MIF-ERROR - unable to find definition of model a$poly$e.xu1.x1.egnd
Warning: Model issue on line 0 :
.model a$poly$e.xu1.x1.egnd spice2poly coef = [ 0 .5 .5 ] ...
Unknown model type spice2poly - ignored
...

Running it like this from the commandline works though:

lijon-mbp:Applications lijon$ cd KiCad\ 5.99/
lijon-mbp:KiCad 5.99 lijon$ open kicad.app

But not like this (can't find cm files):

lijon-mbp:KiCad 5.99 lijon$ cd kicad.app
lijon-mbp:kicad.app lijon$ Contents/MacOS/kicad

Unless I rename the folder to "KiCad" only, then it works:

lijon-mbp:Applications lijon$ cd KiCad
lijon-mbp:KiCad lijon$ cd kicad.app/
lijon-mbp:kicad.app lijon$ Contents/MacOS/kicad

So, there's definitely some room for improvement here.

--
/Jonatan
http://kymatica.com

Revision history for this message
Adam Wolf (adamwolf) wrote :

Can you try running kicad and eeschema by clicking on the icon? :D I
have tried the October nightlies on multiple computers and do not have
issues with ngspice and sallen_key or laser_driver on any of those.
If that works fine for you, I'm going to close this ticket.

If you want to reopen a new one for opening kicad from the command
line from different locations on macos, that's a new ticket. It is
unclear to me from your transcript what you're doing or what's going
on, so maybe add a little more explanation.

On Thu, Oct 3, 2019 at 1:06 PM Jonatan Liljedahl
<email address hidden> wrote:
>
> > > That search path is not complied into ngspice at all. It works for me both
> > > inside and outside of Applications, and renamed. I do not have ngspice
> > > installed anywhere on my computer, and those downloaded installs work for
> > > me where ever I place them. I did not test as standalone or not, but I
> > > will test that as well.
> >
> > This is weird. I tried again running kicad.app from
> > "/Applications/KiCad 5.99/" and now it worked as expected. I'm 99%
> > sure I did exactly as before. Maybe some other random bug, or some OS
> > caching mystery?
>
> Update: now I see the difference. When running via lldb:
>
> lijon-mbp:Applications lijon$ cd KiCad\ 5.99/
> lijon-mbp:KiCad 5.99 lijon$ lldb kicad.app
> (lldb) target create "kicad.app"
> Current executable set to 'kicad.app' (x86_64).
> (lldb) run
>
> It does not find the cm files:
>
> Error on line 0 :
> a$poly$e.xu1.x1.egnd %vd [ +12v 0 -12v 0 ] %vd ( xu1.x1.99 0 )
> a$poly$e.xu1.x1.egnd
> MIF-ERROR - unable to find definition of model a$poly$e.xu1.x1.egnd
> Warning: Model issue on line 0 :
> .model a$poly$e.xu1.x1.egnd spice2poly coef = [ 0 .5 .5 ] ...
> Unknown model type spice2poly - ignored
> ...
>
> Running it like this from the commandline works though:
>
> lijon-mbp:Applications lijon$ cd KiCad\ 5.99/
> lijon-mbp:KiCad 5.99 lijon$ open kicad.app
>
> But not like this (can't find cm files):
>
> lijon-mbp:KiCad 5.99 lijon$ cd kicad.app
> lijon-mbp:kicad.app lijon$ Contents/MacOS/kicad
>
> Unless I rename the folder to "KiCad" only, then it works:
>
> lijon-mbp:Applications lijon$ cd KiCad
> lijon-mbp:KiCad lijon$ cd kicad.app/
> lijon-mbp:kicad.app lijon$ Contents/MacOS/kicad
>
> So, there's definitely some room for improvement here.
>
> --
> /Jonatan
> http://kymatica.com
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1835296
>
> Title:
> simulating laser_driver on macos nightly causes segfault
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/kicad/+bug/1835296/+subscriptions

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

When run from KiCad in my setup (double click onto KiCad/kicad.app alias), code model spice2poly.cm is found, simulation is o.k..

When run from Eeschema in my setup (double click onto KiCad/eeschema.app alias), code model spice2poly.cm is not found.

May I suggest that we add another search path "../Plugins/sim/ngspice" to eeschema/sim/ngspice.cpp, line 447:

#ifdef __WXMAC__
        "/Applications/ngspice/lib/ngspice",
        "Contents/Frameworks",
        wxStandardPaths::Get().GetPluginsDir() + "/sim/ngspice",
        wxFileName( wxStandardPaths::Get().GetExecutablePath() ).GetPath() + "/../../../../../Contents/PlugIns/sim/ngspice"
        "../Plugins/sim/ngspice"
#endif /* __WXMAC__ */

This will search for the code model relative to KiCad/kicad.app/contents/Applications/eeschema.app

Btw: I can do this from within Ngspice by adding a text window with

.control
pre_codemodel ../Plugins/sim/ngspice/spice2poly.cm
.endc

to the eeschema circuit diagram. A ngspice command may be preceded by pre_ . Then it is run before the circuit is parsed. The code model is loaded, then the circuit is loaded into the matrix and the simulation runs successfully.

Application: Eeschema
Version: (5.99.0-192-g5933ac3b9), 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.7.0 x86_64), 64 bit, Little endian, wxMac
Build Info:
    Build date: Oct 2 2019 10:19:28
    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:
    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
    KICAD_STDLIB_DEBUG=OFF
    KICAD_STDLIB_LIGHT_DEBUG=OFF
    KICAD_SANITIZE=OFF

Revision history for this message
Adam Wolf (adamwolf) wrote :

Yeah, I can submit the patch to KiCad tonight!

Thanks Holger!

On Thu, Oct 3, 2019, 4:41 PM Holger Vogt <email address hidden> wrote:

> When run from KiCad in my setup (double click onto KiCad/kicad.app
> alias), code model spice2poly.cm is found, simulation is o.k..
>
> When run from Eeschema in my setup (double click onto KiCad/eeschema.app
> alias), code model spice2poly.cm is not found.
>
> May I suggest that we add another search path "../Plugins/sim/ngspice"
> to eeschema/sim/ngspice.cpp, line 447:
>
> #ifdef __WXMAC__
> "/Applications/ngspice/lib/ngspice",
> "Contents/Frameworks",
> wxStandardPaths::Get().GetPluginsDir() + "/sim/ngspice",
> wxFileName( wxStandardPaths::Get().GetExecutablePath() ).GetPath()
> + "/../../../../../Contents/PlugIns/sim/ngspice"
> "../Plugins/sim/ngspice"
> #endif /* __WXMAC__ */
>
> This will search for the code model relative to
> KiCad/kicad.app/contents/Applications/eeschema.app
>
> Btw: I can do this from within Ngspice by adding a text window with
>
> .control
> pre_codemodel ../Plugins/sim/ngspice/spice2poly.cm
> .endc
>
> to the eeschema circuit diagram. A ngspice command may be preceded by
> pre_ . Then it is run before the circuit is parsed. The code model is
> loaded, then the circuit is loaded into the matrix and the simulation
> runs successfully.
>
> Application: Eeschema
> Version: (5.99.0-192-g5933ac3b9), 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.7.0 x86_64), 64 bit, Little endian, wxMac
> Build Info:
> Build date: Oct 2 2019 10:19:28
> 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:
> 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
> KICAD_STDLIB_DEBUG=OFF
> KICAD_STDLIB_LIGHT_DEBUG=OFF
> KICAD_SANITIZE=OFF
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1835296
>
> Title:
> simulating laser_driver on macos nightly causes segfault
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/kicad/+bug/1835296/+subscriptions
>

Revision history for this message
Adam Wolf (adamwolf) wrote :

Is anyone else having email troubles on this ticket? I just got one of
Jonatan's messages a few minutes ago, this evening, even though I see
it was quoted in later responses that I got hours ago!

On Thu, Oct 3, 2019 at 1:46 PM Adam Wolf <email address hidden> wrote:
>
> Can you try running kicad and eeschema by clicking on the icon? :D I
> have tried the October nightlies on multiple computers and do not have
> issues with ngspice and sallen_key or laser_driver on any of those.
> If that works fine for you, I'm going to close this ticket.
>
> If you want to reopen a new one for opening kicad from the command
> line from different locations on macos, that's a new ticket. It is
> unclear to me from your transcript what you're doing or what's going
> on, so maybe add a little more explanation.
>
> On Thu, Oct 3, 2019 at 1:06 PM Jonatan Liljedahl
> <email address hidden> wrote:
> >
> > > > That search path is not complied into ngspice at all. It works for me both
> > > > inside and outside of Applications, and renamed. I do not have ngspice
> > > > installed anywhere on my computer, and those downloaded installs work for
> > > > me where ever I place them. I did not test as standalone or not, but I
> > > > will test that as well.
> > >
> > > This is weird. I tried again running kicad.app from
> > > "/Applications/KiCad 5.99/" and now it worked as expected. I'm 99%
> > > sure I did exactly as before. Maybe some other random bug, or some OS
> > > caching mystery?
> >
> > Update: now I see the difference. When running via lldb:
> >
> > lijon-mbp:Applications lijon$ cd KiCad\ 5.99/
> > lijon-mbp:KiCad 5.99 lijon$ lldb kicad.app
> > (lldb) target create "kicad.app"
> > Current executable set to 'kicad.app' (x86_64).
> > (lldb) run
> >
> > It does not find the cm files:
> >
> > Error on line 0 :
> > a$poly$e.xu1.x1.egnd %vd [ +12v 0 -12v 0 ] %vd ( xu1.x1.99 0 )
> > a$poly$e.xu1.x1.egnd
> > MIF-ERROR - unable to find definition of model a$poly$e.xu1.x1.egnd
> > Warning: Model issue on line 0 :
> > .model a$poly$e.xu1.x1.egnd spice2poly coef = [ 0 .5 .5 ] ...
> > Unknown model type spice2poly - ignored
> > ...
> >
> > Running it like this from the commandline works though:
> >
> > lijon-mbp:Applications lijon$ cd KiCad\ 5.99/
> > lijon-mbp:KiCad 5.99 lijon$ open kicad.app
> >
> > But not like this (can't find cm files):
> >
> > lijon-mbp:KiCad 5.99 lijon$ cd kicad.app
> > lijon-mbp:kicad.app lijon$ Contents/MacOS/kicad
> >
> > Unless I rename the folder to "KiCad" only, then it works:
> >
> > lijon-mbp:Applications lijon$ cd KiCad
> > lijon-mbp:KiCad lijon$ cd kicad.app/
> > lijon-mbp:kicad.app lijon$ Contents/MacOS/kicad
> >
> > So, there's definitely some room for improvement here.
> >
> > --
> > /Jonatan
> > http://kymatica.com
> >
> > --
> > You received this bug notification because you are subscribed to the bug
> > report.
> > https://bugs.launchpad.net/bugs/1835296
> >
> > Title:
> > simulating laser_driver on macos nightly causes segfault
> >
> > To manage notifications about this bug go to:
> > https://bugs.launchpad.net/kicad/+bug/1835296/+subscriptions

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

@Adam, I occasionally see this. It's just one of the quirks of Launchpad I've learned to accept.

Revision history for this message
Adam Wolf (adamwolf) wrote :

No problem! I was worried I was just getting old!

On Fri, Oct 4, 2019, 12:51 PM Wayne Stambaugh <email address hidden>
wrote:

> @Adam, I occasionally see this. It's just one of the quirks of
> Launchpad I've learned to accept.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1835296
>
> Title:
> simulating laser_driver on macos nightly causes segfault
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/kicad/+bug/1835296/+subscriptions
>

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

I have the fear that we are curing symptoms, but not yet have found the root cause.

Yesterday I have got a new crash with similar cause, after compiling with debug symbols. All we have seen here is always about the initialization of the device count number that ngspice uses, and only when we add the XSPICE devices like spice2poly.

This device count number gets inconsistent, and thus may create a buffer overflow, when trying to read the device parameters. Yesterday's crash occured occured early in the ngspice initialization routine because the device number had already been set (that typically is done later during the initialization).

What may be the reason?
- Calling ngspice initialization twice (currently ngspice does not safeguard against this request)
- Loading the codemodels before initialization
- ... ?

And there has been a change in the ngspice code for creating this number (in between ngspice-26 and ngspice-27 releases). It used to be hard-wired before, now it is evaluated dynamically (ngspice/src/spicelib/devices/dev.c), thus taking into account various (seldom used) compile options concerning device selections. And therefore it has become sensitive to double initialization ...

Unfortunately the crashes are not easily to reproduce because of some macOS internal states. When I manage to achive that, I will look into this (I am not a fan of command line debuggers like lldb). It the should be easily possible to safeguard against double initialization in ngspice. There is code in eeschma ngspice.cpp to prevent double initialization, but what if this is called from a different thread? And why do we need libngspice-0.dylib twice in the distribution?

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

There is a patch on ngspice master branch that prevents false initialization.

All my tests on macOS seem to be o.k. (see my careful wording!).

Could you make the next nightly with this ngspice version?

Revision history for this message
Adam Wolf (adamwolf) wrote :

I hear what you are saying, Holger.

I propose I switch the nightlies to this new patch, and then I am going to
pause working on this for a few days so I can work on some other macOS
bundling changes, at least one of which will probably affect this issue.

I think we are in a better state than before.

Many of the weirdnesses of the KiCad Mac bundle are because of the symlinks
in the bundle. I am going to be removing them very soon, and it is
possible that it will change some of the underlying behavior (for the
better, is my guess).

On Sat, Oct 5, 2019, 6:35 AM Holger Vogt <email address hidden> wrote:

> There is a patch on ngspice master branch that prevents false
> initialization.
>
> All my tests on macOS seem to be o.k. (see my careful wording!).
>
> Could you make the next nightly with this ngspice version?
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1835296
>
> Title:
> simulating laser_driver on macos nightly causes segfault
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/kicad/+bug/1835296/+subscriptions
>

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

I have made a new bug-fix release tagged ngspice-31.3, based on current mngspice master branch, including the fixes mentioned above.

Changed in kicad:
milestone: 5.1.5 → 5.1.6
Revision history for this message
Ian McInerney (imcinerney) wrote :

What is the status of this?

Revision history for this message
Adam Wolf (adamwolf) wrote :

We haven't had any reports of this happening since I updated to the
master branch of ngspice. I'm going to tie it to tag ngspice-31.3
right now.

I think this can be closed, AFAICT.

On Sun, Nov 10, 2019 at 7:15 PM Ian McInerney <email address hidden> wrote:
>
> What is the status of this?
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1835296
>
> Title:
> simulating laser_driver on macos nightly causes segfault
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/kicad/+bug/1835296/+subscriptions

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

@Adam, does this apply for the script you use you build 5.1.5? Maybe we should re-target the milestone if so.

Revision history for this message
Adam Wolf (adamwolf) wrote :

I think we should apply this to 5.1.5.

On Thu, Nov 14, 2019, 3:31 PM Nick Østergaard <email address hidden>
wrote:

> @Adam, does this apply for the script you use you build 5.1.5? Maybe we
> should re-target the milestone if so.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1835296
>
> Title:
> simulating laser_driver on macos nightly causes segfault
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/kicad/+bug/1835296/+subscriptions
>

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

Ok, it seems I can't select the milestone as it is closed. Lets jut call it fix comitted then.

Changed in kicad:
status: Confirmed → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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