bugGNU Octave - Bugs: bug #31861, crash with empty function line

 
 

bug #31861: crash with empty function line

Submitter:  Muhali <muhali>
Submitted:  Mon 13 Dec 2010 04:15:51 PM UTC
   
 
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Segfault, Bus Error, etc.
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Fri 17 Dec 2010 05:55:49 PM UTC, comment #19: 

"I need, for example, an array of size 51500x96x192."

That is a total of approximately 1.768*10^29 elements, so you can easily create an array of that size without needing 64-bit indexing.

However, if it is a double precision array it will take up 7GB of memory, so depending on what you plan to do with it, you might be quite limited unless it is a sparse array or you have a lot of memory (say, 24-32GB or more).

John W. Eaton <jwe>
Group administrator
Wed 15 Dec 2010 06:00:44 AM UTC, comment #18: 

It doesn't really matter whether the function body is empty or not.  The real bug is that we can't be calling functions while we are parsing another one, and that happens when there is a function to be called via the input_event_hook mechanism and we are defining a function at the command line (thus, the input_event_hook functions are called while Octave is waiting for input).

The reason this is related to the fltk graphics backend is that the function that processes events for fltk is registered to be called via the input_event_hook mechanism.

When a function is called this way, it changes the value of symbol_table::current_scope and then when we finish parsing the function it has an unexpected value.  It might be possible to fix this problem by pushing a new scope on the call_stack for the new function we are parsing, but this has some other problems.  For example, the parent scope would not be correct, but maybe we could work around that problem by marking the function-parsing scope as "fake" in some way so it would be skipped when looking for parent scopes but still used when pushing/popping scopes to evaluate functions.

In any case, rather than try to fix that possibly difficult problem, I checked in the following change:

http://hg.savannah.gnu.org/hgweb/octave/rev/b2191ebea12f

This simply prevents input_event_hook functions from being called while we are parsing a function on the command line.  If that causes trouble and we actually do need to call input_event_hook functions while parsing command-line functions, then maybe I will attempt the other fix outlined above instead.

But for now, I consider this bug closed since the patch I checked in should at least avoid the crash.

John W. Eaton <jwe>
Group administrator
Wed 15 Dec 2010 03:52:36 AM UTC, comment #17: 

I can reproduce the crash with octave installed in /usr/local/ after using "backend fltk".


octave:1> backend fltk
octave:2> function y = foo(x)
>
> endfunction
octave: ../../octave/src/symtab.h:1850: static void symbol_table::set_curr_fcn(octave_user_function*, int): Assertion `scope != xtop_scope && scope != xglobal_scope' failed.

Program received signal SIGABRT, Aborted.
0x00007fffeff60a75 in raise () from /lib/libc.so.6
(gdb) bt
#0  0x00007fffeff60a75 in raise () from /lib/libc.so.6
#1  0x00007fffeff645c0 in abort () from /lib/libc.so.6
#2  0x00007fffeff59941 in __assert_fail () from /lib/libc.so.6
#3  0x00007ffff74c3b5e in symbol_table::set_curr_fcn (curr_fcn=0x6abfb0, scope=1) at ../../octave/src/symtab.h:1850
#4  0x00007ffff74c00d1 in octave_user_function (this=0x6abfb0, sid=1, pl=0xb33930, rl=0x0, cl=0xaaa770) at ../../octave/src/ov-usr-fcn.cc:193
#5  0x00007ffff731351b in start_function (param_list=0xb33930, body=0xaaa770, end_fcn_stmt=0xc63970) at oct-parse.yy:2814
#6  0x00007ffff730f6b3 in octave_parse () at oct-parse.yy:1410
#7  0x00007ffff73cd9d3 in main_loop () at ../../octave/src/toplev.cc:568
#8  0x00007ffff73883fb in octave_main (argc=1, argv=0x7fffffffe2b8, embedded=0) at ../../octave/src/octave.cc:896
#9  0x0000000000400889 in main (argc=1, argv=0x7fffffffe2b8) at ../../octave/src/main.c:35
(gdb)


Judd Storrs <judd>
Wed 15 Dec 2010 02:03:42 AM UTC, comment #16: 

I have found a reproducible way, for me, to provoke the segfault.


sh> ./run-octave -f    # Run without invoking any rc files
octave:1> backend fltk
octave:2> function y = foo(x)
>
> endfunction
/m: symtab.h:1850: static void symbol_table::set_curr_fcn(octave_user_function*, int): Assertion `scope != xtop_scope && scope != xglobal_scope' failed.
panic: Aborted -- stopping myself...


There is no segfault if I use 'backend gnuplot' so perhaps some of the successes are from people who use gnuplot by default for graphics.

Rik <rik5>
Group administrator
Tue 14 Dec 2010 10:10:52 PM UTC, comment #15: 

