Re: [osg-users] [vpb] a bug in vpb

2009-06-10 Thread Robert Osfield
Hi Chen,

The changes to the code you've made change what it does and starts
mixing iterators from two different containers (that aren't event the
same type), so you've almost certainly broken the code.

It's a while since I wrote this particular code so exactly what it
does and how it's used escapes me right now - I'll need to do a wider
code review to uncover this.  I really don't know whether there is a
bug here or not, lowering the amount of memory your system has
available will eventually introduce memory errors at some point - but
that would happen for almost all apps, a memory itself doesn't not
indicate a bug in the code that end up crashing at.

Could you please post a stack trace so we can analyse the issue
further, as well as info on exactly which VPB apps you are using, OS,
how much memory you set, etc.

Robert.

On Wed, Jun 10, 2009 at 4:20 AM, wind509459...@qq.com wrote:
 Hi,
  Robert, when i set my machine's virtual memory to a lower value for some
 test related to vpb, thousands of image files as input, then vpb jumps into
 this error:
 //system.cpp, Line 305,
     void eraseFrom(System::DatasetMap datasetMap)
     {
     for(TimeIteratorMap::iterator itr = _timeIteratorMap.begin();
     itr != _timeIteratorMap.end();
     ++itr)
     {
     datasetMap.erase(itr-second);
     }
     }
    Evidently, the iterator was used incorrectly. So i changed it:
      void eraseFrom(System::DatasetMap datasetMap)
     {
     for(TimeIteratorMap::iterator itr = _timeIteratorMap.begin();
     itr != _timeIteratorMap.end();)
     {
     itr = datasetMap.erase(itr-second);
     }
     }
   Then it works. My version is r973. Hope to correct it in later version.

   Xuex, Chen


 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] [vpb] a bug in vpb

2009-06-10 Thread philipjt
Hi Chen,

I think the problem is also not using the iterator in the style that the 
iterator algorithm was originally intended. I have used your style as it hides 
the iterator declation when the for loop goes out of scope, but I think the 
expected usage was more along the lines of:

{
  iterator iter = map.begin();
  while( iter != map.end() )
iter = map.erase( ... );
}

PhilT


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] [vpb] a bug in vpb

2009-06-10 Thread Wang Rui
Hi,

It seems that the return value of erase() are different in Windows and
Unix/Linux. I've done some work in my previous projects like:

for ( DataMap::iterator itr=map.begin(); itr!=map.end(); )
{
DataMap::iterator old_itr = itr;
itr++;
map.erase( old_itr );
}

That's because itr = map.erase(itr) is not compilable with some gcc
versions.

My shame for not studying into the vpb source code yet. :)

Wang Rui
2009/6/10 phili...@ntlworld.com

 Hi Chen,

 I think the problem is also not using the iterator in the style that the
 iterator algorithm was originally intended. I have used your style as it
 hides the iterator declation when the for loop goes out of scope, but I
 think the expected usage was more along the lines of:

{
  iterator iter = map.begin();
  while( iter != map.end() )
iter = map.erase( ... );
}

 PhilT


 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] [vpb] a bug in vpb

2009-06-10 Thread Ulrich Hertlein

On 10.06.2009 15:45 Uhr, Wang Rui wrote:

It seems that the return value of erase() are different in Windows and
Unix/Linux. I've done some work in my previous projects like:

for ( DataMap::iterator itr=map.begin(); itr!=map.end(); )
{
 DataMap::iterator old_itr = itr;
 itr++;
 map.erase( old_itr );
}
That's because itr = map.erase(itr) is not compilable with some gcc
versions.


I don't believe this is the problem.  The 'it = container.erase(it)' construct 
is correct.

However, in this case (from VPB):

for(TimeIteratorMap::iterator itr = _timeIteratorMap.begin();
itr != _timeIteratorMap.end();
++itr)
{
datasetMap.erase(itr-second);
}

the iterator 'itr' is for TimeIteratorMap whereas the erase is on 'datasetMap' 
and
'datasetMap.erase(...)' would logically return a DatasetMap::iterator which (thankfully) 
cannot be assigned to a TimeIteratorMap::iterator, not even under Windows.


Cheers,
/ulrich


2009/6/10 phili...@ntlworld.com mailto:phili...@ntlworld.com
I think the problem is also not using the iterator in the style that
the iterator algorithm was originally intended. I have used your
style as it hides the iterator declation when the for loop goes out
of scope, but I think the expected usage was more along the lines of:

{
  iterator iter = map.begin();
  while( iter != map.end() )
iter = map.erase( ... );
}

PhilT

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] [vpb] a bug in vpb

2009-06-10 Thread Jean-Sébastien Guay

Hi Ulrich,

You're right that what you (and Robert) note is an error (i.e. assigning 
an iterator from one container to an iterator from another container).


But...

I don't believe this is the problem.  The 'it = container.erase(it)' 
construct is correct.


It seems that according to the standard, it is, but some (many?) 
versions of gcc don't support it (perhaps it was added late in the 
standardization process or whatever). I've run across the same problem 
as Wang Rui - map::erase(iterator) returns void on some common 
compilers. So it's not portable code (by gcc's fault but still...).


J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.webhop.org/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] [vpb] a bug in vpb

2009-06-10 Thread Paul Melis

Jean-Sébastien Guay wrote:

Hi Ulrich,

You're right that what you (and Robert) note is an error (i.e. 
assigning an iterator from one container to an iterator from another 
container).


But...

I don't believe this is the problem.  The 'it = container.erase(it)' 
construct is correct.


