gnucap-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnucap-devel] infinite loop in spice parser


From: al davis
Subject: Re: [Gnucap-devel] infinite loop in spice parser
Date: Fri, 29 Mar 2013 20:15:02 -0400
User-agent: KMail/1.13.5 (Linux/2.6.32-5-amd64; KDE/4.4.5; x86_64; ; )

Thanks for the bug report.


On Friday 29 March 2013, Felix Salfelder wrote:
> Hi Al, hi list.
> 
> playing with spicelib, i found the parser hanging at
> gnucap-spice>C1 0 1 2;
> 
> while its not exceptionally clever to place that semicolon,
> it's still a gnucap bug.
> 
> i fixed it with
> 
>      cmd >> node_name;
> +    if(spots.back() == cmd.cursor()) {
> +      throw Exception("what's this?");
> +    }
>      spots.push_back(cmd.cursor());

The usual gnucap way to handle that would be:

    unsigned here = cmd.cursor();
    cmd >> node_name;
    if (cmd.stuck(&here)) {
.....

your way works too.

Having opened this one up .. What does Spice (NGspice?) do?

How does Spice (any of them) handle a semicolon?

What should it do?

Does that spice use a semicolon to introduce a comment?

It seems to me that perhaps the semicolon should be treated as 
"end of statement", so perhaps ...

      num_nodes = i;
      break;
    }else if (cmd.is_end()) {
      // found the end, no '='

should be 

      num_nodes = i;
      break;
    }else if (cmd.skip1b(';') || cmd.is_end()) {
      // found the end, no '='

??

It still needs the check for "stuck".


For readers who don't understand that code, wonder what it does 
...

Consider, in spice format, the line:

X1 a b c d e f g h i j

Which are nodes?  subckt name?  parameters?

Good luck.

How about 

X1 a b c d e=f g=h i=j

ok .. now we can tell "d" is the subckt name, a,b,c are nodes 
....

this function is the one to figure that out.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]