-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to debug Maya crashes? #51
Comments
Not noobish at all, debugging Maya is impossible. Simply put. They do not provide debug symbols and crashes reveal little to no information about why it happened. Best one can do is trial-and-error your way to a suitable workaround. To speed up iteration time, I use from maya import standalone
standaline.initialize()
import my_module
my_module.test() Booting up mayapy is somewhat quicker than booting up the UI, and crashes have been consistent between the two so far. Once you've got a reproducible case with cmdx, I would recommend reproducing it with plain |
OK so I made some progress on that crash:
|
Great summary. I don't use compound attributes, nor delete attributes, myself so it's quite possible there are low-hanging fruit to be harvested in this issue forest. To confirm it's related to plug reuse, you could try |
Ugh, well that's disappointing.
Good tip! I'll try that next time.
Yup I did try it, that solves it. I'm now looking for a more surgical approach, as well as asserting for future safety. |
Not that I'm aware of. :S If you're lucky, the Output Window (on Windows) remains open long enough for you to spot what's going on, it contains at least some useful information. Especially for C++ development where this debugging problem is also rampant. That said, you can redirect the script editor to a file via Python's
Ok. Then that's definitely a cmdx bug. Come to think of it, I have had issues deleting attributes. My "solution" has been to use |
Awesome! I can probably also use that to pipe back to my IDE (VsCode) and get line hyperlinks in the console... someday! Regarding the delete issue, I do have a working fix, seems stable so far. I'm giving up on trying to detect dead plugs in |
I know how you feel. I've been dealing with arbitrary crashes and proxy attributes in Maya (2019, specifically) lately. Maya is not forgiving when it comes to crashes. It would be a totally reasonable temporary solution to clear any plug cache whenever an attribute is deleted though. I've done that a few times only to realise and spot a solution shortly thereafter. Deletion generally isn't run-time sensitive, and even if it was stability is more important than performance. |
Sure clearing is reasonable perf-wise. I like being more precise though, only to make sure I've understood the issue precisely, gives me more confidence. If it still crashes after that, then it means there's more to the issue. |
I just discovered a method of debugging in Maya that I hope everyone already knows and that I wish I had known about years ago. traceWhenever Maya crashes as a result of calling Python, such as Stack trace:
OGSMayaBridge.dll!OGSSubSceneItem::update
OGSMayaBridge.dll!OGSMayaSubSceneManager::UpdateAllSubScenes
OGSMayaBridge.dll!Ttask::syncExecuteChildren
OGSMayaBridge.dll!Ttask::syncExecuteChildren
OGSMayaBridge.dll!OGSApplicationBridge::UpdateScene
OGSMayaBridge.dll!OGSMayaRenderer::updateScene
OGSMayaBridge.dll!OGSMayaBaseRenderer::performSceneRender
OGSMayaBridge.dll!OGSMayaStrokePainter::isViewInfoLegal
OGSMayaBridge.dll!OGSMayaStrokePainter::isViewInfoLegal
DataModel.dll!TidleRefreshCmd::refreshOGSRender
DataModel.dll!TidleRefreshCmd::refresh
DataModel.dll!TidleRefreshCmd::doIt
ExtensionLayer.dll!TeventHandler::doIdles
ExtensionLayer.dll!TeventHandler::suspendIdleEvents
Qt5Core.dll!QObject::event
Qt5Widgets.dll!QApplicationPrivate::notify_helper
Qt5Widgets.dll!QApplication::notify Which most often is not very helpful at all. What if you could instead get output like this? ...
304642 | --- modulename: cmdx, funcname: commit
304643 | cmdx.py(6950): if not ENABLE_UNDO:
304644 | cmdx.py(6953): if not hasattr(cmds, unique_command):
304645 | cmdx.py(6961): try:
304646 | cmdx.py(6962): assert shared.redoId is None
304647 | cmdx.py(6963): assert shared.undoId is None
304648 | cmdx.py(6969): shared.undoId = "%x" % id(undo)
304649 | cmdx.py(6970): shared.redoId = "%x" % id(redo)
304650 | cmdx.py(6971): shared.undos[shared.undoId] = undo
304651 | cmdx.py(6972): shared.redos[shared.redoId] = redo
304652 | cmdx.py(6975): getattr(cmds, unique_command)()
304653 | --- modulename: __init__, funcname: cmdx_0_5_1_command
304654 | <string>(2): cmdx.py(4964): self._doLockAttrs()
304655 | --- modulename: cmdx, funcname: _doLockAttrs
304656 | cmdx.py(4905): while self._lockAttrs:
304657 | cmdx.py(4965): self._doKeyableAttrs()
304658 | --- modulename: cmdx, funcname: _doKeyableAttrs
304659 | cmdx.py(4913): while self._keyableAttrs:
304661 | cmdx.py(4966): self._doNiceNames()
304662 | --- modulename: cmdx, funcname: _doNiceNames
304663 | cmdx.py(4921): while self._niceNames:
304664 | cmdx.py(4753): cmds.undoInfo(chunkName="%x" % id(self), closeChunk=True)
<Crash> And for the love of all that is holy, you can! import sys
import trace
def trace_this(func, fname):
oldout = sys.stdout
olderr = sys.stderr
try:
with open(fname, "w") as f:
sys.stdout = f
sys.stderr = f
tracer = trace.Trace(count=False, trace=True)
tracer.runfunc(func)
finally:
sys.stdout = oldout
sys.stderr = olderr
def crashing_function():
from maya.api import OpenMaya as om
fn = om.MFnDagNode()
node = fn.create("transform")
om.MGlobal.deleteNode(node)
# Do not run this. Yes, it actually crashes Maya
plug = fn.findPlug("translateX", True)
trace_this(crashing_function, r"c:\crashing_function.txt") And that's it! Now Python will print every line it executes to disk, right up until it crashes. Which means you can tell the exact line responsible for the crash. Almost. Most of the time the final line is half-written, other times it's a few lines too old. Maya is crashing after all, and Python seems to be amongst the first to go. But! The above example trace is 300,000 lines long, and the crashing function I was debugging was only about 1/4 of the way done before crashing. Up until discovering The FunctionFor completeness, I'll point out a few things about the tracing function above that are important.
|
Apologies for the perhaps noobish question, but I keep getting hard crashes (Maya shows a "fatal error" dialog, then the crash reporter, then exits), which I'm 90% sure come from cmdx (more specifically, modifying existing compound attributes on a DagNode).
I don't have debug symbols (tips on where to find them? I installed the 2020 devkit but I don't see any pdbs), so the dump doesn't tell me much, except for a partial callstack (somewhat better in the crash log). The crash comes from python > OpenMaya > DependEngine.dll
plug::name
.Here's the crash dump in case someone's feeling generous :) ! But I'd appreciate any tips on how to debug myself.
dumpdata.zip
The text was updated successfully, but these errors were encountered: