FS#332 - Vehicle Deletion Crash [News Window Related?]

Attached to Project: OpenTTD
Opened by PandaMojo (PandaMojo) - Tuesday, 05 September 2006, 11:52 GMT
Last edited by Darkvater (Darkvater) - Thursday, 02 November 2006, 15:55 GMT
Type Bug
Category Interface
Status Closed
Assigned To No-one
Operating System Windows
Severity High
Priority Normal
Reported Version trunk
Due in Version 0.5.0
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


Bug occurs in R6392. It's somewhat difficult to reproduce. I've attached the savegame being affected by it.

The steps I've followed to cause the crash (does not always reproduce the behavior):
1) Select various buses at Cunnigton that are no longer needed (their routes were shortened, and now queue large amounts)
2) U-Turn them then "Send to Depot" to get them out of their queue. I keep their windows *open*.
3) Once they start to arrive at the depots, I start deleting them. In my experience there's about a 20% chance of reproducing it per attempt. I usually do this to 2-4 buses at a time, deleting as they arrive.
4) Crash occurs during one of the buses deletion.

I have not reproduced the bug in debug mode or with a newer/smaller savegame, nor narrowed down the exact cause. I have reproduced it in release mode with Visual Studio 2005's debugger attached.

Crash details: Occurs around DrawWindowViewport due to the window w (which is within _windows and _last_window, so presumibly valid) having a null viewport (causing ViewportDraw to crash presumably, although it is not shown in the release mode stack trace). Of note is w->wndproc == NewsWindowProc, so I'm guessing DestroyVehicleNews (or was that Delete?) as called by DeleteVehicle (or Destroy, if the other one was Delete) isn't working properly, or something is messed up with the FIFO news queue. Either way I'm at a loss.
This task depends upon

Closed by  Darkvater (Darkvater)
Tuesday, 05 December 2006, 12:17 GMT
Reason for closing:  Fixed
Additional comments about closing:  Fixed in SVN
Comment by PandaMojo (PandaMojo) - Friday, 08 September 2006, 07:08 GMT
I think I just uncovered this bug in another manner as well - I had no bugger attached so I was unable to interpret the stack at the time but it occured in a similar manner - A coal train was created, and after the first trial run I noticed it needed a second engine. So I sent it to depot, created the second train, dragged it over (thus removing "Train 2" since it's only engine was now in "Train 1")... boom, crash. Found where the crash savegames are put - unfortunately the game runs fine right afterwards. Odd note - said train immediately left the depot in said savegame, whereas it had been ordered to stay in the depot.

The game had just recently started, which gives me more hope of being able to reproduce it and debug it, since I can run smaller games decently in debug mode.
Comment by Darkvater (Darkvater) - Tuesday, 31 October 2006, 02:32 GMT
I had a crash with it as well, about 'invalid string'. It was even without doing any vehicle deletions. I think it might be related to the borked windowing system. I will try a fix for that and see if these things still happen.

The othe thing might of course be the news-system, have not looked into it yet, what it would do with invalid, or out-of-date news-items.