|
|
Title: Re: [fltk.coredev] Double free of groups
On 3/15/23 01:29 Rob McDonald wrote:
a09b0e2357f2 Remove reversal of children in Fl_Group::clear()
(Albrecht Schlosser)
Causes my program to attempt to double-free a widget on
shutdown.
Sigh. I was afraid that this could happen but did it anyway (to
improve speed) in the hope it wouldn't. It's difficult...
My program subclasses Fl_Group. My specialized version only
implements a constructor and a "int handle(int event)" method.
(I do not implement a destructor or clear() method).
Given your stack trace below, which one is your subclass? I assume
it is Vsp_Group, is this correct?
The particular group that is crashing (they don't all seem
to) includes widgets from Cartesian, a now apparently defunct 2D
plotting library for FLTK developed by Roman Kantor.
OK, for my understanding, what do you mean with "now apparently
defunct" ? Do you say this because your application crashes (with
double free) or for any other reason?
The first entity that tries to double-free is a Ca_Y_Axis,
which comes from Ca_Axis, which is derived from a Fl_Box.
The stack trace looks something like this...
- 0x103acdf20 Ca_Y_Axis::~Ca_Y_Axis
- 0x103c8b8d0 Fl_Group::clear
- 0x103c8ba84 Fl_Group::~Fl_Group
- 0x10263efe4 Vsp_Group::~Vsp_Group
- 0x103c8b8d0 Fl_Group::clear
- 0x103c8bb4c Fl_Group::~Fl_Group
- 0x103c8b8d0 Fl_Group::clear
- 0x103c8ba84 Fl_Group::~Fl_Group
- 0x10263efe4 Vsp_Group::~Vsp_Group
Is this a bug with the new Fl_Group::clear()?
Hard to say, but without seeing your code I suspect that your
Vsp_Group *can* cause the issue. As you know, I'm
responsible for the change that appears to cause it, and I have some
ideas how this can happen. But to explain it I need more details, so
...
Is your code public, can I see it somewhere? Although it's maybe not
a good idea to investigate in someone else's full code, I have some
ideas what to look for, hence I could maybe try to do it. I would
also be interested in testing the code so I could analyze it better.
However, there shouldn't be too many dependencies.
That said, I wonder why I see 'Vsp_Group::~Vsp_Group' twice in the
stack trace. Just to be sure, do you have nested Vsp_Group's, or is
this maybe a recursion? Nested groups would be OK, a recursion
probably not.
How do you use the Cartesian widget(s) in your Vsp_Group? Are they
somehow embedded as subwidgets (like the scrollbars in Fl_Scroll
[2]), or are are they allocated with 'new'? This might make a
difference. [1]
if not, does anyone have suggestions for fixing it?
Not yet, please answer my questions above and/or show at least some
code or point me to the full code somewhere.
Do you expect it to be a problem with my subclass of
Fl_Group, or a problem with Cartesian?
I have an old version of Fl_Cartesian (Fl_Cartesian_0.9.2.tgz)
which says in its header and implementation:
==> Fl_Cartesian.H <==
// Cartesian.H,v 1.0
//
// Copyright 2000-2005 by Roman Kantor.
==> Fl_Cartesian.cxx <==
// Cartesian.cpp,v 1.0
//
// Copyright 2000-2005 by Roman Kantor.
Which version are you using, and if it's different (maybe newer), do
you have a current URL for downloading it? I didn't find a newer
version.
In my version of Fl_Cartesian I didn't find anything that would
explain the issue, but OTOH I couldn't study every instruction. I
would need something I can test.
thanks for any ideas.
I have some ideas, but again, without seeing more code, this would
be just guessing.
However, I'm really interested in this "test case" because I need to
understand what's happening, if it is the mentioned commit that
changes the behavior. Thanks in advance for any insights
(particularly code).
PS:
[1] As you can maybe conclude from my statement above: if you are *embedding*
the Cartesian widget in your Vsp_Group, could you test allocating it
with operator `new` instead and report if this really makes a
difference? This is just a guess...
[2]
https://github.com/fltk/fltk/blob/0f41797b7ab0ee010e31659f60cafd38affac8f5/FL/Fl_Scroll.H#L157
--
You received this message because you are subscribed to the Google Groups "fltk.coredev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkcoredev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkcoredev/3bbd953a-5eb6-ed7c-936d-15ad986e90b4%40online.de.
[ Direct Link to Message ] | |
|
| |