Security change for AIs

An area for discussing new ideas and additions to Oolite.

Moderators: winston, another_commander

Post Reply
Screet
---- E L I T E ----
---- E L I T E ----
Posts: 1883
Joined: Wed Dec 10, 2008 3:02 am
Location: Bremen, Germany

Security change for AIs

Post by Screet »

Hi,

I've found some troubles with oxp's that did use setAI recently. It's easy to make a subtle mistake and not be aware of it, thus I'd like some security change in oolite to prevent problems:

1) When a request is made to switch/set AI from AI A to AI A then simply change that AI state and probably also add a warning message to the log.
2) When circular AI requests are made (like AI A to AI B to AI A) then fall back to the requested AI which was suspended and exit the others. Also change that targets AI state and probably also add a warning message to the log.

I guess both cases can even be handled by one check if the check keeps both cases in mind. Furthermore, for case 2 it would be very difficult to prevent this from inside an oxp.

That would prevent unnecessarily growing AI stacks and AI overflow problems. Maybe that way the current AI limit could even be drastically reduced (if that helps in some way).

Screet
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

I’m not clear on what problem you want to solve.
Last edited by JensAyton on Sat Oct 24, 2009 1:48 pm, edited 1 time in total.
Screet
---- E L I T E ----
---- E L I T E ----
Posts: 1883
Joined: Wed Dec 10, 2008 3:02 am
Location: Bremen, Germany

Post by Screet »

Ahruman wrote:
I’m not clear on what problem you want to solve.[/list]
The AI overflow problem. Some missiles do change the AI - and previously this did cause trouble when too many missiles did hit the same target. I've fixed that oxp by checking if that AI is already active - then nothing happens. However, this is no good fix: Multiple hits by different missiles cannot be detected this way. Other scripts also do change the AI, adding up to the AI stack.

Furthermore, if an AI itself does call another AI and that again calls another AI, it's also not possible to stay safe in a proper way, as it's difficult from outside oolite to determine wether the AI to change to is already somewhere further down in the stack.

That's why I asked to add a safety check to that functionality within the Oolite code: if the requested AI is already on the stack somewhere, simply go back to that one.

Screet
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

Or just set a maximum size to the AI stack, and report an error if it's exceeded? Or simply teach people better the difference between setAI and switchAI?
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

Thargoid wrote:
Or just set a maximum size to the AI stack, and report an error if it's exceeded?
Oolite already does this.
Screet
---- E L I T E ----
---- E L I T E ----
Posts: 1883
Joined: Wed Dec 10, 2008 3:02 am
Location: Bremen, Germany

Post by Screet »

Ahruman wrote:
Thargoid wrote:
Or just set a maximum size to the AI stack, and report an error if it's exceeded?
Oolite already does this.
But that won't help to avoid the situation. IIRC L once got that error and had a massively spammed log.

Screet
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post by Eric Walch »

Screet wrote:
Ahruman wrote:
Thargoid wrote:
Or just set a maximum size to the AI stack, and report an error if it's exceeded?
Oolite already does this.
But that won't help to avoid the situation. IIRC L once got that error and had a massively spammed log.

Screet
But it is logged, so the scripter knows there is probably something wrong and he can correct it. I think the maximum stack size is about 32. Sounds high enough for me as a normal script would never put that many AIs on stack.
User avatar
Kaks
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 3009
Joined: Mon Jan 21, 2008 11:41 pm
Location: The Big Smoke

Post by Kaks »

To reiterate, the spammed log is due to some logic fault within the OXP code.
Once that OXP code is fixed, you'd get no more spamming & no more potential overflow.

As if by magic! ;)
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
Post Reply