Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  
RazTK

Alias Crash

Recommended Posts

If you type something like: alias "test" "echo ...;test"
and then type test at the console, the game will crash out.

Share this post


Link to post

Somehow I get the feeling that this is a clear-cut case of "Don't Do That." What you're doing is an infinite loop without any sort of wait times in between loops, which typically will steal CPU cycles because there is no room for the CPU to "breathe."

Thankfully, Eternity doesn't allow this sort of thing to happen and just crashes out when such a thing is encountered.

Share this post


Link to post

WildWeasel is right. I took a look at this in the debugger and it is causing a stack overflow, meaning that the function C_RunTextCmd is indirectly executing itself in an infinite fashion as it tries to expand the macro over and over. There's no simple way to prevent this due to the structure of the code without completely forbidding an alias to contain the same text as its own name. This would artificially limit what can be done with aliases in some cases, however.

Share this post


Link to post

It's crashing even if I do: alias "test" "echo ...;delay 1000;test"
I thought Eternity can handle that.

Share this post


Link to post

I'd assume the alias expansion occurs before the command is executed. I don't know though. It's entirely possible that the delay command doesn't work right; it is a feature from SMMU that I have never tested. Anyways, all of this stuff will get sorted out if/when possible.

Share this post


Link to post

I figured this problem when I tried to do this kind of script:

alias "autosummon" "start"
alias "start" "alias ss ss2;alias autosummon stopsummon;ss2"
alias "stopsummon" "alias ss stops;alias autosummon start"
alias "ss2" "summon doombarrel;delay 1;ss"
alias "stops" "echo Stopped"

Share this post


Link to post

The problem is that console commands are not interpreted anything like scripts; they are parsed and each command is run consecutively, back to back. Delays may be queued up between the commands as they are buffered, but the entire command must be parsed immediately. That means that alias resolving is not deferred to the time of command execution. That's why recursive aliases cause stack overflow.

I think I see what you're trying to do, and I don't think it'll work with the way the console currently functions. As you may or may not know depending on whether you've read the Eternity changelog and stuff in here, the entire console is way overdue for a rewrite. I don't know when or how it will happen, but it WILL happen eventually.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
×