Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AI crash VM crash openttd #5068

Closed
DorpsGek opened this issue Feb 16, 2012 · 5 comments
Closed

AI crash VM crash openttd #5068

DorpsGek opened this issue Feb 16, 2012 · 5 comments
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)

Comments

@DorpsGek
Copy link
Member

krinn opened the ticket and wrote:

i have a bug in my AI that let the VM crash and openttd then segfault.

note that this was test with 1.1.3 and 1.1.4
i will attach crash.log and my current AI version (you need to disable trains in order to let it work, else the AI might stop working by itself as that part is unfinished).

Step to reproduce: run a map with it, and wait (use fastforward to help)

Attachments

Reported version: Version?
Operating system: All


This issue was imported from FlySpray: https://bugs.openttd.org/task/5068
@DorpsGek
Copy link
Member Author

TrueBrain wrote:

Can you reproduce the problem in 1.1.5? (which was one of the key points I asked you about :D)


This comment was imported from FlySpray: https://bugs.openttd.org/task/5068#comment10899

@DorpsGek
Copy link
Member Author

krinn wrote:

crash.log from 1.1.5

I've done more testing, looks like the custom valuator might crash it, will dig that more to confirm. Maybe not returning a correct value (should be integer no?), currently the return value could be null.

local RoadBridgeList=AIList();
RoadBridgeList.AddList(cBridge.BridgeList);
RoadBridgeList.Valuate(cBridge.GetMaxSpeed); <---

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/5068#comment10901

@DorpsGek
Copy link
Member Author

krinn wrote:

finally found it : bad recursive calling, VM goes oom or something.
function cBridge::Load(bUID)
// Load a bridge object, and detect if we have an UID or a tile gave
{
print("cBridge::Load");
local cobj=cBridge();
if (AIMap.IsValidTile(bUID))
{
cobj.bridgeUID=cBridge.GetBridgeUID(bUID);
if (cobj.bridgeUID!=null) cobj.firstside=bUID;
bUID=cobj.bridgeUID;
}
else cobj.bridgeUID=bUID;
if (bUID in cBridge.bridgedatabase) { cobj=cBridge.GetBridgeObject(bUID); cBridge.CheckBridge(bUID); } <<--- cBridge.CheckBridge(bUID) call cBridge.Load
else cobj.Save(); // we will not save a null bridgeUID
return cobj;
}

function cBridge::CheckBridge(bUID)
// Check if the bridge need an update of its infos
{
local cobj=cBridge.Load(bUID);
local validstart=cBridge.IsValidTile(cobj.firstside);
local validend=cBridge.IsValidTile(cobj.otherside);
if (!validstart || !validend)
{
DInfo("Bridge infos aren't valid anymore, bridge has moved ?",2,"cBridge::CheckBridge");
cBridge.DeleteBridge(bUID);
cobj.Save(); // try to save it again, the Save function will seek who is valid and who's not
}
}

That should solve my AI crashing part :)
Still remain the VM/openttd way to handle such issue.


This comment was imported from FlySpray: https://bugs.openttd.org/task/5068#comment10902

@DorpsGek
Copy link
Member Author

Rubidium wrote:

So this problem seems to be (is?) caused by (infinite) recursion, right? Then we should figure out what level of recursion we want to terminate an AI. Likewise maybe also for the number of operations executed within a valuate call.


This comment was imported from FlySpray: https://bugs.openttd.org/task/5068#comment10904

@DorpsGek
Copy link
Member Author

Rubidium closed the ticket.

Reason for closing: Fixed

In r23962


This comment was imported from FlySpray: https://bugs.openttd.org/task/5068

@DorpsGek DorpsGek added Core flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) labels Apr 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)
Projects
None yet
Development

No branches or pull requests

1 participant