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

Crash when using vehicle var 4C #5398

Closed
DorpsGek opened this issue Dec 19, 2012 · 5 comments
Closed

Crash when using vehicle var 4C #5398

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

Comments

@DorpsGek
Copy link
Member

Pikka opened the ticket and wrote:

r24825

When attempting to create a test grf for http://bugs.openttd.org/task/5397 , OpenTTD crashed. The game crashed after starting a new game, building a depot, opening the depot window and attempting to build the test vehicle.

When I comment the following pseudosprite out of the grf, the game does not crash and the vehicle builds as expected:

23 * 18 02 00 11 82 4C 20 FF \2- B4 00 FF 01 // 4c speed - our speed
11 00 00 00 // our speed = 4C speed, green
12 00 // otherwise, red

If I replace 4C (Current max speed including e.g track or timetable speed limits) with the older var 98 (Maximum speed of the vehicle), the grf runs as expected, with no crash.

Similar constructions now using 4C exist in UKRS2, and do not crash, eg;

9189 * 18 02 00 05 82 4C 20 FF \2- B4 00 FF 01 7b 80 00 0C 7c 80 //running

However, all uses of var 4C (and previously of var 98) in UKRS2 happen within callback chains, if that's important.

Attached are the test grf, the sources, and the crash log.

Attachments

Reported version: trunk
Operating system: All


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

Pikka wrote:

and the dump

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/5398#comment11766

@DorpsGek
Copy link
Member Author

glx wrote:

KERNELBASE.dll!RaiseException�() Inconnu
openttd.exe!raise(int signum) Ligne 593 C
openttd.exe!abort() Ligne 81 C
openttd.exe!error(const char * s, ...) Ligne 120 C++
openttd.exe!Train::GetCurrentMaxSpeed() Ligne 376 C++
openttd.exe!VehicleGetVariable(Vehicle * v, const VehicleScopeResolver * object, unsigned char variable, unsigned int parameter, bool * available) Ligne 628 C++
openttd.exe!VehicleScopeResolver::GetVariable(unsigned char variable, unsigned int parameter, bool * available) Ligne 906 C++
openttd.exe!DeterministicSpriteGroup::Resolve(ResolverObject * object) Ligne 244 C++
openttd.exe!GetVehicleCallback(CallbackID callback, unsigned int param1, unsigned int param2, unsigned short engine, const Vehicle * v) Ligne 1073 C++
openttd.exe!GetVehicleProperty(const Vehicle * v, PropertyID property, unsigned int orig_value) Ligne 1103 C++
openttd.exe!Train::ConsistChanged(bool same_length) Ligne 154 C++
openttd.exe!CmdBuildRailVehicle(unsigned int tile, DoCommandFlag flags, const Engine * e, unsigned short data, Vehicle * * ret) Ligne 724 C++
openttd.exe!CmdBuildVehicle(unsigned int tile, DoCommandFlag flags, unsigned int p1, unsigned int p2, const char * text) Ligne 125 C++
openttd.exe!DoCommandPInternal(unsigned int tile, unsigned int p1, unsigned int p2, unsigned int cmd, void (const CommandCost &, unsigned int, unsigned int, unsigned int) * callback, const char * text, bool my_cmd, bool estimate_only) Ligne 689 C++
openttd.exe!DoCommandP(unsigned int tile, unsigned int p1, unsigned int p2, unsigned int cmd, void (const CommandCost &, unsigned int, unsigned int, unsigned int) * callback, const char * text, bool my_cmd) Ligne 550 C++
openttd.exe!BuildVehicleWindow::OnClick(Point pt, int widget, int click_count) Ligne 1256 C++
openttd.exe!DispatchLeftClickEvent(Window * w, int x, int y, int click_count) Ligne 514 C++
openttd.exe!MouseLoop(MouseClick click, int mousewheel) Ligne 2571 C++
openttd.exe!HandleMouseEvents() Ligne 2653 C++
openttd.exe!WndProcGdi(HWND__ * hwnd, unsigned int msg, unsigned int64 wParam, int64 lParam) Ligne 497 C++
user32.dll!UserCallWinProcCheckWow�() Inconnu
user32.dll!DispatchMessageWorker�() Inconnu
openttd.exe!VideoDriver_Win32::MainLoop() Ligne 977 C++
openttd.exe!ttd_main(int argc, char * * argv) Ligne 849 C++
openttd.exe!WinMain(HINSTANCE * hInstance, HINSTANCE
* hPrevInstance, char * lpCmdLine, int nCmdShow) Ligne 465 C++
openttd.exe!__tmainCRTStartup() Ligne 275 C
kernel32.dll!BaseThreadInitThunk�() Inconnu
ntdll.dll!RtlUserThreadStart�() Inconnu


This comment was imported from FlySpray: https://bugs.openttd.org/task/5398#comment11767

@DorpsGek
Copy link
Member Author

michi_cc wrote:

It's triggering "assert(max_speed == this->GetCurveSpeedLimit());" in Train::GetCurrentMaxSpeed() as the cached curve speed is only updated at the end of ConsistChanged.

Using var 98 works as it directly accesses the speed cache without any checks. It will not return the correct value as far as I can see though. Because of that it might make sense to simply drop the assert and accept the wrong return value. GetCurrentMaxSpeed is used in acceleration calculations, so always calling to GetCurveSpeedLimit is probably unwise.


This comment was imported from FlySpray: https://bugs.openttd.org/task/5398#comment11768

@DorpsGek
Copy link
Member Author

michi_cc wrote:

Easiest fix :)

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/5398#comment11769

@DorpsGek
Copy link
Member Author

michi_cc closed the ticket.

Reason for closing: Fixed

In r24831.


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

@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