It seems that according to the standard, it is, but some (many?) 
versions of gcc don't support it (perhaps it was added late in the 
standardization process or whatever). I've run across the same problem 
as Wang Rui - map::erase(iterator) returns void on some common 
compilers. So it's not portable code (by gcc's fault but still...).
According to the spec I have here (ISO C++ 1998 draft) 
std::map::erase(it) should return void (and same for std::set). Only for 
sequential containers (vector, list, deque) is an iterator returned in 
case of erase()ing. Makes sense too, as associative containers are 
usually not implemented as a simple list of elements, so returning the 
next item after the one just erased could be tricky.


Regards,
Paul

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] [vpb] a bug in vpb

2009-06-10 Thread Ulrich Hertlein

Hi J-S,

On 10.06.2009 16:23 Uhr, Jean-Sébastien Guay wrote:

But...


I don't believe this is the problem. The 'it = container.erase(it)' construct is
correct.


It seems that according to the standard, it is, but some (many?) versions of 
gcc don't
support it (perhaps it was added late in the standardization process or 
whatever). I've
run across the same problem as Wang Rui - map::erase(iterator) returns void on 
some
common compilers. So it's not portable code (by gcc's fault but still...).


It seems that std::map::erase doesn't actually return an iterator at all, at 
least
according to http://www.cplusplus.com/reference/stl/map/erase/

I'm not across any of that code but in my experience it can be dangerous to hold on to 
iterators for a length of time since they may become invalid with insert/erase.  This 
shouldn't be the case for maps though...


/ulrich
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] [vpb] a bug in vpb

2009-06-10 Thread Paul Melis

Paul Melis wrote:

Jean-Sébastien Guay wrote:

Hi Ulrich,

You're right that what you (and Robert) note is an error (i.e. 
assigning an iterator from one container to an iterator from another 
container).


But...

I don't believe this is the problem.  The 'it = container.erase(it)' 
construct is correct.


It seems that according to the standard, it is, but some (many?) 
versions of gcc don't support it (perhaps it was added late in the 
standardization process or whatever). I've run across the same 
problem as Wang Rui - map::erase(iterator) returns void on some 
common compilers. So it's not portable code (by gcc's fault but 
still...).
According to the spec I have here (ISO C++ 1998 draft) 
std::map::erase(it) should return void (and same for std::set). Only 
for sequential containers (vector, list, deque) is an iterator 
returned in case of erase()ing. Makes sense too, as associative 
containers are usually not implemented as a simple list of elements, 
so returning the next item after the one just erased could be tricky.
Interestingly, the c0x draft I could find indeed lists 
std::map::erase(it) (and for set as well) as returning an interator.


Paul


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] [vpb] a bug in vpb

2009-06-10 Thread Jean-Sébastien Guay

Hi Paul,

According to the spec I have here (ISO C++ 1998 draft) 
std::map::erase(it) should return void (and same for std::set).


The version I have is dated October 2008. Here's a link:

http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2008/n2798.pdf

From here:

http://www.open-std.org/JTC1/SC22/WG21/

See page 838:

  iterator  erase(const_iterator position);
  size_type erase(const key_type x);
  iterator  erase(const_iterator first, const_iterator last);

So yeah, it was probably added later.

Anyways, the result is that some (all? I'm not sure) versions of gcc 
don't support the version that return an iterator, and return void 
instead. VC++ does. Does this mark the first time VC++ is more 
up-to-date than gcc with regards to standards? :-)


J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.webhop.org/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] [vpb] a bug in vpb

2009-06-10 Thread Paul Melis

Hey,

Jean-Sébastien Guay wrote:


According to the spec I have here (ISO C++ 1998 draft) 
std::map::erase(it) should return void (and same for std::set).


The version I have is dated October 2008. Here's a link:

http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2008/n2798.pdf

From here:

http://www.open-std.org/JTC1/SC22/WG21/

See page 838:

  iterator  erase(const_iterator position);
  size_type erase(const key_type x);
  iterator  erase(const_iterator first, const_iterator last);

So yeah, it was probably added later.
The inconsistency in void - iterator return type seems to have been 
marked as defect (DR 130) shortly after the previous C++ spec was 
published in 1998. DR 130 is dated March 1990: 
http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#130


The DR proposes to change erase() from returning void to returning an 
iterator.


Anyways, the result is that some (all? I'm not sure) versions of gcc 
don't support the version that return an iterator, and return void 
instead. VC++ does. Does this mark the first time VC++ is more 
up-to-date than gcc with regards to standards? :-)
From what I can find about this is that Dinkumware STL (which is what 
VS is using) has chosen to return iterators for erase(). I guess you 
could say that any conforming code using erase() must ignore the return 
value, as it is prescribed to be void. An STL implementation that 
differs in return type will also work with conforming code, as the 
result value is ignored anyway. So perhaps it is code using Dinkumware 
STL (VS) that expects an iterator as result value that is non-conforming...


Paul



___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] [vpb] a bug in vpb

2009-06-09 Thread wind
Hi,
  Robert, when i set my machine's virtual memory to a lower value for some test 
related to vpb, thousands of image files as input, then vpb jumps into this 
error:
 //system.cpp, Line 305,
 void eraseFrom(System::DatasetMap datasetMap)
{
for(TimeIteratorMap::iterator itr = _timeIteratorMap.begin();
itr != _timeIteratorMap.end();
++itr)
{
datasetMap.erase(itr-second);
}
}
Evidently, the iterator was used incorrectly. So i changed it:
  void eraseFrom(System::DatasetMap datasetMap)
{
for(TimeIteratorMap::iterator itr = _timeIteratorMap.begin();
itr != _timeIteratorMap.end();)
{
itr = datasetMap.erase(itr-second);
}
}
   Then it works. My version is r973. Hope to correct it in later version. 
   
   Xuex, Chen___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org