OpenRCT2 / OpenRCT2

An open source re-implementation of RollerCoaster Tycoon 2 🎢
https://openrct2.io
GNU General Public License v3.0
13.54k stars 1.56k forks source link

Trying to rename a Multi-Dimension coaster causes a crash #914

Closed ArDee20p closed 9 years ago

ArDee20p commented 9 years ago

On build 490, probably with other builds as well, the game will CTD whenever I try to rename a Multi-Dimension coaster that still has its default name. I'm guessing it has something to do with the hyphen, since this doesn't happen with any pre-built 4D coaster designs. (e.g. "X")

Gymnasiast commented 9 years ago

Renaming a Multi-Dimension coaster that still has its default name indeed crashes the game:

schermafdruk van 2015-03-15 09 31 23

The dump contents are as follows:

Unhandled exception: page fault on write access to 0x1013a000 in 32-bit code (0x10097bea).
Register dump:
 CS:0023 SS:002b DS:002b ES:002b FS:0063 GS:006b
 EIP:10097bea ESP:0032fc04 EBP:0032fc78 EFLAGS:00010287(  R- --  I S - -P-C)
 EAX:100ef3ce EBX:00000601 ECX:fffb53cd EDX:fffffffe
 ESI:1013a001 EDI:1013a000
Stack dump:
0x0032fc04:  00000000 40000110 10034978 100ef3cf
0x0032fc14:  100ef3d0 fffffffe 00000300 00028f10
0x0032fc24:  00000001 00000001 0000002a 00000008
0x0032fc34:  00001000 00000000 00000000 00000000
0x0032fc44:  00000000 00000000 00000000 00000000
0x0032fc54:  0032fc78 6c80f3b0 729ae800 00000186
Backtrace:
=>0 0x10097bea in openrct2 (+0x97bea) (0x0032fc78)
  1 0x10013924 in openrct2 (+0x13923) (0x0032fc8c)
  2 0x100138a4 in openrct2 (+0x138a3) (0x0032fdac)
  3 0x10035772 in openrct2 (+0x35771) (0x0032fdc0)
  4 0x004069e4 in openrct2 (+0x69e3) (0x0032fe60)
  5 0x7b861d8c call_process_entry+0xb() in kernel32 (0x0032fe78)
  6 0x7b86588b in kernel32 (+0x5588a) (0x0032feb8)
  7 0x7bc7d970 call_thread_func_wrapper+0xb() in ntdll (0x0032fed8)
  8 0x7bc7dbcd call_thread_func+0x7c() in ntdll (0x0032ffa8)
  9 0x7bc7d94e RtlRaiseException+0x21() in ntdll (0x0032ffc8)
  10 0x7bc53ebe in ntdll (+0x43ebd) (0x0032ffe8)
0x10097bea: repe movsb  (%esi),%es:(%edi)
Modules:
Module  Address         Debug info  Name (124 modules)
PE    400000- 14b6000   Export          openrct2
PE  10000000-10142000   Export          openrct2
PE  6c740000-6c83f000   Deferred        sdl2
ELF 7b800000-7ba4b000   Dwarf           kernel32<elf>
  \-PE  7b810000-7ba4b000   \               kernel32
ELF 7bc00000-7bcd0000   Dwarf           ntdll<elf>
  \-PE  7bc10000-7bcd0000   \               ntdll
ELF 7bf00000-7bf03000   Deferred        <wine-loader>
ELF 7c61d000-7c64c000   Deferred        msctf<elf>
  \-PE  7c620000-7c64c000   \               msctf
ELF 7ce4d000-7ce7b000   Deferred        libvorbis.so.0
ELF 7ce7b000-7cf0a000   Deferred        libvorbisenc.so.2
ELF 7cf0a000-7cf42000   Deferred        libflac.so.8
ELF 7cf42000-7cfb3000   Deferred        libsndfile.so.1
ELF 7cfb3000-7d02a000   Deferred        libpulsecommon-4.0.so
ELF 7d02a000-7d120000   Deferred        libasound.so.2
ELF 7d20c000-7d215000   Deferred        libogg.so.0
ELF 7d215000-7d21c000   Deferred        libasyncns.so.0
ELF 7d21c000-7d272000   Deferred        libpulse.so.0
ELF 7d28b000-7d293000   Deferred        libasound_module_pcm_pulse.so
ELF 7d2a1000-7d2ce000   Deferred        winealsa<elf>
  \-PE  7d2b0000-7d2ce000   \               winealsa
