Menu

#661 COMMON with named structure results in segfault

v1.0 (example)
closed-fixed
nobody
None
5
2018-04-12
2015-06-22
No

GDL version 0.9.5 (debian version, rebuilt with debugging symbols)

While testing the "coyote" library with an example found on their web page, I found that creating postscript files fails. I could trace that down to the following minimal example which causes a segfault on gdl exit.

PRO cgPS_SETUP__DEFINE
    struct = { CGPS_SETUP }
END

PRO test_coyote
  COMMON _$FSC_PS_START_, ps_struct
  ps_struct = {cgPS_SETUP}
END

Stack trace is:

(gdb) where
#0  Data_<SpDString>::Destruct (this=0x1146380)
    at /home/oles/Projects/2011/debian/gdl/gdl-0.9.5/src/datatypes.cpp:2032
#1  0x00000000009483b4 in DestructTag (t=0, this=0x1181040)
    at /home/oles/Projects/2011/debian/gdl/gdl-0.9.5/src/dstructgdl.hpp:326
#2  DStructGDL::~DStructGDL (this=0x1181040, __in_chrg=<optimized out>)
    at /home/oles/Projects/2011/debian/gdl/gdl-0.9.5/src/dstructgdl.cpp:92
#3  0x000000000094af29 in DStructGDL::~DStructGDL (this=0x1181040, 
    __in_chrg=<optimized out>)
    at /home/oles/Projects/2011/debian/gdl/gdl-0.9.5/src/dstructgdl.cpp:103
#4  0x0000000000951972 in DVar::~DVar (this=0x131a020, 
    __in_chrg=<optimized out>)
    at /home/oles/Projects/2011/debian/gdl/gdl-0.9.5/src/dvar.cpp:40
#5  0x0000000000924610 in PurgeContainer<std::vector<DVar*> > (
    s=std::vector of length 1, capacity 1 = {...})
    at /home/oles/Projects/2011/debian/gdl/gdl-0.9.5/src/objects.hpp:80
#6  DCommon::~DCommon (this=this@entry=0x1315150, __in_chrg=<optimized out>)
    at /home/oles/Projects/2011/debian/gdl/gdl-0.9.5/src/dcommon.cpp:38
#7  0x00000000009246d9 in DCommon::~DCommon (this=0x1315150, 
    __in_chrg=<optimized out>)
    at /home/oles/Projects/2011/debian/gdl/gdl-0.9.5/src/dcommon.cpp:39
#8  0x0000000000b10b26 in PurgeContainer<std::vector<DCommon*> > (
    s=std::vector of length 1, capacity 1 = {...})
    at /home/oles/Projects/2011/debian/gdl/gdl-0.9.5/src/objects.hpp:80
#9  ResetObjects ()
    at /home/oles/Projects/2011/debian/gdl/gdl-0.9.5/src/objects.cpp:101
#10 0x0000000000bc4634 in AtExit ()
    at /home/oles/Projects/2011/debian/gdl/gdl-0.9.5/src/gdl.cpp:109
#11 0x00007ffff209ad32 in __run_exit_handlers (status=0, 
    listp=0x7ffff2425698 <__exit_funcs>, 
    run_list_atexit=run_list_atexit@entry=true) at exit.c:82
#12 0x00007ffff209ad85 in __GI_exit (status=<optimized out>) at exit.c:104
#13 0x00007ffff2081a47 in __libc_start_main (
    main=0x503700 <main(int, char**)>, argc=3, argv=0x7fffffffe318, 
    init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, 
    stack_end=0x7fffffffe308) at libc-start.c:323
#14 0x0000000000505279 in _start ()

Discussion

  • Ole Streicher

    Ole Streicher - 2015-06-22

    Correction: the definition is:

    PRO cgPS_SETUP__DEFINE
      struct = { CGPS_SETUP,  z: !Z }
    END
    
     
  • GregJung

    GregJung - 2015-06-25

    This failure is reproduced in my own gdl build, but it isn't evident until the program exits. Also can be a simple common definition
    using a structure, from the $MAIN level:

      GDL - GNU Data Language, Version 0.9.5+ 2015.06.04 cvs+{gvj}delvar,file
    
    - For basic information type HELP,/INFO
    - Please report bugs, feature or help requests and patches at:
      http://sourceforge.net/projects/gnudatalanguage/
    
    GDL> common aaa,zzz
    GDL> zzz=!z
    GDL> help
    % At $MAIN$
    GDLLIB          STRING    = 'D:/programs/gnudatalanguage/lib'
    O               ULONG     =         1561
    TSTLIB          LONG      =           31
    ZZZ (AAA)       STRUCT    = -> !AXIS Array[1]
    Compiled Procedures:
    $MAIN$
    
    Compiled Functions:
    
    GDL> exit
    < abnormal exit message>
    
     

    Last edit: GregJung 2015-06-25
  • Alain C.

    Alain C. - 2015-09-14

    The problem was present before 2015-08-17

    I cannot reproduce this problem in CVS version since 2015-08-19

    Unfortunately, large change in CVS between Aug. 17 and 19

    I would very welcome a way to add a similar test in testsuite ...
    before closing this bug (regression possible ...)

    Alain

     
  • giloo

    giloo - 2015-09-14

    yes, the crash is avoided by this patch.
    Leave the ticket open as PurgeContainer() is unsafe for structures defined also as part of a common.

     
  • Sylwester Arabas

    Gilles, could you please elaborate on the PurgeContainer() problem in a new github issue? Thanks

     
  • giloo

    giloo - 2018-04-12
    • status: open --> closed-fixed
     
  • giloo

    giloo - 2018-04-12

    closed, was solved a long time ago (now), probably at the expense of gdl not cleaning all its memory before exiting. But who does^))?

     

Log in to post a comment.