Horde3D

Next-Generation Graphics Engine
It is currently 22.11.2024, 13:21

All times are UTC + 1 hour




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: 17.07.2008, 14:06 
Offline

Joined: 03.07.2008, 01:23
Posts: 50
Ok, so I was doing some experimenting with creating textures on the fly. I ended up creating the same texture twice. Now, the documentation tells that if the resource already exists, the function fails. However it didn't mention it fails with a segmentation fault, randomly:

#0 0xb7be5032 in RendererBase::destroyRenderBuffer () libHorde3D.so
#1 0xb7c097e4 in Texture2DResource::release () from libHorde3D.so
#2 0xb7c09877 in Texture2DResource::~Texture2DResource () from libHorde3D.so
#3 0xb7bc2871 in createTexture2D () from libHorde3D.so

To reproduce, just call it like e.g. this:

std::cout << "WORK XX " << res << std::endl;
res = Horde3D::createTexture2D("norfdsfdsmal2",
ResourceFlags::NoTexRepeat|
ResourceFlags::NoTexCompression|
ResourceFlags::NoTexMipmaps|
ResourceFlags::NoTexFiltering,
width, height, false);
std::cout << "WORK XY " << res << std::endl;
res = Horde3D::createTexture2D("norfdsfdsmal2",
ResourceFlags::NoTexRepeat|
ResourceFlags::NoTexCompression|
ResourceFlags::NoTexMipmaps|
ResourceFlags::NoTexFiltering,
width, height, false);
std::cout << "WORK XZ " << res << std::endl;
res = Horde3D::createTexture2D("norfdsfdsmal2",
ResourceFlags::NoTexRepeat|
ResourceFlags::NoTexCompression|
ResourceFlags::NoTexMipmaps|
ResourceFlags::NoTexFiltering,
width, height, false);
std::cout << "WORK XW " << res << std::endl;

That could produce for example:

WORK XX 0
WORK XY 47
./simple_run.sh: line 1: 31572 Segmentation fault

or

WORK XX 0
WORK XY 47
WORK XZ 0

depending on luck.


Top
 Profile  
Reply with quote  
PostPosted: 17.07.2008, 14:27 
Offline

Joined: 03.07.2008, 01:23
Posts: 50
If I try to do

"removeResource" followed by "releaseUnusedResources" to make sure the same resource shouldn't be there anymore, I get the same segmentation fault. It just seems destroyRenderBuffer is somehow broken. And I didn't even set the "renderable" flag to true when creating the texture.

This time with:

#0 0xb7c7a032 in RendererBase::destroyRenderBuffer () from libHorde3D.so
#1 0xb7c9e7e4 in Texture2DResource::release () from libHorde3D.so
#2 0xb7c8b0ab in ResourceManager::releaseUnusedResources () from libHorde3D.so
#3 0xb7c5789b in releaseUnusedResources () from libHorde3D.so


Top
 Profile  
Reply with quote  
PostPosted: 17.07.2008, 14:32 
Offline

Joined: 03.07.2008, 01:23
Posts: 50
BTW, if you want to fix this, you should set

_rendBuf=0x0;

in Texture2DResource constructor, if the renderable flag is false. Just a thought: Why are C++ initializer lists never used in the engine? This is not java, you don't have default values for pointers or any other values for the matter.


Top
 Profile  
Reply with quote  
PostPosted: 18.07.2008, 16:39 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
Is the
Code:
_rendBuf=0x0;

statement the fix for all of the problems above?


Top
 Profile  
Reply with quote  
PostPosted: 18.07.2008, 19:03 
Offline

Joined: 03.07.2008, 01:23
Posts: 50
Yeah, it fixes the problems. Sorry for elaborating too much. It's a simple thing - if the texture isn't renderable, then it's destructor tries to free a buffer that has never been allocated. It tests whether it's 0, but it's never been initialized... the same when unloading resources by hand...


Top
 Profile  
Reply with quote  
PostPosted: 18.07.2008, 19:40 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
Fixed it in the SVN,... thanks for pointing it out


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group