On 07/07/2015 at 09:36, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   R15 
Platform:   Windows  ;   
Language(s) :     C++  ;


I've just recently update Melange to version 15.003, and I'm getting a sporadic crash with the following code:

BaseTag* tag = searchOp->GetFirstTag();
if (tag->GetParameter(TEXTURETAG_RESTRICTION, data))
	String name = data.GetString();

Right when getting the name. As it turns out, TEXTURETAG_RESTRICTION could sometimes return values that are not of type DA_STRING, and because I'm always reading a String, the application crashes.
This does not happen with the old version, but I have no problem in verifying the data type, and only execute the code if the type is DA_STRING.

My question is, what could be the values of tag->GetParameter(TEXTURETAG_RESTRICTION, data) ?
What is the meaning of an Int32 for example?

On 07/07/2015 at 09:48, xxxxxxxx wrote:

may be it crashes of a missing tag?
try this

BaseTag* tag = searchOp->GetFirstTag();
if (tag && tag->GetParameter(TEXTURETAG_RESTRICTION, data))
	String name = data.GetString();

On 07/07/2015 at 09:55, xxxxxxxx wrote:


The crash is exactly in the line String name = data.GetString()
I have other code lines in there, the posted code was a simplification. I actually read other stuff from the same tag, before the crash.

Interestingly enough, if I have a breakpoint in the next line (after the GetString()) it always crashes. If I do not have any breakpoint near this code, it's very hard to get a crash here (but it happens sometimes).

On 07/07/2015 at 10:52, xxxxxxxx wrote:


About your question of Int32, I'd recommend reading this:

On 07/07/2015 at 10:59, xxxxxxxx wrote:

Originally posted by xxxxxxxx


About your question of Int32, I'd recommend reading this:


Ok, I kind of deserve that for not being clear enough!
Well, What I meant was, "what is the meaning of and Int32 value as a result of the Get TEXTURETAG_RESTRICTION".

I know what an Integer is, what I don't know is what its value represents here.

On 07/07/2015 at 11:40, xxxxxxxx wrote:


Okay, now we know that :p

I wasn't able to find anything about that on the docs.

Could it be an enum value? Just my thoughts here.

On 07/07/2015 at 13:43, xxxxxxxx wrote:

Here are my thoughts on this:

1. Do not assume that the first tag is a Texture tag.  And you might be like well it is the first and maybe only tag on the object.  And you would be incorrect.  Polygon objects also have two hidden tags: a Point tag and a Polygon tag.  Verify that you are getting the proper tag type.  Would be better to iterate through the object's tags until you find a texture tag.  There may be more than one or none.

if (tag && tag->IsInstanceOf(Ttexture) && tag->GetParameter(TEXTURETAG_RESTRICTION, data))

2. TEXTURETAG_RESTRICTION is defined as a String description in the Ttexture.res file.  Therefore, it should *always* return a String.  That is why I mention point 1.  Could be that you are requesting a parameter for a tag that isn't a Texture tag and thus the issues.

On 07/07/2015 at 13:52, xxxxxxxx wrote:


So I thought that simplifying the code was the best approach to make myself clear, but I was wrong. So here is the full code until the problematic line:

BaseObject *searchOp = (PolygonObject* )op;
while (!found && searchOp != nullptr)
    BaseTag* btag = searchOp->GetFirstTag();
    for (; btag; btag = (BaseTag* )btag->GetNext())
        if (btag->GetType() == Ttexture)
            if (btag->GetParameter(TEXTURETAG_MATERIAL, data))
                MaterialSelection m;
                m.mat = (AlienMaterial* )data.GetLink();
                found = true;
                if (m.mat != nullptr && std::find(std::begin(materials), std::end(materials), m) == end(materials))
                    if (btag->GetParameter(TEXTURETAG_RESTRICTION, data))
                        String name = data.GetString();

I think I have all the needed checks, however, if I check the "data" type (data.GetType()) it returns Int32, and the the data.GetString() crashes.

On 07/07/2015 at 15:04, xxxxxxxx wrote:

data.GetType() does indeed return Int32.  It is a value representing the 'type' of data for the description.  It should be DA_STRING.

if (data.GetType() != DA_STRING)  //then something is wrong

Otherwise, I don't see anything wrong with the code (except the possible issues using the STL).

On 07/07/2015 at 15:21, xxxxxxxx wrote:

Yep, the type I'm getting when it crashes is DA_LONG.

On 07/07/2015 at 15:57, xxxxxxxx wrote:

That is very odd.  Possible memory corruption?  Is the restriction empty when it crashes or it doesn't matter either way?  There has to be some outside factor for the data type to return DA_LONG when it has to be DA_STRING.

On 07/07/2015 at 15:59, xxxxxxxx wrote:

may be it returns an Int32 "0" when string is empty.

On 07/07/2015 at 16:30, xxxxxxxx wrote:

It could be empty yes, because all variables are null, and the type could just be the initial value, or even memory trash.

Either way, does it make sense to crash in situations like this? Also, why the GetParameter returns true, if the data is empty?

I check for type now, to make sure it does not read invalid stuff, but it was not needed before.

On 08/07/2015 at 10:46, xxxxxxxx wrote:


I can confirm the described behavior and it seems to be a bug. A bug report was filed.

But calling GetString() should not cause a crash, it should just trigger a breakpoint. Are your sure it causes a crash?

Best wishes,

On 08/07/2015 at 10:48, xxxxxxxx wrote:

You're right, it's just a breakpoint! That's why it doesn't happen in release mode.