473,396 Members | 1,933 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

crash in copy of a list. very simple question.

We encounter a crash every now and then at a client, and now I'm starting to
doubt the fundamentals of life :-)

We have a list of structs.

struct SContactProperty
{
public:
SContactProperty(void) : m_strName(_T("")), m_strValue(_T("")),
m_bHidden(false) {};
tstring m_strName; //The name of the call property
tstring m_strValue; //The value of the call property
bool m_bHidden;
};

if we have 2 variables l1 and l2, both of type list<SContactProperty>, can
one then do simply:
l1=l2;

???
I ask because we put GlobalFlags on so that it crashes at the first memory
misusage. This helped us always in the past to pinpoint the any crash
immediately, but here it leads to such a line.

We used Visual Studio 6 SP6.

Jürgen Devlieghere
Jul 23 '05 #1
4 1685
Jürgen Devlieghere wrote:
We encounter a crash every now and then at a client, and now I'm starting to
doubt the fundamentals of life :-)

We have a list of structs.

struct SContactProperty
{
public:
SContactProperty(void) : m_strName(_T("")), m_strValue(_T("")),
m_bHidden(false) {};
tstring m_strName; //The name of the call property
tstring m_strValue; //The value of the call property
What's a 'tstring'? Is that something you cooked up which doesn't manage
its dynamic memory properly?
bool m_bHidden;
};

if we have 2 variables l1 and l2, both of type list<SContactProperty>, can
one then do simply:
l1=l2;

???
I ask because we put GlobalFlags on so that it crashes at the first memory
misusage. This helped us always in the past to pinpoint the any crash
immediately, but here it leads to such a line.
I am not sure I understand what you're trying to say here, but 'tstring'
is very likely to blame.
We used Visual Studio 6 SP6.


Shouldn't matter.

V
Jul 23 '05 #2
Hi,

Sorry, tstring is just std::string in case of ASCII (to have an equivalent
to tchar but for STL).

Jürgen

"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:Nh*******************@newsread1.mlpsca01.us.t o.verio.net...
Jürgen Devlieghere wrote:
We encounter a crash every now and then at a client, and now I'm starting
to doubt the fundamentals of life :-)

We have a list of structs.

struct SContactProperty
{
public:
SContactProperty(void) : m_strName(_T("")), m_strValue(_T("")),
m_bHidden(false) {};
tstring m_strName; //The name of the call property
tstring m_strValue; //The value of the call property


What's a 'tstring'? Is that something you cooked up which doesn't manage
its dynamic memory properly?
bool m_bHidden;
};

if we have 2 variables l1 and l2, both of type list<SContactProperty>,
can one then do simply:
l1=l2;

???
I ask because we put GlobalFlags on so that it crashes at the first
memory misusage. This helped us always in the past to pinpoint the any
crash immediately, but here it leads to such a line.


I am not sure I understand what you're trying to say here, but 'tstring'
is very likely to blame.
We used Visual Studio 6 SP6.


Shouldn't matter.

V

Jul 23 '05 #3
Jürgen Devlieghere wrote:
Sorry, tstring is just std::string in case of ASCII (to have an equivalent
to tchar but for STL).
(a) Please don't top-post. Thanks!

(b) If you're sure that 'tstring' is not to blame, there is nothing in
the code you posted to indicate a possible screw-up. Then it is
most likely elsewhere.

Try to create a minimal program (by removing parts of your code that you
think are irrelevant or cannot be the cause of the problem) that still
exhibits the crash you are talking about. If you get a small program that
can do that, post it here. If in the process of reducing your code you
find that some other piece when removed causes the crash to go away, look
at that piece with more care.

Jürgen

"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:Nh*******************@newsread1.mlpsca01.us.t o.verio.net...
Jürgen Devlieghere wrote:
We encounter a crash every now and then at a client, and now I'm starting
to doubt the fundamentals of life :-)

We have a list of structs.

