Crash when accessing transform information of MFnTransform

Crash when accessing transform information of MFnTransform

Sebastian_Wiendl
Enthusiast Enthusiast
1,220 Views
4 Replies
Message 1 of 5

Crash when accessing transform information of MFnTransform

Sebastian_Wiendl
Enthusiast
Enthusiast

Hi everyone,

I have come across a very odd crash that I cannot explain.

(by the way, using Maya 2020)

 

So, I have got a custom MPxLocatorNode and at each frame, I am reading its parent's transform values.

The parent is connected to the output of a decomposeMatrix node and I get correct values... until I don't.

 

At some point (not always the same frame), it throws an exception saying:

 

Exception thrown at 0x00007FF803A3C454 (Foundation.dll) in maya.exe: 0xC0000005: Access violation writing location 0x0000000000000000.

 

Here is a code snippet.

MStatus status;
const MFnDagNode dagNode( object, &status );                      // Object is my custom MPxLocator node's MObject
if( status != MStatus::kSuccess ) return;                         
const MObject parentObject = dagNode.parent( 0 );                       
const bool null = parentObject.isNull();                          // is false
const MFnDagNode parentDag( parentObject );                       
const MString apiType = parentObject.apiTypeStr();                // is kTransform
const MFnTransform transform( parentObject, &status );            // status is fine {fStatusCode=0 '\0' fInternalStatusCode=255 'ÿ' fStatus=true }
MString name = transform.name();                                  // has the correct name
const MTransformationMatrix matrix = transform.transformation();  // Crash

 

As you can see, I still get the correct name and api type of the MFnTransform.

But on transform.transformation(), I get a crash.

I also get a crash at some point if I try transform.getTranslation( MSpace::kTransform, &status );

 

I know this is not much to work with, but I was hoping for suggestions on how to maybe check if the transform is valid, or being able to get the values any other way.

I'm fine if there is a test saying that there is bad data in the transform and to not attempt to read it.

I just don't want a crash.

 

Any help would be much appreciated.

 

Cheers,

Sebastian

0 Likes
Accepted solutions (1)
1,221 Views
4 Replies
Replies (4)
Message 2 of 5

olarn
Advocate
Advocate

Was cached playback active? does the problem persists in serial evaluation mode?

0 Likes
Message 3 of 5

Sebastian_Wiendl
Enthusiast
Enthusiast

Thank you very much for getting back to me @olarn 

Much appreciated.

 

I never use Cached Playback, so that is always off for me.

 

And yes, Serial evaluation mode seems to fix it.

Any idea what's the issue with Parallel evaluation mode in this scenario?

 

Again, thanks so much for your help.

 

Cheers,

Sebastian

Message 4 of 5

olarn
Advocate
Advocate
Accepted solution

Well the symptoms sounded like there's race condition

Did the node held on to some other shared object or resource it wasn't supposed to? Another possible cause is using non-thread safe functions during parallel evaluation.

 

Perhaps try receiving custom transform parent matrix via connection from custom node .parentMatrix attribute instead of querying directly during evaluation

0 Likes
Message 5 of 5

Sebastian_Wiendl
Enthusiast
Enthusiast

Sorry for not getting back to you earlier, @olarn . I just got back from holidays.

 

Another possible cause is using non-thread safe functions during parallel evaluation.

Yes, I think this is probably the most likely cause. I will have to double-check my code.

 


Perhaps try receiving custom transform parent matrix via connection from custom node .parentMatrix attribute instead of querying directly during evaluation

This seems to work without problems.

 

Thanks so much again for your help.

 

0 Likes