ELF 7d2ce000-7d2ee000   Deferred        mmdevapi<elf>
  \-PE  7d2d0000-7d2ee000   \               mmdevapi
ELF 7d334000-7d364000   Deferred        p11-kit-trust.so
ELF 7d364000-7d36d000   Deferred        libffi.so.6
ELF 7d36d000-7d384000   Deferred        libresolv.so.2
ELF 7d384000-7d3da000   Deferred        libdbus-1.so.3
ELF 7d3da000-7d465000   Deferred        libgmp.so.10
ELF 7d465000-7d494000   Deferred        libhogweed.so.2
ELF 7d494000-7d4c9000   Deferred        libnettle.so.4
ELF 7d4c9000-7d4dc000   Deferred        libtasn1.so.6
ELF 7d4dc000-7d518000   Deferred        libp11-kit.so.0
ELF 7d518000-7d525000   Deferred        libkrb5support.so.0
ELF 7d525000-7d557000   Deferred        libk5crypto.so.3
ELF 7d557000-7d62b000   Deferred        libkrb5.so.3
ELF 7d62b000-7d758000   Deferred        libgnutls-deb0.so.28
ELF 7d758000-7d7a8000   Deferred        libgssapi_krb5.so.2
ELF 7d7a8000-7d823000   Deferred        libcups.so.2
ELF 7d826000-7d830000   Deferred        libwrap.so.0
ELF 7d830000-7d83b000   Deferred        libjson-c.so.2
ELF 7d83e000-7d852000   Deferred        gnome-keyring-pkcs11.so
ELF 7d852000-7d885000   Deferred        uxtheme<elf>
  \-PE  7d860000-7d885000   \               uxtheme
ELF 7d885000-7d88c000   Deferred        libxfixes.so.3
ELF 7d88c000-7d897000   Deferred        libxcursor.so.1
ELF 7d897000-7d8a9000   Deferred        libxi.so.6
ELF 7d8a9000-7d8ad000   Deferred        libxcomposite.so.1
ELF 7d8ad000-7d8b8000   Deferred        libxrandr.so.2
ELF 7d8b8000-7d8c3000   Deferred        libxrender.so.1
ELF 7d8c3000-7d8c9000   Deferred        libxxf86vm.so.1
ELF 7d8c9000-7d8cd000   Deferred        libxinerama.so.1
ELF 7d8cd000-7d8d4000   Deferred        libxdmcp.so.6
ELF 7d8d4000-7d8d8000   Deferred        libxau.so.6
ELF 7d8d8000-7d8fa000   Deferred        libxcb.so.1
ELF 7d8fa000-7da45000   Deferred        libx11.so.6
ELF 7da45000-7da58000   Deferred        libxext.so.6
ELF 7da59000-7da5e000   Deferred        libkeyutils.so.1
ELF 7da5e000-7da63000   Deferred        libcom_err.so.2
ELF 7da63000-7da77000   Deferred        libavahi-client.so.3
ELF 7da77000-7da85000   Deferred        libavahi-common.so.3
ELF 7da87000-7db12000   Deferred        winex11<elf>
  \-PE  7da90000-7db12000   \               winex11
ELF 7db99000-7dbc2000   Deferred        libexpat.so.1
ELF 7dbc2000-7dbfe000   Deferred        libfontconfig.so.1
ELF 7dbfe000-7dc2a000   Deferred        libpng12.so.0
ELF 7dc2a000-7dcda000   Deferred        libfreetype.so.6
ELF 7dd09000-7de22000   Deferred        oleaut32<elf>
  \-PE  7dd20000-7de22000   \               oleaut32
ELF 7de22000-7dec0000   Deferred        msvcrt<elf>
  \-PE  7de40000-7dec0000   \               msvcrt
ELF 7dec0000-7dee2000   Deferred        imm32<elf>
  \-PE  7ded0000-7dee2000   \               imm32
ELF 7df06000-7df4a000   Deferred        dsound<elf>
  \-PE  7df10000-7df4a000   \               dsound
ELF 7df4a000-7df86000   Deferred        dplayx<elf>
  \-PE  7df50000-7df86000   \               dplayx
ELF 7df86000-7dfcc000   Deferred        dinput<elf>
  \-PE  7df90000-7dfcc000   \               dinput
ELF 7dfcc000-7e00b000   Deferred        winspool<elf>
  \-PE  7dfd0000-7e00b000   \               winspool
ELF 7e00b000-7e103000   Deferred        comctl32<elf>
  \-PE  7e010000-7e103000   \               comctl32
ELF 7e103000-7e173000   Deferred        shlwapi<elf>
  \-PE  7e110000-7e173000   \               shlwapi
ELF 7e173000-7e390000   Deferred        shell32<elf>
  \-PE  7e180000-7e390000   \               shell32
ELF 7e390000-7e476000   Deferred        comdlg32<elf>
  \-PE  7e3a0000-7e476000   \               comdlg32
ELF 7e476000-7e55b000   Deferred        opengl32<elf>
  \-PE  7e490000-7e55b000   \               opengl32
ELF 7e55b000-7e68d000   Deferred        wined3d<elf>
  \-PE  7e570000-7e68d000   \               wined3d
ELF 7e68d000-7e6f5000   Deferred        ddraw<elf>
  \-PE  7e690000-7e6f5000   \               ddraw
ELF 7e6f5000-7e71d000   Deferred        msacm32<elf>
  \-PE  7e700000-7e71d000   \               msacm32
ELF 7e71d000-7e797000   Deferred        rpcrt4<elf>
  \-PE  7e730000-7e797000   \               rpcrt4
ELF 7e797000-7e8ae000   Deferred        ole32<elf>
  \-PE  7e7b0000-7e8ae000   \               ole32
ELF 7e8ae000-7e914000   Deferred        advapi32<elf>
  \-PE  7e8c0000-7e914000   \               advapi32
ELF 7e914000-7ea22000   Deferred        gdi32<elf>
  \-PE  7e920000-7ea22000   \               gdi32
ELF 7ea22000-7eb6a000   Deferred        user32<elf>
  \-PE  7ea40000-7eb6a000   \               user32
ELF 7eb6a000-7ec1d000   Deferred        winmm<elf>
  \-PE  7eb70000-7ec1d000   \               winmm
ELF 7ef8d000-7ef9a000   Deferred        libnss_files.so.2
ELF 7ef9a000-7efa6000   Deferred        libnss_nis.so.2
ELF 7efa6000-7efbf000   Deferred        libnsl.so.1
ELF 7efbf000-7efc8000   Deferred        libnss_compat.so.2
ELF 7efc8000-7efd1000   Deferred        librt.so.1
ELF 7efd3000-7efe7000   Deferred        libz.so.1
ELF 7efe7000-7f000000   Deferred        version<elf>
  \-PE  7eff0000-7f000000   \               version
ELF f7343000-f7389000   Deferred        libm.so.6
ELF f7389000-f738e000   Deferred        libdl.so.2
ELF f738e000-f753b000   Deferred        libc.so.6
ELF f753b000-f7558000   Deferred        libpthread.so.0
ELF f7588000-f773b000   Dwarf           libwine.so.1
ELF f773d000-f775f000   Deferred        ld-linux.so.2
ELF f775f000-f7760000   Deferred        [vdso].so
Threads:
process  tid      prio (all id:s are in hex)
00000008 (D) C:\Spelletjes\RollerCoaster Tycoon 2\openrct2.exe
    00000026    2
    00000025   15
    00000024   15
    00000023    0
    00000022    0
    00000009    0 <==
0000000e services.exe
    0000001d    0
    0000001c    0
    00000014    0
    00000010    0
    0000000f    0
00000012 winedevice.exe
    0000001b    0
    00000018    0
    00000017    0
    00000013    0
00000019 plugplay.exe
    0000001f    0
    0000001e    0
    0000001a    0
00000020 explorer.exe
    00000021    0
System information:
    Wine build: wine-1.7.18
    Platform: i386
    Host system: Linux
    Host version: 3.16.0-31-generic
adrian17 commented 9 years ago

It's caused by the text input length being limited to 32 chars (actually 31 because of null terminator, I think), while the string "Multi-Dimension roller coaster 1" is already 32 chars long.

It is actually partially an original bug: launch the original game and try changing the name to "Multi-Dimension roller coaster 2" -> you'll see it being capped to "Multi-Dimension roller coaster ".

The original text input allowed input to be unlimited, and capped it after you accepted it. The new window has max length limit implemented in the input handler itself, so it breaks when the string is above the limit.

duncanspumpkin commented 9 years ago

I'm just going to put a quick fix on it by putting a null terminator at the expected maxLength location.