struct SContactProperty
{
public:
SContactProperty(void) : m_strName(_T("")), m_strValue(_T("")),
m_bHidden(false) {};
tstring m_strName; //The name of the call property
tstring m_strValue; //The value of the call property


What's a 'tstring'? Is that something you cooked up which doesn't manage
its dynamic memory properly?

bool m_bHidden;
};

if we have 2 variables l1 and l2, both of type list<SContactProperty>,
can one then do simply:
l1=l2;

???
I ask because we put GlobalFlags on so that it crashes at the first
memory misusage. This helped us always in the past to pinpoint the any
crash immediately, but here it leads to such a line.


I am not sure I understand what you're trying to say here, but 'tstring'
is very likely to blame.

We used Visual Studio 6 SP6.


Shouldn't matter.

V

V
Jul 23 '05 #4
Hi,

For all those that suffered and will suffer the same experiences, here the
result.

We used the STL implementation delivered by Microsoft with Visual Studio 6,
which is actually an old Dinkumware implementation, in a multithreaded
environment. Well, it's very simpel. Don't.

Of course we were aware that the STL implementation was not thread-safe. So,
we protected all container actions using semaphores. Well, that's not
enough. The simpel fact that you use std::string from multiple threads will
cause your application to crash in the routines that do string manipulation
/ creation.

Here is a 20 lines example, that will crash within a second, although
nothing is wrong with the code:
#include <string>
#include <time.h>
#include <stdio.h>
#include <windows.h>

unsigned long __stdcall test(void *dummy_p)
{
for (;;)
{
std::string strTest;
for (int i=0;i<10;i++)
{
strTest += "abcdef";
}
}
return 0;
}

void main(void)
{ int i;

DWORD thread_id;

for (i=0;i<100;i++)
CreateThread(NULL,0,test,(void *)i,0,&thread_id);

char buffer[100];
gets(buffer);
}

As you see, only a local stack variable (the string strTest) is manipulated,
so one would think it should not be protected. Well, wrong about that.

Applying a fix available from Dinkumware doesn't help if you compile
"multithreaded dll", since the offending code is then in the dll.

The solution was to move to StlPort. It costed some days to move all our
code, but appart from 1 small issue that is not compatible (the iterator
change if you call delete on a std::set::iterator), we didn't have to change
our code.

Hope to help some people that face the same problem.

Jürgen Devlieghere
Jul 23 '05 #5

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

Similar topics

48
by: Joseph | last post by:
Hi I'm writing a commercial program which must be reliable. It has to do some basic reading and writing to and from files on the hard disk, and also to a floppy. I have foreseen a potential...
8
by: Eric Brunel | last post by:
Hi all, I was creating a Tkinter widget in the style of the reversed tabs below Excel worksheets and I stepped in a serious problem: the code I made makes python crash with a seg fault, bus...
14
by: MSR | last post by:
I have a couple of questions. 1. Copy Constructor. class A { private: int a1; double d1; char *ptr;
8
by: Adam Louis | last post by:
I would like help resolving this problem. I'm a novice who's been hired to query a hospital database and extract useful information, available to me only in a dynamically generated, downloadable...
7
by: simkn | last post by:
Hello, I'm writing a function that updates an array. That is, given an array, change each element. The trick is this: I can't change any elements until I've processed the entire array. For...
34
by: NewToCPP | last post by:
Hi, Why does a C/C++ programs crash? When there is access to a null pointer or some thing like that programs crash, but why do they crash? Thanks.
5
by: Eric_Dexter | last post by:
I was trying to add this to my project but I must be missing some includes or there is a serius error somewhere Anthra Norell wrote:
12
by: John Henry | last post by:
Hi list, Just to make sure I understand this. Since there is no "pointer" type in Python, I like to know how I do that. For instance, if I do: ...some_huge_list is a huge list...
110
by: alf | last post by:
Hi, is it possible that due to OS crash or mysql itself crash or some e.g. SCSI failure to lose all the data stored in the table (let's say million of 1KB rows). In other words what is the worst...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...
0
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,...

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.