Simple function chain crashes studio (solved)

I’ve been working on an update on my first plugin for quite a while now. I’ve constantly deleted-saved it locally to test changes and methods for various parts of this system with no issue.
First, my friend’s studio started crashing when he tested it as a local plugin; after pressing a specific button. I’ve updated the actual plugin, and now it crashes for me too.

The issue is, that I’ve reviewed the chain of functions that crashed our studio, and looked at studio logs and found nothing that would be suspicious, so I’ve no clue what causes a crash.

Anyway, the procedure is as follows:

  1. the user presses a button, that triggers an initial event function:
  1. The “ResetButton” module applies a few properties based on predefined conditions. In this case, it will run through the entire module.
  1. Lastly, a second module that simply finds an object from a name and classname. Note that the if statement after line 21 is useless, but I didn’t remove it yet.

Please help me find what’s causing crash, I have no clue!
thanks!!

1 Like

Do you get any type of error message when studio crashes or does it just disappear immediately?

Nothing really jumps out at me when looking at these code snippets. If you’re not seeing a callstack in the studio logs, the best suggestion I can give is to narrow down what exactly is causing the issue by commenting out code here and there.

Nothing at all, just freezes/crashes completely. Tracing back debug logs, there was nothing displayed on the output other than a message that’s a status update on the plugin and some studio things afterwards.

I have a suspicion that the “recovery” code is what’s actually causing issue, either way I’m trying to optimize now.

Hmm… if it’s freezing and blocking UI interaction, that makes me thing there’s some infinite loop happening or possibly a stack overflow from some recursive event happening. I don’t immediately see how/where that could be happening in your code, but it’s hard to say without knowing the full context of the code.

Sorry I can’t really help with this.

Edit: I just tested a never ending recursive function and a stack overflow did happen, but it didn’t crash studio. However I also ran a while true loop and that studio freeze. So that might be what’s happening.

2 Likes

If you comment out big sections of it, then gradually add back the code, testing each time you readd the code, you should be able to narrow down which part of the code is causing the crash to occur.

2 Likes

I reviewed my code again, revealing a few mistakes that indeed causes a memory leak by recursively calling module functions back and forth. I have rewrote a few functions and merged 1-2 modules in an attempt to fix the issue.

I can’t really say results yet, since it raised other errors in other parts of the plugin. I’ll be able to post an update once I manage to troubleshoot them

1 Like

What my mistake was, well, first of all bad module implementation. I didn’t realize at first that the first parameter that the “GrabParent” module receives is the requested button itself, so it just created an infinite loop of back-and-forth calling of the same 2 modules.

Thank you for the advice, I began to break down what happens step by step when the button is clicked, and that’s how I realized my mistake.

What I did at the end is:

  • Merged the “GrabParent” module with a script function to make it simpler
  • Removed the recovery code (it was an impossible scenario)
  • Reviewed and fixed the “ResetButton” module so it doesn’t stop on the first iteration

It doesn’t crash now. Thanks for your help!

1 Like

Nice. Glad you were able to figure it out :slight_smile:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.