News:

Simutrans Wiki Manual
The official on-line manual for Simutrans. Read and contribute.

Cross-compiling: Linux to Windows

Started by jamespetts, November 28, 2016, 01:33:38 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

DrSuperGood

Could it be that the build is trying to use AVX or other instructions my processor does not support? It would not be the first time that nonsense error messages get generated as a result of that.

Ters

I think the last time Simutrans tried to use unsupported instructions, the error could be read as saying that. Access violation is access violation.

An offset of 0xD90 suggest the null pointer is for an array, rather than a struct/class. If it is reproducible in debug builds, it shouldn't be hard to figure out what it is. (What causes is might be more challenging.) Should it be one of those nasty only-in-release-build bugs, you could try telling gcc/ld to generate a memory map.

jamespetts

#107
Thank you both for that. The crashes that people are experiencing on the server appear to be the crash that can be reproduced on quitting on occasions. I have managed to catch this in the MinGW debugger, which gives the following backtrace:


Thread 1 received signal SIGSEGV, Segmentation fault.
karte_t::save () at simworld.cc:7899
7899    simworld.cc: No such file or directory.
(gdb) backtrace
#0  karte_t::save () at simworld.cc:7899
#1  0x00000000006e48e0 in karte_t::save () at simworld.cc:7827
#2  0x000000000066d7ad in interaction_t::process_event ()
    at siminteraction.cc:353
#3  0x000000000066da3b in interaction_t::check_events ()
    at siminteraction.cc:439
#4  0x00000000006e6b8c in karte_t::interactive () at simworld.cc:10367
#5  0x000000000067a7ed in simu_main () at simmain.cc:1362
#6  0x000000000068c0b3 in sysmain () at simsys.cc:825
#7  0x00000000004013ed in __tmainCRTStartup ()
    at /build/mingw-w64-_1w3Xm/mingw-w64-4.0.4/mingw-w64-crt/crt/crtexe.c:332
#8  0x00000000004014fb in WinMainCRTStartup ()
    at /build/mingw-w64-_1w3Xm/mingw-w64-4.0.4/mingw-w64-crt/crt/crtexe.c:184


The line in question is:


old_players[i] = settings.get_player_type(i);


in this block of code:


// do not set value for empty player
    uint8 old_players[MAX_PLAYER_COUNT];
    for(  int i=0;  i<MAX_PLAYER_COUNT;  i++  ) {
        old_players[i] = settings.get_player_type(i);
        if(  players[i]==NULL  ) {
            settings.set_player_type(i, player_t::EMPTY);
        }
    }


which is unchanged from Standard.

Edit:

Dr. Memory gives me the following output:


Dr. Memory version 1.11.0 build 2 built on Aug 29 2016 02:41:18
Dr. Memory results for pid 5480: "Simutrans-Extended-64.exe"
Application cmdline: "C:\Users\James\Documents\Development\Simutrans\simutrans-extended-sources\simutrans\Simutrans-Extended-64.exe"
Recorded 115 suppression(s) from default C:\Program Files (x86)\Dr. Memory\bin64\suppress-default.txt

