The International Simutrans Forum

 

Author Topic: Cross-compiling: Linux to Windows  (Read 16607 times)

0 Members and 1 Guest are viewing this topic.

Offline DrSuperGood

  • Dev Team
  • Devotee
  • *
  • Posts: 2519
  • Languages: EN
Re: Cross-compiling: Linux to Windows
« Reply #105 on: January 20, 2018, 01:16:27 AM »
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.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5340
  • Languages: EN, NO
Re: Cross-compiling: Linux to Windows
« Reply #106 on: January 20, 2018, 09:27:37 AM »
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.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 17715
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Cross-compiling: Linux to Windows
« Reply #107 on: January 20, 2018, 12:54:03 PM »
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:

Code: [Select]
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:

Code: [Select]
old_players[i] = settings.get_player_type(i);

in this block of code:

Code: [Select]
// 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:

Code: [Select]
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
« Last Edit: January 20, 2018, 01:15:58 PM by jamespetts »

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5340
  • Languages: EN, NO
Re: Cross-compiling: Linux to Windows
« Reply #108 on: January 20, 2018, 01:32:46 PM »
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).

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 17715
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Cross-compiling: Linux to Windows
« Reply #109 on: January 20, 2018, 05:03:23 PM »
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:

Code: [Select]
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.
« Last Edit: January 20, 2018, 06:48:30 PM by jamespetts »