I have read the INSTALL.OCTAVE instructions.

I need, for example, an array of size 51500x96x192.

Muhali <muhali>
Tue 14 Dec 2010 09:23:44 PM UTC, comment #14: 

If you want to build with --enable-64, I recommend that you read and follow the directions given in the INSTALL.OCTAVE file.  This file is generated from doc/interpreter/install.txi when you build Octave.

Precisely what do you mean by "very large datasets"?  Precisely what dimensions do you need to be able to handle?

John W. Eaton <jwe>
Group administrator
Tue 14 Dec 2010 09:15:07 PM UTC, comment #13: 

You are probably right that many of the configure switches don't make sense, but with them I somehow managed to get the 64-bit version plus the sparse matrix libraries working (yes, I do need 64-bit to be able to read very large datasets, and I do have custom-built numerical libraries).

Regarding the cholmod options, without them I get this from the configure script:

configure:46393: gcc -o conftest -g -O2 -pthread  -I/usr/local/include  -L/usr/local/lib conftest.c -lcholmod  -lcolamd  -lamd -llapack -L/usr/local/lib -lblas64  -L/usr/local/lib -L/usr/lib/gcc/x86_64-linux-gnu/4.4.2 -L/usr/lib/gcc/x86_64-linux-gnu/4.4.2/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.4.2/../../.. -lgfortranbegin -lgfortran -lm -lm   >&5

/usr/local/lib/libcholmod.so: undefined reference to `METIS_NodeComputeSeparator'
/usr/local/lib/libcholmod.so: undefined reference to `METIS_NodeND'
/usr/local/lib/libcholmod.so: undefined reference to `camd_free'
/usr/local/lib/libcholmod.so: undefined reference to `camd_printf'
/usr/local/lib/libcholmod.so: undefined reference to `csymamd_l'
/usr/local/lib/libcholmod.so: undefined reference to `camd_calloc'
/usr/local/lib/libcholmod.so: undefined reference to `camd_realloc'
/usr/local/lib/libcholmod.so: undefined reference to `ccolamd_l_set_defaults'
/usr/local/lib/libcholmod.so: undefined reference to `camd_malloc'
/usr/local/lib/libcholmod.so: undefined reference to `camd_l2'
/usr/local/lib/libcholmod.so: undefined reference to `ccolamd_l_recommended'
/usr/local/lib/libcholmod.so: undefined reference to `ccolamd_l'

If this is awkward, any help is appreciated.

M.

Muhali <muhali>
Tue 14 Dec 2010 08:14:21 PM UTC, comment #12: 

It is possible, but I would be surprised if this problem is related to the --enable-64 configure option.  But in any case, I don't think you want to use that unless you are also using custom-built numerical libraries.  Please read the description of building with --enable-64 in the file INSTALL.OCTAVE for more info.

As for the other configure options that you are using, where did you get the idea that you should use -fPIC for CFLAGS and CXXFLAGS?  That disables compiler optimization and the configure script (really libtool) is supposed to determine whether options like -fPIC are needed.  Similarly, you should not need to specify -lblas.  That is one of the libraries that should be checked by default.  Adding -fdefault-integer-8 to the --with-blas option makes no sense as far as I can tell.  Using "--with-cholmod=-lcholmod -lcamd -lccolamd -lmetis" also does not make sense to me.

BTW, do you have more than 16GB of memory?  Do you regularly work with integer arrays with more than 2e9 elements?  If not, then I don't think there is any need to build with --enable-64.

John W. Eaton <jwe>
Group administrator
Tue 14 Dec 2010 07:29:42 PM UTC, comment #11: 

more variation:

now I can't reproduce it anymore, and of course I "haven't changed anything". ;-)

weird.

M.

Muhali <muhali>
Tue 14 Dec 2010 06:50:49 PM UTC, comment #10: 

Forgot to include my hg tip:


changeset:   11362:456752abad08
tag:         tip
user:        John W. Eaton <jwe@octave.org>
date:        Tue Dec 14 02:01:59 2010 -0500
summary:     ChangeLog fixes


Judd Storrs <judd>
Tue 14 Dec 2010 06:45:55 PM UTC, comment #9: 

I can't reproduce the crash. I'm on Ubuntu 10.4 x86_64 (also not using --enable-64, flex 2.3.5, bison 2.4.1, gcc 4.4.3)

Judd Storrs <judd>
Tue 14 Dec 2010 06:36:31 PM UTC, comment #8: 

For comparison, my system is also x86_64, Ubuntu (and thus Debian derived), using Flex 2.3.5, Bison 2.4.1, but gcc 4.4.1-4.  I don't use the experimental '--enable-64' option.

