Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Problems with UPP_HEAP in multi-threaded
Problems with UPP_HEAP in multi-threaded [message #16367] Tue, 10 June 2008 21:49 Go to next message
cocob is currently offline  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 #16368 is a reply to message #16367] Tue, 10 June 2008 22:08 Go to previous messageGo to next message
cocob is currently offline  cocob
Messages: 156
Registered: January 2008
Experienced Member
finally the problem seems to have no link with multi-threading

this piece of code crash without flagMT defined

#include <Core/Core.h>

CONSOLE_APP_MAIN
{
	std::string str;
	str.append("test");
}

[Updated on: Wed, 11 June 2008 08:51]

Report message to a moderator

Re: Problems with UPP_HEAP in multi-threaded [message #16369 is a reply to message #16368] Tue, 10 June 2008 23:44 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
It works for me in ubuntu 8.04 with gcc 4.1.

What is you gcc --version ?

Is the problem in optimal mode only or in debug too?

Mirek
Re: Problems with UPP_HEAP in multi-threaded [message #16370 is a reply to message #16367] Wed, 11 June 2008 08:49 Go to previous messageGo to next message
cocob is currently offline  cocob
Messages: 156
Registered: January 2008
Experienced Member
gcc -version show 4.2 but 4.1 and 4.3 are also installed.
Does theide use the 4.1 version ?

This problem occurs with Force_speed and not with debug (i never tested optimal).

Thanks for your help

cocob
Re: Problems with UPP_HEAP in multi-threaded [message #16372 is a reply to message #16370] Wed, 11 June 2008 09:12 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
4.2 is flawed.

See this:

http://www.ultimatepp.org/forum/index.php?t=msg&th=3466& amp; amp;start=0&

Now of course the problem is what GCC is theide using. I am not quite sure how you got your U++; AFAIK regular svn .deb for Ubunut with theide binary has 4.1 as dependency and uses it to compile (presets the build method).

Have you installed with binary or compiled theide from sources?

Mirek

[Updated on: Wed, 11 June 2008 09:15]

Report message to a moderator

Re: Problems with UPP_HEAP in multi-threaded [message #16373 is a reply to message #16367] Wed, 11 June 2008 09:54 Go to previous messageGo to next message
cocob is currently offline  cocob
Messages: 156
Registered: January 2008
Experienced Member
I have installed .deb downloaded here

http://www.ultimatepp.org/svnbuilds/
Re: Problems with UPP_HEAP in multi-threaded [message #16375 is a reply to message #16373] Wed, 11 June 2008 10:45 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Now THAT is little bit more weird Smile

Could you try that testcase posted in other thread (the one about the bug)?

What is the Compiler name in your Setup/Build methods...?

Mirek
Re: Problems with UPP_HEAP in multi-threaded [message #16376 is a reply to message #16367] Wed, 11 June 2008 12:54 Go to previous messageGo to next message
cocob is currently offline  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

Re: Problems with UPP_HEAP in multi-threaded [message #16377 is a reply to message #16367] Wed, 11 June 2008 13:19 Go to previous messageGo to next message
cocob is currently offline  cocob
Messages: 156
Registered: January 2008
Experienced Member
My problem is solved with g++-4.3 instead of g++-4.1 !
Re: Problems with UPP_HEAP in multi-threaded [message #17321 is a reply to message #16377] Thu, 07 August 2008 02:51 Go to previous messageGo to next message
captainc is currently offline  captainc
Messages: 278
Registered: December 2006
Location: New Jersey, USA
Experienced Member
I'm running into the same problem. Having trouble with g++-4.1 and g++-4.2. Attempting to compile and install 4.3 now. What is the issue with it?
Re: Problems with UPP_HEAP in multi-threaded [message #17323 is a reply to message #16367] Thu, 07 August 2008 08:42 Go to previous messageGo to next message
cocob is currently offline  cocob
Messages: 156
Registered: January 2008
Experienced Member
since this problem i always compile with g++-4.3 and i got no more problems
Re: Problems with UPP_HEAP in multi-threaded [message #17335 is a reply to message #17323] Fri, 08 August 2008 04:30 Go to previous messageGo to next message
captainc is currently offline  captainc
Messages: 278
Registered: December 2006
Location: New Jersey, USA
Experienced Member
I'm using g++ 4.3.1 and I am still getting the problem. I am using CallbackArgTarget example to test. I did a clean Upp out directory and full recompile using g++-4.3 and still getting Fatal error invalid memory access. Though the main gui window comes up; it just has the error message on it. Non-gui apps seem to work though...
Re: Problems with UPP_HEAP in multi-threaded [message #17336 is a reply to message #17335] Fri, 08 August 2008 08:31 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Confirmed.
Re: Problems with UPP_HEAP in multi-threaded [message #17337 is a reply to message #17336] Fri, 08 August 2008 08:41 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Anyway, only a minor bug:

void Ctrl::PopUp(Ctrl *owner, bool savebits, bool activate, bool, bool)
{
	LLOG("POPUP: " << UPP::Name(this));
	Ctrl *q = owner ? owner->GetTopCtrl() : GetActiveCtrl();
	ignoretakefocus = true;
	Create(q, true, savebits);
	if(activate && q) {
		q->StartPopupGrab();
		popupgrab = true;
	}
	if(top) popup = true;
	WndShow(visible);
	if(activate && IsEnabled())
		SetFocus();
	if(top) top->owner = owner;
	StateH(OPEN);
}


-> the problem was than the menu is "alone" without real application. Fixed by "&& q".

Mirek
Previous Topic: DEFAULT_MAX_CONTENT_SIZE or max_content_size
Next Topic: Smart pointer: Garbage collected by reference counting
Goto Forum:
  


Current Time: Thu Mar 28 10:00:29 CET 2024

Total time taken to generate the page: 0.01822 seconds