473,585 Members | 2,512 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

[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<cha r> v, w(1);
v = w;
}

There is a bug in the vector::operato r= 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 2532
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_t ype va(__end_of_sto rage);
iterator tmp = va.allocate(x.e nd() - x.begin(),0);
#ifndef _RWSTD_NO_EXCEP TIONS
try {
__end_of_storag e = uninitialized_c opy(x.begin(), x.end(), tmp);
} catch(...) {
va.deallocate(t mp,x.end()-x.begin());
throw;
}
#else
__end_of_storag e = uninitialized_c opy(x.begin(), x.end(), tmp);
#endif // _RWSTD_NO_EXCEP TIONS
__destroy(__sta rt, __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_storag e but the
old version of __start. I fixed it by remembering the length
to deallocate, before __end_of_storag e 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
1936
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 following error: Traceback (most recent call last): File "Play.py", line 111, in ? playWAV(sys.argv) File "Play.py", line 69, in playWAV
1
9380
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 character array using mmioread. This array does not make much sense to me however, I don't really understand the format. Anyone has an idea as to how to...
1
2548
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 use of the Rogue-Wave-Class-Library which I think SUN delivers with it's compiler suit.
4
3227
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
1810
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: http://incubator.apache.org/stdcxx The stdcxx project is a complete implementation of the C++ Standard Library with a Class Reference, a...
12
1738
by: theoderich | last post by:
Following is possible with gcc and g++: #include <math.h> double sin(double) { return 1; } int main()
9
3316
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 classe : RWFile RWFileManager
1
14908
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 so that we can open and read data correctly before transmitting it over the phone line. Fortunately, there are plenty of good articles on the...
1
2677
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 vectofclusts_iter(*((RWOrdered*) at(size))); CCluster* pc; while ((pc = (CCluster*) vectofclusts_iter()) != NIL) pc->writeChartTo(fout); }
0
7836
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8199
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8336
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7950
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8212
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6606
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3863
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1175
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.