gApplicationObject error

Recently I get this error with one of my bigger projects. The app launches fine but does give this error at random - even when doing nothing.

If you can reproduce it, I’d love to look at fixing it.

Well, thats the problem. I have about 10 users (there are about 12000 registered users for that app) that reported this issue but we cannot reproduce this ourself.
So it seems to be rare but it is rather strange some are reporting this.

Any direction I need to look at?

BTW they cannot provide me a step-by-step how to reproduce because it happens at random.

Maybe the sam as in Feedback 31518?

Well, the error is the same.
In the meantime I got another user reporting this. :-/

@Joe:
Please give me some direction to look at.

It might be Timer or Thread related: a Timer or Thread function accessing a property or method of App when the application has actually already closed.

The app uses a lot of timers and threads but none do change something when quitting the app.
Also, the error is shown even when no timer or threads are running.

Of course not, but what if a Timer or Thread is still running for some reasons without you knowing.

An example which happend to me a few years ago was an instance of a Thread subclass staying alive in memory because of an “unfreeable” resource (an open file where the user removed the USB-stick without properly ejecting it). On closing the application the Thread was still running because me setting it to Nil had no effect due to the open file.

This assertion is triggered when a window’s menubar is set, which can happen explicitly via your code or implicitly when creating a window. It’s essentially asserting that there still is a valid application object, which there really should be.

There’s only two ways I can think of for the global application object to be set to null. The first is quitting the application, which will trigger the application object’s destructor before tearing down the rest of the state. The second is memory corruption and something managing to overwrite the application object in memory.

The first is fairly easy to test for: just put some code in the app’s destructor and see if it fires when it shouldn’t. The second is difficult to test for and I don’t have any immediate ideas.

Well, this could be the issue. I launch a unix app in the shell that can consume a lot of memory. Maybe a shell has a limit in memory allocation?