472,780 Members | 1,397 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,780 software developers and data experts.

[RW] Rogue Wave standard library -- unbelievable bug

The following code causes a deallocation of a random amount of
bytes, with the Rogue Wave STL supplied with Borland C++ 5.5.1 :

#include <vector>

int main()
{
std::vector<char> v, w(1);
v = w;
}

There is a bug in the vector::operator= code that uses the wrong
value when determining how much memory to deallocate when
deallocating the old contents of v.

I'm amazed that a company which provides STL implementations to
professional compiler vendors, can let this slip through their
QA system. I couldn't find any mention of it in their Knowledge
Base either (although it has a very hard to use search system),
and you can't enter the RW STL patches area of their website
without a login ID. There's no mention of it on Borland's site
either.

Does anyone know if later versions fixed this (eg. BCC 5.6.4),
or if there are any freely-available patches? Are there any
more howlers like this one that I haven't come across yet?

Jul 23 '05 #1
5 2486
There might be. I don't know if Borland still maintains this old
library.

What is the date on the Rogue Wave copyright notice at the top of the
file? I suspect it must be at least 5 years old and, AFAIK, Borland
hasn't taken any of our updates in about that long (which doesn't mean
that the library has never been updated, just not with our code). Your
program does the right thing with our latest library as well as with
several older versions (I tried 2.0.3 from 1998 that comes with Compaq
C++, 2.1.1 with SunProm and 2.2.1 with HP aCC), so it seems that it's
time to upgrade.

Jul 23 '05 #2
se***@roguewave.com wrote:

What is the date on the Rogue Wave copyright notice at the top of
the file? I suspect it must be at least 5 years old and, AFAIK,
Borland hasn't taken any of our updates in about that long
(which doesn't mean that the library has never been updated,
just not with our code).
(c) 1994-1999 Rogue Wave Software Inc.
I couldn't find a specific version number anywhere.
program does the right thing with our latest library as well as
with several older versions (I tried 2.0.3 from 1998 that comes
with Compaq C++, 2.1.1 with SunProm and 2.2.1 with HP aCC), so
it seems that it's time to upgrade.


Is it possible for me to upgrade the standard library without
upgrading the compiler? (free of charge?) There's only 1 later
version of Borland, and they have since dropped C++Builder, so
it's not a great economic decision to get it.

The actual code snippet in question was, from vector.cc:

if (x.size() > capacity())
{
__value_alloc_type va(__end_of_storage);
iterator tmp = va.allocate(x.end() - x.begin(),0);
#ifndef _RWSTD_NO_EXCEPTIONS
try {
__end_of_storage = uninitialized_copy(x.begin(), x.end(), tmp);
} catch(...) {
va.deallocate(tmp,x.end()-x.begin());
throw;
}
#else
__end_of_storage = uninitialized_copy(x.begin(), x.end(), tmp);
#endif // _RWSTD_NO_EXCEPTIONS
__destroy(__start, __finish);
va.deallocate(__start,__end_of_storage.data()-__start);
__start = tmp;
}

As you can see, the va.deallocate() at the end is calculating
the amount with the NEW version of __end_of_storage but the
old version of __start. I fixed it by remembering the length
to deallocate, before __end_of_storage gets reassigned.

Jul 23 '05 #3
I'm not familiar with the Borland support policy, you'd need to talk to
them. We don't have the Borland compiler on our current support matrix
so if you got the code from us you'd have to do some porting (and it
probably wouldn't be free, although I'd encourage you to call our sales
and ask :)

The version macro, _RWSTD_VER, should be #defined by #including any
library header. I'm not sure if that convention was in place in '99,
though.

The code and the problem you're describing sounds familiar but I'm
afraid I'm too busy right now to hunt down the change that fixed it.
Below is the definition of the assignment operator from our latest
released branch.

Hope it helps.

vector<_TypeT, _Allocator>&
vector<_TypeT, _Allocator>::
operator= (const vector &__rhs)
{
if (capacity () < __rhs.size ())
vector (__rhs).swap (*this);
else if (&__rhs != this)
assign (__rhs.begin (), __rhs.end ());

return *this;
}

Jul 23 '05 #4
se***@roguewave.com wrote:
I'm not familiar with the Borland support policy, you'd need to
talk to them. We don't have the Borland compiler on our current
support matrix so if you got the code from us you'd have to do
some porting (and it probably wouldn't be free, although I'd
encourage you to call our sales and ask :)

The version macro, _RWSTD_VER, should be #defined by #including
any library header. I'm not sure if that convention was in place
in '99, though.
Oh yes -- it is 0x020101. Thanks for your answers anyway.
I'm doing my best to convince the upper echelons to switch
to a new compiler.. you know how it goes :)
Below is the definition of the assignment operator from our latest
released branch.

vector<_TypeT, _Allocator>&
vector<_TypeT, _Allocator>::
operator= (const vector &__rhs)
{
if (capacity () < __rhs.size ())
vector (__rhs).swap (*this);
else if (&__rhs != this)
assign (__rhs.begin (), __rhs.end ());

return *this;
}


Looks like there have been many improvements since 1999 :)

Jul 23 '05 #5
Old Wolf wrote:
There's only 1 later
version of Borland, and they have since dropped C++Builder, so
it's not a great economic decision to get it.


Well, there's "dropped" and there's "dropped." They've dropped it as a
standalone product. C++ support will be integrated into the next release
of Delphi (if I understand correctly), and includes our library.

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: david.kettle | last post by:
Hello Python World! I've been playing with the 'wave' and 'audioop' modules in the library, and I have a question. When I tried to read a "wav" file with samples in 32-bit float, I got the...
1
by: Jakub Dudek | last post by:
Hi, I am trying to read wave date (the 16 bits audio words) from a wave file using c++. I have tried using the mmsystems library. I got to the point where I read the wave data chunk into a...
1
by: Thomas Lenarz | last post by:
Hello, we have got C++-programs (older SUN-Compiler) using the Rogue-Wave-Class-Library and consider to port the application to AIX 5.2 (GNU gcc/g++) The only drawback we could find ist the...
4
by: vikram | last post by:
in a stereo type of wave file i want to know what is this left & right info in a wave file??? how do i read the left & right info from a .wav file to a buffer..
0
by: sebor | last post by:
Hi all, The latest release of the Rogue Wave C++ Standard Library, version 4.1.0, has just been released into public domain under the Apache License, version 2.0, as the Apache stdcxx project:...
12
by: theoderich | last post by:
Following is possible with gcc and g++: #include <math.h> double sin(double) { return 1; } int main()
9
by: nkprajapati | last post by:
Hi All, I am using off the shelf Rouge Wave library. But now I want to move to Open Source. Anybody aware of Open Source port of Rouge Wave Library ? These are some heavily used Rouge Wave...
1
by: homevista | last post by:
Part II: Wave file - How to read to a buffer Wave (or Wav) is the standard format for storing audio data on the PC. As software developers, we are interested in the internal structure of the file...
1
by: Steven Backus | last post by:
I inherited a Solaris c++ program that uses Rogue Wave and am trying to port it to linux. It seg faults in this code: for (int size = entries() - 1; size 1; --size) { RWOrderedIterator...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.