[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #44406] glps_renderer::draw uses static state
From: |
Dan Sebald |
Subject: |
[Octave-bug-tracker] [bug #44406] glps_renderer::draw uses static state variable, potential bug? |
Date: |
Mon, 02 Mar 2015 07:07:47 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:18.0) Gecko/20100101 Firefox/18.0 SeaMonkey/2.15 |
URL:
<http://savannah.gnu.org/bugs/?44406>
Summary: glps_renderer::draw uses static state variable,
potential bug?
Project: GNU Octave
Submitted by: sebald
Submitted on: Mon 02 Mar 2015 07:07:45 AM GMT
Category: Plotting with OpenGL
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Other
Status: None
Assigned to: None
Originator Name:
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release: dev
Operating System: Any
_______________________________________________________
Details:
In searching for a bug, I've looked through gl2ps-renderer.cc. I notice
something here about the routine glps_renderer(). I'm going to raise it
because if this code is interruptable, there is potential for a rare obscure
bug that would be very hard to duplicate and find if some user were to report
it.
There is this construct:
glps_renderer::draw (const graphics_object& go, const std::string print_cmd)
{
static bool in_draw = false;
if (!in_draw)
{
in_draw = true;
...
in_draw = 0;
ret
}
If this code can be interrupted, there is the rare event possibility that the
user hits Cntrl-C at a time that corresponds to the in_draw variable value
being 1. If so, from that point forward this draw routine will not behave
correctly if the user follows up with some related command. Very rare, I
know, but rare bugs are the worst kind.
So, if that is an issue, how to fix? Well, there should be some way of
reseting that static variable, or more likely make it a private class variable
and reset it to zero every time it is first used. Keep the recursive portion
separate from the.
public
draw();
private
draw_recurse();
int in_draw_rec;
::draw() {
in_draw_rec = 0;
draw_recurse();
}
::draw_recurse() {
in_draw_rec = 1;
draw_recurse(go);
}
one could do the same sort of thing with an input value:
::draw() {
draw_recurse(go, 0);
}
::draw_recurse(xyz, state) {
draw_recurse(go, state+1);
}
I may not have that right, but I'm not quite sure how it is intended to work
because of the virtual functions and all. There might be a better way of
doing this as well. I haven't thought too much about it.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?44406>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #44406] glps_renderer::draw uses static state variable, potential bug?,
Dan Sebald <=
- [Octave-bug-tracker] [bug #44406] glps_renderer::draw uses static state variable, potential bug?, Dan Sebald, 2015/03/02
- [Octave-bug-tracker] [bug #44406] glps_renderer::draw uses static state variable, potential bug?, John W. Eaton, 2015/03/02
- [Octave-bug-tracker] [bug #44406] glps_renderer::draw uses static state variable, potential bug?, Dan Sebald, 2015/03/02
- [Octave-bug-tracker] [bug #44406] glps_renderer::draw uses static state variable, potential bug?, John W. Eaton, 2015/03/02
- [Octave-bug-tracker] [bug #44406] glps_renderer::draw uses static state variable, potential bug?, John W. Eaton, 2015/03/02
- [Octave-bug-tracker] [bug #44406] glps_renderer::draw uses static state variable, potential bug?, Dan Sebald, 2015/03/03
- [Octave-bug-tracker] [bug #44406] glps_renderer::draw uses static state variable, potential bug?, Dan Sebald, 2015/03/03