playMaker

Author Topic: help with debugging/avoiding null reference error  (Read 1728 times)

twerkface

  • Playmaker Newbie
  • *
  • Posts: 8
help with debugging/avoiding null reference error
« on: December 12, 2017, 07:59:21 PM »
I have a non-interactive, infinitely cycling application scripted with PlayMaker that regularly (but doesn't frequently) crash. Both the standalone player and the Unity editor (during runtime) crash with the following error type:

Code: [Select]
Crashed Thread:        0  Dispatch queue: com.apple.main-thread
 
 Exception Type:        EXC_BAD_ACCESS (SIGABRT)
 Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000230
 Exception Note:        EXC_CORPSE_NOTIFY   

Sometimes it's a freeze, and usually it crashes the application immediately. The logs always show a varying number of "Receiving unhandled NULL exception" messages at the time of the crash. From this thread I assume the problem isn't with my variables that are values, but with the reference types.

I've been going through my FSMs and variables. Because there are many different FSMs running at the same time, it's hard for me to figure out how to debug this using breakpoints. But I'm also not sure what types of variables commonly cause this error?

The thread I linked above mentions using try/catch blocks to circumvent the crashes. I guess it means scripting actions when a null reference is found? Is there an Action that allows for this?

If anyone can help interpret the following from one of my logs, I'd be eternally grateful! Is there a way to tell which Actions are being triggered at the time of the crash? Or, is there an Action that can print to the log the name of the FSM/Action(s) that are active at the time of the crash?

Code: [Select]
Receiving unhandled NULL exception
 Receiving unhandled NULL exception
 Obtained 13 stack frames.
 Obtained 31 stack frames.
 #0  0x000000016a0db9 in void physx::shdfnd::sort<physx::PxsContactPatch*, physx::SortBoundsPredicateManifold, physx::shdfnd::ReflectionAllocator<physx::PxsContactPatch*> >(physx::PxsContactPatch**, unsigned int, physx::SortBoundsPredicateManifold const&, physx::shdfnd::ReflectionAllocator<physx::PxsContactPatch*> const&, unsigned int)
 #1  0x000000016a0120 in physx::PxsContactReduction<6u>::reduceContacts()
 #2  0x0000000169f8d2 in physx::PxsSolverConstraintPostProcessTask::mergeContacts(physx::PxsCompoundContactManager&, physx::PxsThreadContext&)
 #3  0x0000000169f342 in physx::PxsSolverConstraintPostProcessTask::runInternal()
 #4  0x00000001630804 in physx::Cm::Task::run()
 #5  0x0000000071e9fc in PhysxJobFunc(physx::PxBaseTask*)
 #6  0x00000000a1f506 in JobQueue::Exec(JobInfo*, int, int)
 #7  0x00000000a1fa10 in JobQueue::ExecuteOneJob()
 #8  0x00000000a1bacc in JobSystem::ExecuteOneJobQueueJob()
 #9  0x000000006ec245 in CompletionTask::ProcessAllPhysicsTasks()
 #10 0x0000000070de3d in PhysicsManager::FixedUpdate()
 #11 0x0000000070ba53 in PhysicsManager::InitializeClass()::FixedUpdatePhysicsFixedUpdatestruct::Forward()
 #12 0x00000000acb33d in PlayerLoop()
 #13 0x0000000133c126 in -[PlayerAppDelegate UpdatePlayer]
 #14 0x00000095a8f1e6 in __NSFireTimer
 #15 0x0000009426a996 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__
 #16 0x0000009426a4ad in __CFRunLoopDoTimer
 #17 0x00000094269f4e in __CFRunLoopDoTimers
 #18 0x00000094261910 in __CFRunLoopRun
 #19 0x00000094260e1a in CFRunLoopRunSpecific
 #20 0x00000094260c0b in CFRunLoopRunInMode
 #21 0x00000093954396 in RunCurrentEventLoopInMode
 #22 0x00000093954182 in ReceiveNextEventCommon
 #23 0x00000093953f7b in _BlockUntilNextEventMatchingListInModeWithFilter
 #24 0x00000091f86015 in _DPSNextEvent
 #25 0x000000926ebbbb in -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:]
 #26 0x000000926eb4e5 in -[NSApplication(NSEvent) nextEventMatchingMask:untilDate:inMode:dequeue:]
 #27 0x00000091f7acb6 in -[NSApplication run]
 #28 0x00000091f47d1e in NSApplicationMain
 #29 0x0000000133bf1b in PlayerMain(int, char const**)
 #30 0x000000000029f5 in start
 Thread 0x0 may have been prematurely finalized
 Stacktrace:
 
 
 Native stacktrace:
 
     0   libsystem_kernel.dylib              0xa1668496 __pthread_kill + 10
     1   libsystem_c.dylib                   0xa15c8a34 abort + 141
     2   io 120817 ELtestbuild32 nobreak DEV 0x0112b129 _Z12HandleSignaliP9__siginfoPv + 41
     3   libmono.0.dylib                     0x030a4fbc mono_chain_signal + 69
     4   libmono.0.dylib                     0x02ffdc08 mono_sigsegv_signal_handler + 231
     5   libsystem_platform.dylib            0xa1742e5b _sigtramp + 43
     6   ???                                 0xffffffff 0x0 + 4294967295
     7   io 120817 ELtestbuild32 nobreak DEV 0x016a0120 _ZN5physx19PxsContactReductionILj6EE14reduceContactsEv + 1296
     8   io 120817 ELtestbuild32 nobreak DEV 0x0169f8d2 _ZN5physx34PxsSolverConstraintPostProcessTask13mergeContactsERNS_25PxsCompoundContactManagerERNS_16PxsThreadContextE + 1378
     9   io 120817 ELtestbuild32 nobreak DEV 0x0169f342 _ZN5physx34PxsSolverConstraintPostProcessTask11runInternalEv + 290
     10  io 120817 ELtestbuild32 nobreak DEV 0x01630804 _ZN5physx2Cm4Task3runEv + 36
     11  io 120817 ELtestbuild32 nobreak DEV 0x0071e9fc _ZL12PhysxJobFuncPN5physx10PxBaseTaskE + 204
     12  io 120817 ELtestbuild32 nobreak DEV 0x00a1f506 _ZN8JobQueue4ExecEP7JobInfoii + 118
     13  io 120817 ELtestbuild32 nobreak DEV 0x00a1fa10 _ZN8JobQueue13ExecuteOneJobEv + 64
     14  io 120817 ELtestbuild32 nobreak DEV 0x00a1bacc _ZN9JobSystem21ExecuteOneJobQueueJobEv + 28
     15  io 120817 ELtestbuild32 nobreak DEV 0x006ec245 _ZN14CompletionTask22ProcessAllPhysicsTasksEv + 21
     16  io 120817 ELtestbuild32 nobreak DEV 0x0070de3d _ZN14PhysicsManager11FixedUpdateEv + 3005
     17  io 120817 ELtestbuild32 nobreak DEV 0x0070ba53 _ZZN14PhysicsManager15InitializeClassEvEN35FixedUpdatePhysicsFixedUpdatestruct7ForwardEv + 35
     18  io 120817 ELtestbuild32 nobreak DEV 0x00acb33d _Z10PlayerLoopv + 605
     19  io 120817 ELtestbuild32 nobreak DEV 0x0133c126 -[PlayerAppDelegate UpdatePlayer] + 326
     20  Foundation                          0x95a8f1e6 __NSFireTimer + 97
     21  CoreFoundation                      0x9426a996 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 22
     22  CoreFoundation                      0x9426a4ad __CFRunLoopDoTimer + 1213
     23  CoreFoundation                      0x94269f4e __CFRunLoopDoTimers + 350
     24  CoreFoundation                      0x94261910 __CFRunLoopRun + 2192
     25  CoreFoundation                      0x94260e1a CFRunLoopRunSpecific + 506
     26  CoreFoundation                      0x94260c0b CFRunLoopRunInMode + 123
     27  HIToolbox                           0x93954396 RunCurrentEventLoopInMode + 268
     28  HIToolbox                           0x93954182 ReceiveNextEventCommon + 494
     29  HIToolbox                           0x93953f7b _BlockUntilNextEventMatchingListInModeWithFilter + 83
     30  AppKit                              0x91f86015 _DPSNextEvent + 1227
     31  AppKit                              0x926ebbbb -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1742
     32  AppKit                              0x926eb4e5 -[NSApplication(NSEvent) nextEventMatchingMask:untilDate:inMode:dequeue:] + 132
     33  AppKit                              0x91f7acb6 -[NSApplication run] + 943
     34  AppKit                              0x91f47d1e NSApplicationMain + 1368
     35  io 120817 ELtestbuild32 nobreak DEV 0x0133bf1b _Z10PlayerMainiPPKc + 1371
     36  io 120817 ELtestbuild32 nobreak DEV 0x000029f5 start + 53
 
 Debug info from gdb:
 
 
 =================================================================
 Got a SIGABRT while executing native code. This usually indicates
 a fatal error in the mono runtime or one of the native libraries
 used by your application.
 =================================================================
« Last Edit: December 12, 2017, 08:02:55 PM by twerkface »

twerkface

  • Playmaker Newbie
  • *
  • Posts: 8
Re: help with debugging/avoiding null reference error
« Reply #1 on: December 13, 2017, 08:54:26 PM »
Anyone? I know it's a lot :-[

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: help with debugging/avoiding null reference error
« Reply #2 on: December 14, 2017, 01:46:08 AM »
Hi,

 yep, that's tricky. It's typically something you can only debug with the following:

- make a copy of your project, and work on debugging on that copy until you found out exactly what's wrong.
- turn features either all off and enable them one by one until it crashes then you know which feature it the problem or turn feature off one by one, either way.
- once you know what is the fsm that causes the trouble, then you need to check which action or sequence is the issue, with this you will need to pause and step forward until you can figure our, if it's a loop, you will see this as you constanly keep getting into the same cycle, else it will crash at one particular step as you enter a new state.

 Let me know how this goes. Yes this is painfull :) I have been there many time :)


also, it helps trying to soft debug by simply go over each fsm and logic and think hard about what it does and what could be wrong here, typically maybe you are trying to access a gameobject instance that is not there anymore, or something like that.

 Bye,

 Jean

twerkface

  • Playmaker Newbie
  • *
  • Posts: 8
Re: help with debugging/avoiding null reference error
« Reply #3 on: December 15, 2017, 06:51:43 PM »
Jean, thank you for this message! It’s quite motivating and I’ll do my best :)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: help with debugging/avoiding null reference error
« Reply #4 on: December 18, 2017, 02:39:00 AM »
Hi,

:)
 you'll gain experience with this and it will become easier and easier. Also alwasy try to really think hard before tearing apart your code, being able to analyze your logic and find flaws is really the best and most rewarding skills you can get, people that only rely on the script debugger or turning everthing off usuallty never learn anything from this ( as well as it being very tedious...)

so try to find a set of repro steps and pause the game before and step in slowly to the issue for example, this might help.


 bye,

 Jean