Freezes I can't identify why or where?

Mac OSX specific forum
jesperbrannmark
Enthusiast
Enthusiast
Posts: 536
Joined: Mon Feb 16, 2009 10:42 am
Location: sweden
Contact:

Freezes I can't identify why or where?

Post by jesperbrannmark »

Hi.
When I run in cocoa in the newer versions - 5.0, 5,1.. I get a lot of freezes of my program.
No error... nothing in the debugger that makes me identify why... no cpu or memory usage to tell me whats going on.
It happens more often if I don't have my main window as active window during startup (like if I check my mail while the program starts).
I can run the same code several times (without recomplile) and it freezes at different places in the program.
How can I find what is causing the problem? Is there any specific tools? Is there any more advanced logging?
I am not getting any errors at all..
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3944
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Freezes I can't identify why or where?

Post by wilbert »

Is cpu load close to 0 or 100 ?
To monitor cpu load and memory usage, you can use PureMonitor
http://www.purebasic.fr/english/viewtop ... 27&t=53285
Windows (x64)
Raspberry Pi OS (Arm64)
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Freezes I can't identify why or where?

Post by IdeasVacuum »

It could be that your Anti Virus is interupting it.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Re: Freezes I can't identify why or where?

Post by Polo »

Have you tried removing the code on SizeWindow event just to check?
jesperbrannmark
Enthusiast
Enthusiast
Posts: 536
Joined: Mon Feb 16, 2009 10:42 am
Location: sweden
Contact:

Re: Freezes I can't identify why or where?

Post by jesperbrannmark »

Hi.
No CPU use (from activity monitor), or just a tiny bit like 0.1% ...
No Antivirus
Resize - I dont even come so far in the code.
Most of the time it looks up on login screen (enter password etc), sometimes after a couple of characters - sometimes after pressing login and a progressbar is indicating where we are in login process.. sometimes when main window comes up and the webgadget show "what today look like" - sometimes when clicking a button - sometimes not at all.

it would have been so much easier if it was at a specific point every time... but it is not... so i really need some more in depth monitor (like the good old action replay cartridge on the amiga). It must be something in PB that is doing this, the question is what and why.
The code is to big to just cut out code and see when the problem stops.
jesperbrannmark
Enthusiast
Enthusiast
Posts: 536
Joined: Mon Feb 16, 2009 10:42 am
Location: sweden
Contact:

Re: Freezes I can't identify why or where?

Post by jesperbrannmark »

I removed all use of threads. This happens regardsless of debugger or if its a production executable.
It will freeze or crash and can do so on either;
1. First webgadget (most common crash) on the waitwindowevent (like in http://www.youtube.com/watch?v=cpXq5YnD3mE&t=0m52s or http://www.youtube.com/watch?v=cpXq5YnD3mE&t=1m05s )
2. First window everything just stops - no crash but have to force quit. No keyboard input working and just the rainbow wheel mouse (like in http://www.youtube.com/watch?v=cpXq5YnD3mE&t=0m39s )
3. Random place some time in the program, with either the rainbow wheel OR the crash on waitwindowevent.

How can I debug this? Is there a trick? It has been in v5 and newer using cocoa... but also sometimes with carbon but not so frequent...
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3944
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Freezes I can't identify why or where?

Post by wilbert »

It's hard to tell if you have no code to test with.
Personally I haven't encountered this. It could have to do with memory management.
The Cocoa version of PureBasic uses an autorelease pool so allocated memory that isn't used anymore is released not immediately but at certain points in time.
Have you monitored the amount of memory your application consumes ?

Crashes on WaitWindowEvent could also be a PureBasic bug.
As far as I know (Fred can correct me if I'm wrong), WaitWindowEvent is the place where the items in the autorelease pool are released.
If something in there was already released manually (caused by a bug), the application can crash when it tries to release an object for the second time.
Windows (x64)
Raspberry Pi OS (Arm64)
jesperbrannmark
Enthusiast
Enthusiast
Posts: 536
Joined: Mon Feb 16, 2009 10:42 am
Location: sweden
Contact:

Re: Freezes I can't identify why or where?

Post by jesperbrannmark »

The memory usage is what to expect. Sometimes it bounces up high, but not with these crashes. The thing is the compiled program itself is just getting started upon the crashes and it seems it doesnt matter much what I do with my code (I have a errorhandler installed but its not being called ever upon these crashes or if it it gives a BUS error or a Segment Violation error or at best a IMA and the code line never tells any insight to the real problem).

I think it has nothing to do with WaitWindowEvent. In the back of my head I think this is something in a thread created by a library in PB. Like maybe network library or sprites library does something in a seperate thread and if there is a problem in a thread usually it crashes on waitwindowevent.
The problem is I have no tools to check WHAT is the real problem here. I am sure my code is crappy, no doubt about it, but the problem occurs because of something in PB since V5... Is there any way of compiling the code and running via Xcode debugger somehow? I cant redistribute the code to everyone since its my commercial project and I cant just cut out a piece of code that gives the error so I have to have the whole thing.
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3944
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Freezes I can't identify why or where?

Post by wilbert »

With XCode comes a tool named Instruments. That might help you.
Once you have your application compiled with PureBasic, you can use it to monitor a lot of things.
Windows (x64)
Raspberry Pi OS (Arm64)
User avatar
J. Baker
Addict
Addict
Posts: 2196
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: Freezes I can't identify why or where?

Post by J. Baker »

Are you working with a window screen and mouse events?
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
jesperbrannmark
Enthusiast
Enthusiast
Posts: 536
Joined: Mon Feb 16, 2009 10:42 am
Location: sweden
Contact:

Re: Freezes I can't identify why or where?

Post by jesperbrannmark »

Hi.
Yes i work with window event, both NewEventHandlerUPP_ (carbon) and currentEvent = oMsg(0, sharedApplication, "currentEvent") (cocoa) - but that comes later in the program. The crash (usually) occurs way before this.
User avatar
J. Baker
Addict
Addict
Posts: 2196
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: Freezes I can't identify why or where?

Post by J. Baker »

The reason I asked about mouse in a screen is because my test app locked up when I tried to open another app while the test app was running. See this...
http://www.purebasic.fr/english/viewtop ... 96#p394396
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
jesperbrannmark
Enthusiast
Enthusiast
Posts: 536
Joined: Mon Feb 16, 2009 10:42 am
Location: sweden
Contact:

Re: Freezes I can't identify why or where?

Post by jesperbrannmark »

Aha, no i am not using examinemouse... i use windowmousex/y only.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Freezes I can't identify why or where?

Post by IdeasVacuum »

Do you have your app running on Windows too? If not, it would be worth trying it.

For Windows apps, NirSoft have a number of handy tools. This one http://www.nirsoft.net/utils/what_is_hang.html could be useful.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Post Reply