Menu

#187 GDL receives SIGABRT when GSL fails (e.g. out of memory)

closed-fixed
nobody
None
7
2014-01-02
2009-10-10
No

The example below shows a way to crash GDL by triggering a default GSL error handler (the code is currently also included in test_outofmem.pro). NEWTON/BROYDEN logic in gsl_fun.cpp contains an exemplary method to translate GSL errors to GDL warnings - perhaps it can be used in other GSL-based GDL routines to fix such behaviour.

GDL> a = HISTOGRAM([0], nbins=1000L*1000L*1000L, loc=b)
gdl(25561) malloc: *** mmap(size=3705036800) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
gsl: init.c:51: ERROR: failed to allocate space for histogram ranges
Default GSL error handler invoked.

Program received signal SIGABRT, Aborted.
0x941e9e42 in __kill ()
(gdb) bt
#0 0x941e9e42 in __kill ()
#1 0x941e9e34 in kill$UNIX2003 ()
#2 0x9425c23a in raise ()
#3 0x94268679 in abort ()
#4 0x008becf7 in gsl_error ()
#5 0x008d6dc2 in gsl_histogram_alloc ()
#6 0x0039defc in lib::histogram_fun (e=0x1a32560) at gsl_fun.cpp:1159
#7 0x0025660f in GDLInterpreter::lib_function_call (this=0xbffff188, _t=0x1a32460) at GDLInterpreter.cpp:4813
#8 0x00256798 in GDLInterpreter::check_expr (this=0x0, _t=0x0) at GDLInterpreter.cpp:2139
#9 0x00498e74 in ASSIGN_REPLACENode::Run (this=0x1a332d0) at prognode.cpp:511
#10 0x0025a3f6 in GDLInterpreter::statement (this=0xbffff188, _t=0x1a332d0) at GDLInterpreter.cpp:270
#11 0x00265710 in GDLInterpreter::statement_list (this=0xbffff188, _t=0x1a332d0) at GDLInterpreter.cpp:74
#12 0x001ed4eb in DInterpreter::ExecuteLine (this=0xbffff188, in=0x0) at dinterpreter.cpp:783
#13 0x001ef25b in DInterpreter::InterpreterLoop (this=0xbffff188, startup=@0xbffff270) at dinterpreter.cpp:1184
#14 0x004a8edd in main (argc=1, argv=0xbffff2c8) at gdl.cpp:192

Discussion

  • Sylwester Arabas

    Another example:

    GDL> la_trired, 1, 1, 1
    gsl: init_source.c:29: ERROR: matrix dimension n1 must be positive integer
    Default GSL error handler invoked.
    Abort trap

     
  • Alain C.

    Alain C. - 2009-10-30

    First case is the size of array is too, so big than we may have a neg due to modulo in longint ...

    Second case (I create a new entry) is very simple: bad case check at GDL level

    Alain

     
  • Sylwester Arabas

    Yet another example when this happens:

    GDL> print,interpolate([1,3],[-1,0,1,2],/cubic)
    gsl: interp.c:38: ERROR: insufficient number of points for interpolation type
    Default GSL error handler invoked.
    Abort trap

     
  • Sylwester Arabas

    • priority: 5 --> 7
     
  • Marc Schellens

    Marc Schellens - 2012-07-23

    A proper error handler for GSL is now set at GDL startup. All routines using GSL functions were made exception save. New routines using GSL should be programmed this way.

     
  • Marc Schellens

    Marc Schellens - 2012-07-23
    • status: open --> closed-fixed
     
  • Sylwester Arabas

    Thanks Marc.
    Sylwester

     

Log in to post a comment.