ngspice Segmnt Violation at first tran step

Help
2009-04-25
2013-06-12
  • Sharad N. Nandgaonkar

    We had ng-spice-rework-18 version running on RedHat EL3 and RedHat EL4 and
    were running into the “23018: Subckt Stack underflow” problem discussed in
    http://sourceforge.net/forum/forum.php?thread_id=3041566&forum_id=120973 .

    So we downloaded the latest version from CVS (as of  Tiesday April 21,
    2009) and built it (as rework-19).  Then we are getting a segmentation
    violation after it computes the initial operating point solution and
    trying to find the first transient time point after t=0.  The gdb call-
    stack given below shows that ckt->CKTstate to be {0x2a95d73010,
    0x2a95c0b010, 0x2a95cbf010, 0x0, 0x0, 0x0, 0x0, 0x0}.  That is,
    (ckt->CKTstate3 is NULL and hence the segmentation fault.

    Has anyone else run into this before?  Is there a fix available for it?

    Thanks,

    Sharad

    #0  0x0000000000a20579 in DCtran (ckt=0x3cd42a0, restart=1) at
    dctran.c:774
    774                     *(ckt->CKTstate3+i) = *(ckt->CKTstate1+i);
    (gdb) bt
    #0  0x0000000000a20579 in DCtran (ckt=0x3cd42a0, restart=1) at dctran.c:774
    #1  0x0000000000a12e66 in CKTdoJob (inCkt=0x3cd42a0, reset=1, inTask=0x3cd4840) at cktdojob.c:202
    #2  0x000000000043eb0c in if_run (t=0x3cd42a0 "pE \003", wha=0xa7aea9 "run", args=0x0, tab=0x3cd41b0 "\020pe\225*") at spiceif.c:339
    #3  0x000000000043af21 in dosim (what=0xa7aea9 "run", wl=0x1c00a30) at runcoms.c:296
    #4  0x000000000043b0c6 in ft_dorun (file=0x23e95a0 "p1ng.raw") at runcoms.c:359
    #5  0x0000000000404d14 in main (argc=5, argv=0x7fbffff408) at main.c:1119

     
    • Holger Vogt

      Holger Vogt - 2009-04-26

      Sharad,

      could you make your input available to me? Or generate any other test case creating the seg fault?

      I would then have a look.

      Regards

      Holger

       
    • Holger Vogt

      Holger Vogt - 2009-04-26

      Sharad,

      for testing purposes I have started a simulation with more than 300000 transistors (10  15k inverter chains in parallel) using the actual ngspice-19 for MS Windows (compiled with MINGW) on a Windows XP system.  Transient simulation is running. So I do not see a limit with this large "circuit". It needs however a lot of memory. Do you have enough memory in your machine (probably you will need more than 512 MB)?

      Regards

      Holger

       
    • Sharad N. Nandgaonkar

      Hi Holger,

      Thanks for your quick response.  I cannot send the circuit out because it contains customer proprietary information.  We will try to reduce/change it to reproduce the problem independently.

      We are using RedHat Linux RHEL4 on xeonoct machines with 16+ GB of memory, and 64-bit compilation.  So memory availability does not seem to be a problem.  The machine did not have any other significant load when running the simulation.

      I was hoping that knowing the location of the SegV as reported by gdb would give some insight into the problem in the code.  At a somewhat superficial level it seems that on the first tran timestep there is some problem and the program control flow is coming to this portion of the code with only the current point (at the first tran time step being computed), the previous point (the starting op-point solution at t=0) being available.  The code has allocated one more state array to "shift the points back" to prepare for taking the next step, but is somehow assuming that that one more state vector (ckt->CKTstate3) has been allocated for the shift.  And trying to write to that unallocated vector location is causing the SegV.  (So, would simply checking if the state vector pointer is non-null before trying to copy the data to those locations fix the problem?  Or would that be a band-aid fix that would create/hide other problems?)

      Anyway, we will try to see if we can reproduce the problem with a netlist that can be sent sent out.

      Regards,

      Sharad

       
    • Holger Vogt

      Holger Vogt - 2009-04-28

      Sharad,

      there is a bug:

      if you use
      .option method=gear maxord=1
      or
      .option method=trap maxord=1
      which should work according to the manual (yielding the Euler method), it does not, but reproduces your seg fault.

      If you use
      .option method=gear maxord=2
      or
      .option method=trap maxord=2
      instead, it is o.k.

      .option method=trap maxord=1 already fails will plane old spice3f5, may have been repaired with other spice variants.

      Please let me know if this is the error source.

      Regards

      Holger

       
    • Holger Vogt

      Holger Vogt - 2009-04-28

      Sharad,

      to be more specific:
      .option method=gear maxord=1
      is not allowed,
      .option method=trap maxord=1
      should be o.k. (Euler method: I do not know if it is implemeted).

      Regards

      Holger

       
    • Sharad N. Nandgaonkar

      Hello Holger,

      Thanks for your investigations.  We did get a very small example (pasted below to keep this bug-report self contained).  I also tried your suggestions on the same example and found that:
          .option method=trap maxord=1 ---> Had SegV
          .option method=trap maxord=2 ---> No SegV
          .option method=gear maxord=1 ---> Had SegV
          .option method=gear maxord=2 ---> No SegV

      So it does seem that by using a method of order 1 there is no 3rd previous state vector value at the first step after t=0 (so ckt->CKTstate3 is NULL) and so just checking for the NULL value and avoiding the copying will be a reasonable fix for this.  But I am still hesitating to put this in due to unfamiliarity with the code details.  (I will look up the procedure for sending in a verified bug fix to ngspice source code -- starting with some very trivial cosmetic changes etc.  Any simple pointers to getting started properly will be much appreciated.)

      At least we will bypass this bug for now using one of the combinations that work.

      Thanks again for your help,
      Sharad

      -=-=-=-=-=-=- Begin example file s1.sp -=-=-=-=-=-=-
      * ngspice has SegV for ".option method=gear maxord=1" etc.

      .option  method=trap maxord=1
      .Temp 23

      vgsp_1  in_p_1_src  0  pwl ( 0 -.12 250p -.12 300p 0 550p 0 600p .6 )
      r_p_g_1   in_p_1_src  in_p_1  0.1

      vdsp_1  drain_p_1_src  0  pwl ( 0 -.12 2n -.12 2.5n 0 )
      r_p_d_1   drain_p_1_src  drain_p_1   0.1

      vgsp_D_1  in_p_d_1  0  pwl ( 0 1.2 100p 1.2 105p 0 15000p 0 15005p 1.2 16n 1.2 )

      vdd_1     nvdd_1    0    1.2

      mp:xinv5   drain_p_1 in_p_1 nvdd_1 blk_1  pch  l=0.125 w=9.5 ps=9.625 pd=9.625 as=1.1875 ad=1.1875

      rblk_1  blk_1  nvdd_1  0.1

      mp:xinv5_dly   out_1_d in_p_d_1 nvdd_1 blk_1_d  pch  l=0.125 w=9.5 ps=9.625 pd=9.625 as=1.1875 ad=1.1875

      rblk_1_d  blk_1_d  nvdd_1  0.1

      .ic v(out_1_d)=0

      .plot tran v(out_1_d)

      .TRAN  10p  16n

      .end
      -=-=-=-=-=-=- End of example file s1.sp -=-=-=-=-=-=-

       
    • Holger Vogt

      Holger Vogt - 2009-05-21

      Sharad,

      Euler method is not implemented in ngspice.

      Therefore maxord=2 is needed. maxord=1 will not work.

      Regards

      Holger

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks