From bug-octave-request at bevo dot che dot wisc dot edu Mon Nov 18 18:33:45 2002 Subject: crash bug in 2.1.39 (function definition) From: "John W. Eaton" To: Hein Zelle Cc: bug-octave at bevo dot che dot wisc dot edu Date: Mon, 18 Nov 2002 18:33:13 -0600 On 18-Nov-2002, Hein Zelle wrote: | I found a reproducable crash bug in octave 2.1.39, and although the | way to produce it is a bit vague, it may be easy to fix. | Here's a dump of my octave session: | | ----- | | [laptop] ~/files/svd/ncep-sst-z20 :-) octave | GNU Octave, version 2.1.39 (i686-pc-linux-gnu). | [snip copyright info] | | octave:1> function nelem = bla(a,res) | > # press control-C here to abort function definition | | octave:1> function nelem = bla(a,res) | panic: impossible state reached in file `parse.y' at line 1085 | panic: Aborted -- stopping myself... | attempting to save variables to `octave-core'... | save to `octave-core' complete | Abort (core dumped) Please try the following patch. It should avoid the crash but will also result in a memory leak any time you interrupt in the middle of defining a function. I don't see a good fix for that right now. Thanks, jwe 2002-11-18 John W. Eaton * parse.y (symtab_context): Now extern. * parse.h: Provide decl. * lex.l (reset_parser): Set it to 0. Index: lex.l =================================================================== RCS file: /usr/local/cvsroot/octave/src/lex.l,v retrieving revision 1.187 diff -u -r1.187 lex.l --- lex.l 6 Nov 2002 20:38:50 -0000 1.187 +++ lex.l 19 Nov 2002 00:31:44 -0000 at @ -808,6 +808,7 @@ error_state = 0; warning_state = 0; parser_end_of_input = false; + symtab_context = 0; // We do want a prompt by default. promptflag = 1; Index: parse.h =================================================================== RCS file: /usr/local/cvsroot/octave/src/parse.h,v retrieving revision 1.26 diff -u -r1.26 parse.h --- parse.h 3 Feb 2001 06:23:38 -0000 1.26 +++ parse.h 19 Nov 2002 00:31:44 -0000 at @ -74,6 +74,9 @@ // an eval() statement. extern bool evaluating_function_body; +// Keep track of symbol table information when parsing functions. +extern symbol_table *symtab_context; + // TRUE means warn about function files that have time stamps in the future. extern bool Vwarn_future_time_stamp; Index: parse.y =================================================================== RCS file: /usr/local/cvsroot/octave/src/parse.y,v retrieving revision 1.188 diff -u -r1.188 parse.y --- parse.y 12 Nov 2002 23:05:40 -0000 1.188 +++ parse.y 19 Nov 2002 00:31:45 -0000 at @ -134,7 +134,7 @@ bool evaluating_function_body = false; // Keep track of symbol table information when parsing functions. -static symbol_table *symtab_context = 0; +symbol_table *symtab_context = 0; // Forward declarations for some functions defined at the bottom of // the file. ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------