Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Crash in MDataHandle::setFloat (Maya 2016)

Crash in MDataHandle::setFloat (Maya 2016)

Anonymous
Not applicable
1,114 Views
3 Replies
Message 1 of 4

Crash in MDataHandle::setFloat (Maya 2016)

Anonymous
Not applicable

I have a wierd unexpected crash in DependEngine.dll. I have a custom MPxNode in c++, I have removed all code but the very minimum to repro this bug. I also have a very simple .ma file, only my node and a locator.

 

To crash, I launch Maya 2016, open this .ma file, then click the timeline to change the time twice. On the second time change it will crash inside my compute, but actually inside the call to MDataHandle::setFloat, which is totally strange.

 

Here the relevant part of the .ma file:

 

createNode transform -n "Left_Ctrl" -p "Left_Grp";

   (skip transform attributes)

createNode myNode -n "myNode1";
    addAttr -w false -ci true -sn "lips_AA" -ln "lips_AA" -at "float";
connectAttr ":time1.o" "myNode1.tm";
connectAttr "myNode1.lips_AA" "Left_Ctrl.translateX"

 

And the simplified node basically has only the initialize and this:

 

class myNode: public MPxNode

(skip trivial other stuff)


MStatus myNode::compute( const MPlug& plug, MDataBlock& block )
{
    MStatus status;

    if (MFnDependencyNode(thisMObject()).isNewAttribute(plug.attribute()))
    {
        {
            MDataHandle data = block.outputValue(plug.attribute(), &status);
            data.setFloat(0.0f); // Will crash inside this call
            block.setClean(plug.attribute());
            return MStatus::kSuccess;
        }
    }

    return MStatus::kSuccess;
}



MStatus myNode::setDependentsDirty( const MPlug& plugBeingDirtied, MPlugArray &affectedPlugs )
{
    if (plugBeingDirtied == MPlug(thisMObject(), xml) ||
        plugBeingDirtied == MPlug(thisMObject(), time) ||
        plugBeingDirtied == MPlug(thisMObject(), forcedirty))
    {
        // Add all dynamic outputs to affectedPlugs

        MFnDependencyNode fnDependNode(thisMObject());
        for ( unsigned i=0; i<fnDependNode.attributeCount(); i++ )
        {
            MObject attribute = fnDependNode.attribute(i);
            if (fnDependNode.attributeClass(attribute)==MFnDependencyNode::kLocalDynamicAttr)
            {
                MPlug plug(thisMObject(), attribute);
                affectedPlugs.append(plug); // with the supplied .ma test file, this will be called once on the plug called lips_AA
            }
        }
    }

    return( MS::kSuccess );
}
0 Likes
Accepted solutions (1)
1,115 Views
3 Replies
Replies (3)
Message 2 of 4

deane
Community Visitor
Community Visitor

The second return value in your compute() should be MS::kUnknownParameter, otherwise Maya won't do its default processing on the attributes which your plugin is not handling.

 

Your compute() must retrieve the input values that the output depends on - even if you just throw the values away - otherwise the DG's dirtying can get out of synch.

 

I don't think either of those things is responsible for your crash, but they may be exacerbating the the problem.

 

Also, have you tried printing out the name of the attribute it's crashing on? Perhaps it's some unrelated dynamic attr.

0 Likes
Message 3 of 4

Anonymous
Not applicable

Yes, the two changes you mention are in my original code, but not in this simplified version. Both have the crash. With the symbols I was able to get a better stack for the crash, I don't know if that can help anyone.

I am also downloading and applying Service Packs, just to make sure I have the most up-to-date software, and maybe get different hints about the problem. I was currently using the initial release of Maya 2016.

 

>     DependEngine.dll!CompactPlugArray<TevaluationNode::DirtyPlugInfo>::get(const Tattribute & attribute) Line 166    C++
     DependEngine.dll!TevaluationNode::setClean(const Tattribute & attribute) Line 675    C++
     DependEngine.dll!TdataBlockDG::setClean(const Tattribute & attribute) Line 2105    C++
    myplugin.mll!myNode::compute(const MPlug & plug, MDataBlock & block) Line 170    C++

0 Likes
Message 4 of 4

Anonymous
Not applicable
Accepted solution

Actually, I just installed Maya 2016 SP4, and the problem disappeared. So It seems I was hitting an actual Maya bug from the original release, and it was fixed in subsequent Service Packs.

0 Likes