COMMON with named structure results in segfault
Status: Beta
Brought to you by:
m_schellens
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 ()
Correction: the definition is:
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:
Last edit: GregJung 2015-06-25
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
in fact, seems to be related to : http://gnudatalanguage.cvs.sourceforge.net/viewvc/gnudatalanguage/gdl/src/objects.cpp?r1=1.68&r2=1.69&sortby=date
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.
Gilles, could you please elaborate on the PurgeContainer() problem in a new github issue? Thanks
closed, was solved a long time ago (now), probably at the expense of gdl not cleaning all its memory before exiting. But who does^))?