Problems with UPP_HEAP in multi-threaded [message #16367] |
Tue, 10 June 2008 21:49 |
cocob
Messages: 156 Registered: January 2008
|
Experienced Member |
|
|
Hello all
One more time, sorry for my english low skill, ...
I have some problems with UPP Core package in multi-threaded.
I have a package which use STL (strings, vectors, ...) Its functions works perfectly in an app with a single thread but in multithreaded i get a crash "Invalid memory access". It seems to come from overloaded function for HEAP (new, delete) which are use in STL for example in std::string::append().
Here a little example producing my problems.
My config : Debian lenny x86 UPP SVN r284
#include <Core/Core.h>
#include <iostream>
using namespace Upp;
class test
{
public:
typedef test CLASSNAME;
void loop();
void start();
};
void test::start()
{
Thread().Start(THISBACK(loop));
}
void test::loop()
{
std::string str;
while(true)
{
Thread().Sleep(200);
str.append("test");
std::cout << "loop" << std::endl;
}
}
CONSOLE_APP_MAIN
{
(new test)->start();
while(true)
{
Thread().Sleep(500);
std::cout << "Wait..." << std::endl;
}
}
|
|
|
|
|
|
|
|
|
Re: Problems with UPP_HEAP in multi-threaded [message #16376 is a reply to message #16367] |
Wed, 11 June 2008 12:54 |
cocob
Messages: 156 Registered: January 2008
|
Experienced Member |
|
|
In build method my compiler name is g++-4.1
I have tried the test of the other thread. It seems to works (no invalid memory access and it prints "32") in both debug speed and optimal.
The same test prints 0 with g++-4.2 and "32" with g++-4.3
I don't think this is a compiler problem.
I have some problems when i use Core package only
Thanks for help
cocob
[Updated on: Wed, 11 June 2008 13:04] Report message to a moderator
|
|
|
|
|
|
|
|
|