AutoHotkey Community

It is currently May 27th, 2012, 4:59 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Max calling level?
PostPosted: October 10th, 2005, 1:52 pm 
Offline

Joined: October 3rd, 2005, 2:42 am
Posts: 186
From: http://www.autohotkey.com/forum/viewtopic.php?p=34830
Quote:
...the following should die gracelessly:
Code:
#t::
clipboard = 1
CrashMe()

CrashMe()
{
  clipboard := clipboard + 1
  CrashMe()
}
*tries it* Yup, there we go:
Quote:
Program Error
AutoHotkey.exe has generated errors and will be closed by Windows. You will need to restart the program.

An error log is being created.
I guess Chris could avoid this by setting a max calling level, beyond which threads would die with a popup, rather than kill the whole script. Using the above code, it looped 160 times on my system before dying (or at least, I had the value 160 in my clipboard after the crash).


So, yeah, that'd be a kindof nice feature to have: just a popup to say "maximum number of nested function calls reached, stack usage dangerously high, terminating the thread but leaving ahk still running so that your hotkeys still work.".

And maybe add "Would you like to disable the hotkey that caused this? Y/N".

If there's some kindof windowsy magic that could be used to automagically detect when the stack was running out, that'd be best, but otherwise, maybe a default to something like 100 or 150, user-definable with #MaxNesting or something. Which has the advantage that they can allow themselves to crash if they want to.

_________________
Yet another hotkeyer.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 11th, 2005, 11:08 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
This is already on the to-do list, so I'll add the details of your ideas to my notes.

One thing I don't like about this is its impact in performance. The simple act of checking and incrementing a variable for every Gosub and Function-call (then decrementing the same upon Return) might decrease performance by 2% or more depending on the nature of the script (e.g. a math intensive script whose subroutines are very fast).

But I'll certainly benchmark it when the time comes to make sure the benefit is worth the cost.

Thanks.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: LazyMan and 2 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group