Rik <rik5>
Group administrator
Tue 14 Dec 2010 05:23:33 PM UTC, comment #7: 

some more information of my system and configuration:

I am on a debian system (2.6.36) using bison (GNU Bison) 2.4.1, flex 2.5.35; my octave configuration is

config_opts = '--prefix=/usr/local/octave-test' '--enable-64' '--with-blas=-lblas -fdefault-integer-8' 'CFLAGS=-fPIC' 'CXXFLAGS=-fPIC' 'LDFLAGS=-L/usr/local/lib' 'F77=gfortran' 'FFLAGS=-g' 'CPPFLAGS=-I/usr/local/include' '--with-cholmod=-lcholmod -lcamd -lccolamd -lmetis'

and I compile with this version of gcc:

$> gcc -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.4.2-3' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --with-arch-32=i486 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.4.2 (Debian 4.4.2-3)


I hope that helps.

M.

Muhali <muhali>
Tue 14 Dec 2010 07:24:20 AM UTC, comment #6: 

I've tried various things that have been suggested, and have also built a version with the default compiler flags (I normally compile with CXXFLAGS and CFLAGS set to -ggdb3, so no compiler optimization) but I still have not been able to reproduce this problem.

The config.info file that you uploaded does provide some info, but not all that I requested.

Also, precisely what configure and make commands are you using to build Octave?

John W. Eaton <jwe>
Group administrator
Mon 13 Dec 2010 08:53:55 PM UTC, comment #5: 

Well, this seems to have considerable variation:
for me (Fedora 14 x86_64) is fails both for installed
version and for ./run-octave.  I just confirmed this
with the latest build:
[qss:octave] hg tip
changeset:   11350:f6d15ae003b8
tag:         tip
user:        Kai Habel <kai.habel@gmx.de>
date:        Mon Dec 13 20:23:00 2010 +0100
files:       scripts/ChangeLog
description:
ChangeLog fix

Michael Godfrey <godfrey>
Group Member
Mon 13 Dec 2010 08:42:35 PM UTC, comment #4: 

I can confirm this on today's (12/13/10) tip (11348:2ae0ca4ee36b).  This is on a Kubuntu 9.04, x86_64 system.  A possible clue is that it does not segfault when run from the source tree with ./run-octave, but rather only when installed and run from the default location (/usr/local/bin).

Interestingly, I ran the test under octave-3.2.4 and it accepts a null function, but when I use 'exit' to leave the interpreter the program then segfaults.

Rik <rik5>
Group administrator
Mon 13 Dec 2010 05:05:56 PM UTC, comment #3: 

I am using

changeset:   11346:30f54b3b9953
tag:         tip
user:        Jaroslav Hajek <highegg@gmail.com>
date:        Sun Dec 12 21:58:30 2010 +0100
summary:     drop support of 'i' option in lookup

octave configuration attached.

M.


(file #22195)

Muhali <muhali>
Mon 13 Dec 2010 04:57:05 PM UTC, comment #2: 

This fails for me on Fedora 14 x86_64 system with

[qss:octave] hg tip
changeset:   11341:3c7ba1e3dc21
tag:         tip
user:        Kai Habel <kai.habel@gmx.de>
date:        Fri Dec 10 19:53:06 2010 +0100
files:       scripts/ChangeLog scripts/plot/pie.m scripts/plot/pie3.m scripts/plot/private/__pie__.m

Also failed on somewhat earlier system.

Michael Godfrey <godfrey>
Group Member
Mon 13 Dec 2010 04:47:08 PM UTC, comment #1: 

I'm unable to duplicate this error.  I'm using


$ hg tip
changeset:   11346:30f54b3b9953
tag:         tip
user:        Jaroslav Hajek <highegg@gmail.com>
date:        Sun Dec 12 21:58:30 2010 +0100
summary:     drop support of 'i' option in lookup


Precisely what version are you using?  How was it compiled?  What compiler are you using and what version do you have?  What version of Bison do you have?  What version of flex?

John W. Eaton <jwe>
Group administrator
Mon 13 Dec 2010 04:15:51 PM UTC, original submission:  

in the current development version octave crahsed when faced with an empty input line for a function definition.

octave:1> function y = foo(x)

>
> endfunction

octave: symtab.h:1850: static void symbol_table::set_curr_fcn(octave_user_function*, int): Assertion `scope != xtop_scope && scope != xglobal_scope' failed.
panic: Aborted -- stopping myself...
Aborted

M.

Muhali <muhali>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #22195:  config.info added by muhali (33KiB - application/x-info)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by judd (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by godfrey (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by muhali (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2010-12-15 jwe StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2010-12-13 rik5 StatusWorks For Me Confirmed
    2010-12-13 muhali Attached File- Added config.info, #22195
    2010-12-13 jwe StatusNone Works For Me

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code