Error #1: UNADDRESSABLE ACCESS: reading 0x0000000000000d90-0x0000000000000d91 1 byte(s)
# 0 Simutrans-Extended.exe!karte_t::save                  [/usr/share/games/nightly/simutrans-experimental/simworld.cc:7899]
# 1 Simutrans-Extended.exe!loadsave_t::wr_open            [dataobj/loadsave.cc:411]
# 2 Simutrans-Extended.exe!karte_t::save                  [/usr/share/games/nightly/simutrans-experimental/simworld.cc:7827]
# 3 Simutrans-Extended.exe!std::__cxx11::basic_string<>::_M_append [bauer/../boden/wege/weg.h:287]
# 4 Simutrans-Extended.exe!interaction_t::process_event   [/usr/share/games/nightly/simutrans-experimental/siminteraction.cc:353]
# 5 Simutrans-Extended.exe!SDL_GetTicks_REAL              [../src/timer/windows/SDL_systimer.c:130]
# 6 Simutrans-Extended.exe!SDL_PushEvent_REAL             [../src/events/SDL_events.c:752]
# 7 KERNEL32.dll!CreateFileA                             +0x1dd    (0x0000000076e61d5e <KERNEL32.dll+0x21d5e>)
# 8 Simutrans-Extended.exe!do_sema_b_wait_intern          [/build/mingw-w64-_1w3Xm/mingw-w64-4.0.4/mingw-w64-libraries/winpthreads/src/cond.c:625]
# 9 Simutrans-Extended.exe!pthread_getclean               [/build/mingw-w64-_1w3Xm/mingw-w64-4.0.4/mingw-w64-libraries/winpthreads/src/thread.c:940]
#10 Simutrans-Extended.exe!sem_wait                       [/build/mingw-w64-_1w3Xm/mingw-w64-4.0.4/mingw-w64-libraries/winpthreads/src/sem.c:204]
#11 Simutrans-Extended.exe!__emutls_get_address           [bauer/brueckenbauer.cc:1329]
#12 Simutrans-Extended.exe!get_random_seed                [utils/simrandom.cc:83]
#13 Simutrans-Extended.exe!interrupt_check                [/usr/share/games/nightly/simutrans-experimental/simintr.cc:103]
#14 Simutrans-Extended.exe!karte_t::step                  [/usr/share/games/nightly/simutrans-experimental/simworld.cc:5763]
#15 Simutrans-Extended.exe!karte_t::sync_step             [/usr/share/games/nightly/simutrans-experimental/simworld.cc:4732]
#16 Simutrans-Extended.exe!interaction_t::check_events    [/usr/share/games/nightly/simutrans-experimental/siminteraction.cc:439]
#17 Simutrans-Extended.exe!karte_t::interactive           [/usr/share/games/nightly/simutrans-experimental/simworld.cc:10367]
#18 Simutrans-Extended.exe!log_t::important               [utils/log.cc:72]
#19 Simutrans-Extended.exe!simu_main                      [/usr/share/games/nightly/simutrans-experimental/simmain.cc:1362]
Note: @0:03:32.214 in thread 6656
Note: instruction: movzx  0x00000d90(%rsi) -> %eax
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Ters

Sounds like this is NULL, except that there are earlier accesses to members of *this. I suggest adding a breakpoint at the beginning of save and stepping through it while looking at the data. It isn't a function that is called hundreds of times. karte_t is probably the only struct huge enough to have such high offsets for members (including nested members).

jamespetts

#109
I am having trouble getting gdb breakpoints to work - I have not used gdb for setting breakpoints in the past. "break simworld.cc:7827" has no effect, nor does "break ../simworld.cc:7827" have any effect.

Edit: Setting a breakpoint at the entry to void karte_t::save(loadsave_t *file, bool silent) allows me to discover that the program crashes on the first execution of line 7899 (which is in a for loop), and that, also, file->set_buffered(true) created a new thread when it was executed.

However, I cannot get "print i" or "print old_players" to work, as it claims that there is no such symbol in the current context:


loadsave_t::set_buffered () at dataobj/loadsave.cc:212
212     dataobj/loadsave.cc: No such file or directory.
(gdb) fin
Run till exit from #0  loadsave_t::set_buffered () at dataobj/loadsave.cc:212
[New Thread 19228.0x4114]
karte_t::save () at simworld.cc:7899
7899    simworld.cc: No such file or directory.
(gdb) s

Thread 1 received signal SIGSEGV, Segmentation fault.
karte_t::save () at simworld.cc:7899
7899    in simworld.cc
(gdb) print
The history is empty.
(gdb) print old_players
No symbol "old_players" in current context.
(gdb) print i
No symbol "i" in current context.
(gdb) backtrace
#0  karte_t::save () at simworld.cc:7899
#1  0x00000000006e48e0 in karte_t::save () at simworld.cc:7827
#2  0x000000000066d7ad in interaction_t::process_event ()
    at siminteraction.cc:353
#3  0x000000000066da3b in interaction_t::check_events ()
    at siminteraction.cc:439
#4  0x00000000006e6b8c in karte_t::interactive () at simworld.cc:10367
#5  0x000000000067a7ed in simu_main () at simmain.cc:1362
#6  0x000000000068c0b3 in sysmain () at simsys.cc:825
#7  0x00000000004013ed in __tmainCRTStartup ()
    at /build/mingw-w64-_1w3Xm/mingw-w64-4.0.4/mingw-w64-crt/crt/crtexe.c:332
#8  0x00000000004014fb in WinMainCRTStartup ()
    at /build/mingw-w64-_1w3Xm/mingw-w64-4.0.4/mingw-w64-crt/crt/crtexe.c:184


Edit 2: I think that I have now managed to solve this by changing the compile settings, removing the -DPTW32_STATIC_LIB flag and selecting different versions of the include files for pthreads, zlib and bzlib. The corrected version is now available on the server, and I should be grateful if anyone could test this and confirm that this now works without crashing.

Thank you all for your help.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.